AtlasOfLivingAustralia / avh-hub

Australian Virtual Herbarium
https://avh.ala.org.au
Mozilla Public License 2.0
4 stars 2 forks source link

Boolean search in Advanced search form #146

Closed nielsklazenga closed 7 months ago

nielsklazenga commented 8 months ago

This is based on ticket https://support.ehelp.edu.au/a/tickets/189804: [avh] Improve AVH suggestion

The user wants to query for two different name strings for the same person, for example, 'Eaton, A.' and 'Heal, A.'. The user wants to do that in the 'Collector' field by entering de string Eaton, A. OR Heal, A., but that particular request I knocked back two or three years ago.

However, I am pretty sure I used to be able to do things like collector_text:"Eaton, A." OR collector_text:"Heal, A." in the full-text search. Currently, this functionality is broken, as when the user input is converted to a query string, the string gets prepended with 'text:' (which seems to make sense, as this is the 'text' field) and also the translation of spaces to '+' appears to be a problem for SOLR.

It would be great if this functionality could be re-instated. It seems to me a fairly easy change in the 'Advanced search' code, i.e. not prepending the string with 'text:' if the input already has a colon in it and using '%20' instead of '+' to replace spaces.

adam-collins commented 7 months ago

Full text search on the advanced search tab is adding the prefix text: and wrapping the context in double quotes. This is unnecessary because text is the default field.

I will need to look into this a bit more as the wrapping of the full text search in double quotes may or may not still be required for some searches. If the behaviour has changed then there should be some record and hopefully a reason is included.

adam-collins commented 7 months ago

After consideration please use this alternative approach. Construct your own URL to do this search. Start with https://avh.ala.org.au/occurrences/search?q= and add your query. The example in this issue would result in https://avh.ala.org.au/occurrences/search?q=collector_text:%22Eaton,%20A.%22%20OR%20collector_text:%22Heal,%20A.%22

Some context. ala-hub has the label on this search box ALL of these words (full text). This is not as accurate as I prefer but is more informative than the avh-hub's text. The actual search done is text:"{user input}". It looks like this has been the case since 2021. Pre-2021 it was text:{user input} which fails for the given example. The text: prefix is unnecessary as this is the default, i.e. a search on the text field. The wrapping of quotes is necessary so that it does not end up doing a {first word} OR {second word} type of search.

The mechanism to detect a valid search to avoid the wrapping with double quotes is not worth the trouble when the alternative exists.

Note that this field has since been renamed from collector_text to text_recordedBy. The old name still works but please consider using the new name.