senaite / senaite.jsonapi

RESTful JSON API for SENAITE
https://www.senaite.com
GNU General Public License v2.0
11 stars 19 forks source link

Index search not working for catalogs other than 'portal_catalog' #23

Closed ramonski closed 6 years ago

ramonski commented 6 years ago

Steps to reproduce

Query an index of a catalog other than portal_catalog, e.g.:

@@API/senaite/v1/search??catalog=bika_analysis_catalog&Title=Weight*

Current behavior

If the index searched for is does exist in portal_catalog (yes, portal_catalog), than it is ignored.

See the Code here: https://github.com/senaite/senaite.jsonapi/blob/master/src/senaite/jsonapi/catalog.py#L75

Expected behavior

The index check uses the right catalog and builds the query accordingly

Screenshot (optional)

nihadness commented 6 years ago

/API/senaite/v1/search?catalog=bika_analysis_catalog&title=Bacterial%20Identification works but /API/senaite/v1/search?catalog=bika_analysis_catalog&title=Bacterial* doesn't. So in your case it is probably because of Title. But it seems wildcards do not work anyways.

ramonski commented 6 years ago

Please see the code above. It filters out any index name that is not present in the queried catalog, but unfortunately uses always portal_catalog

nihadness commented 6 years ago

Dear @ramonski , my changes must solve the problem about searching by indexes which is the real issue. But that thing about wildcards still won't work.

ramonski commented 6 years ago

Thanks @nihadness! Indeed, the wildcard search is a feature the index has to support and as far as I know only the ZCTextIndex is capable to do so. Regarding the catalogs, we need to add the other catalogs as well, e.g. the bika_catalog_analysisrequest_listing, bika_catalog_worksheet_listing etc. Otherwise these catalogs can't be selected via the catalog request parameter

nihadness commented 6 years ago

yes as you said, we can only search by SearchableText index in our catalogs, since it is the only ZCTextIndex for all catalogs... So how should it work when user wants to search by another index? E.g: getKeyword='test*'. Should the system query by SearchableText (let's say Keyword field value is inSearchableText) and then check if getKeyword field matches that test* Regular Expression? Because it might happen that 'test' is not a keyword but a title, and SearchableText contains that field as well.... Let me know if I am clear : )