ome / omero_search_engine

App which is used to search metadata (key-value pairs)
GNU General Public License v2.0
1 stars 4 forks source link

searchvalues not returning study Names #54

Open will-moore opened 2 years ago

will-moore commented 2 years ago

Trying to find studies by Name or IDR number with:

https://idr-testing.openmicroscopy.org/searchengine/api/v1/resources/all/searchvalues/?value=idr0012&key=Name+(IDR+number)

doesn't return anything. Removing the key doesn't help (finds 1 other match but not Name).

will-moore commented 1 year ago

In order to replace the manual JavaScript - based approach to searching for Studies, I can use Key-Value pairs to search for studies using the search engine (see https://github.com/IDR/idr-gallery/pull/20) but I still have to use a 'manual' approach or different endpoints for searching for Name and Description. In #57 I should be able to search by Name, or load ALL names and filter locally. But I would have to do the same again for description and then combine those results with the /searchvalues/ endpoint to provide auto-complete results.

It would be really nice if "Name" and "Description" were considered to be Key/Value pairs on the objects for the purposes of searchvalues. Or this could be optional with https://idr-testing.openmicroscopy.org/searchengine/api/v1/resources/all/searchvalues/?value=idr0012&key=Name&key=Description and the default behaviour would be just to search kv pairs?

khaledk2 commented 1 year ago

I have modified the names endpoint to be able to search both names and descriptions. The user needs to add use_description=true in the URL, then the searchengine searches both name and description using the provided value. The returned result is a dict which contains the study names and the descriptions.

For example, to search all the studies (screens and projects) which their names or description containing cell, the user can submit this request:

http://idr-testing.openmicroscopy.org/searchengine/api/v1/resources/all/names/?value=cell&use_description=true

The current behaviour is maintained if the user does not set use_description=true.

It is deployed in idr-testing, Please check it and let me what do you think.

will-moore commented 1 year ago

This is actually working fine for me, but I'm worried this is not going to work so well outside of IDR since it assumes that the Name can be used as a project/screen identifier. Only in IDR can we assume that Names are unique. If omero_search_engine is used elsewhere, we will need the object ID. Probably a better format is:

{
  "screens": [
    {"id": 123, "Name": "My Screen", "Description": "Screen Description"}
  ],
  "projects": []
}

This would also allow us to add other info in future, e.g. group, owner, creation-date etc.

will-moore commented 1 year ago

I also realise that this search really needs to be case insensitive.

E.g. https://idr-testing.openmicroscopy.org/searchengine/api/v1/resources/all/names/?value=analysis&use_description=true and https://idr-testing.openmicroscopy.org/searchengine/api/v1/resources/all/names/?value=Analysis&use_description=true should return the same results.