Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by value only #83

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
12 changes: 12 additions & 0 deletions app_data/test_index_data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"complex_test_cases":{
"query_image_and_value_only":[
[
"hela",
"kif1"
]
],
"query_image_or_value_only":[
[
"pdxdc1",
"pdx1"
]
],
"query_image_and":[
[
[
Expand Down
48 changes: 48 additions & 0 deletions examples/search_by_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2023 University of Dundee & Open Microscopy Environment.
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import sys
from utils import query_the_search_ending, logging

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

"""
This example will use search by value only without key
It will search for thr images which have key/value
pairs which the vlaue contains cancer"""

query = {
"and_filters": [
{"value": "cancer", "operator": "contains"},
],
"or_filters": [],
}

main_attributes = []
logging.info("Sending the query:")
results_1 = query_the_search_ending(query, main_attributes)

and_filters = [
{"name": "cell line", "value": "hela", "operator": "equals"},
{"value": "kif", "operator": "contains"},
]
query = {"and_filters": and_filters, "or_filters": []}

logging.info("Sending the second query:")
results_2 = query_the_search_ending(query, main_attributes)
10 changes: 7 additions & 3 deletions omero_search_engine/api/v1/resources/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,13 @@ def simple_search(
):
if not operator:
operator = "equals"
and_filters = [
{"name": key, "value": value, "operator": operator, "resource": resource}
]
if key:
and_filters = [
{"name": key, "value": value, "operator": operator, "resource": resource}
]
else:
and_filters = [{"value": value, "operator": operator, "resource": resource}]

query_details = {"and_filters": and_filters}
if bookmark:
bookmark = [bookmark]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "filter_schema",
"type": "object",
"additionalProperties": true,
"required": ["name","value","operator"],
"required": ["value","operator"],
"properties": {
"name": {
"name": "name",
Expand Down
6 changes: 3 additions & 3 deletions omero_search_engine/api/v1/resources/swagger_docs/search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ parameters:
description: the resource attribute
in: query
type: string
required: true
required: False
- name: value
description: the attribute value
in: query
type: string
required: true
- name: study
description: filter by study name
in: query
description: fi lter by study name
in: querygit push
type: string
required: False
- name: operator
Expand Down
Loading
Loading