AtlasOfLivingAustralia / biocache-service

Occurrence & mapping webservices
https://biocache-ws.ala.org.au/ws/
Other
9 stars 26 forks source link

Biocache-service compelx search query error. #778

Closed sughics closed 1 year ago

sughics commented 1 year ago
  1. Reported by Martin:

    The following query

    https://biocache-ws.ala.org.au/ws/occurrences/search?fq=%28raw_scientificName%3A%22Apis%20cerana%20%28exotic%20strains%2C%20genotypes%20and%20sub-species%29%22%29%20AND%20decimalLongitude%3A%5B110%20TO%20154%5D%20AND%20decimalLatitude%3A%5B-55%20TO%20-10%5D%20AND%20%28year%3A%222022%22%29%20AND%20month%3A%5B12%20TO%20%2A%5D%20AND%20day%3A%5B5%20TO%20%2A%5D&disableAllQualityFilters=true&pageSize=0

    returns

    {
    "message": "Error from server at null: org.apache.solr.search.SyntaxError: Cannot parse '(raw_scientificName:\"Apis cerana (exotic strains': Lexical error at line 1, column 49.  Encountered: <EOF> after : \"\\"Apis cerana (exotic strains\"", "errorType": "Query syntax invalid", "statusCode": 400
    }

    tbh I’m guessing it was the comma that caused the problem because it’s the common element among the 4 failed queries, but I could be wrong. I could easily remove it from the string, but I think it used to work, so thought I’d check

2 . Reported by @timhicks-ala via user support request

Filtering searches by collector appears broken - 400 errors on both AVH and regular Biocache, eg: https://biocache.ala.org.au/occurrences/search?q=taxa%3A%22Geophila%22&qualityProfile=ALA&fq=collector%3A%22Forster%2C+P.I.%22

This is the the request made to biocache-service: https://biocache-ws.ala.org.au/ws/occurrences/search?q=taxa%3A%22Geophila%22&fq=collector%3A%22Forster%2C%20P.I.%22&qualityProfile=ALA&start=0&pageSize=20&sort=first_loaded_date&dir=desc&qc=&facets=taxon_name%2Cfamily%2Ccommon_name%2Cspecies_group%2Cstate%2Csensitive%2Cmonth%2Coccurrence_decade_i%2Cbasis_of_record%2Cmultimedia%2Coccurrence_status%2Cinstitution_uid%2Cdata_resource_uid%2CcontentTypes&flimit=1

returns

    {
    "message": "Error from server at null: org.apache.solr.search.SyntaxError: Cannot parse 'recordedBy:\"Forster': Lexical error at line 1, column 20.  Encountered: <EOF> after : \"\\"Forster\"", "errorType": "Query syntax invalid", "statusCode": 400
    }
timhicks-ala commented 1 year ago

(Helpdesk reference) Filtering by collector raised in: https://support.ehelp.edu.au/a/tickets/164422 https://support.ehelp.edu.au/a/tickets/164479 https://support.ehelp.edu.au/a/tickets/168541 https://support.ehelp.edu.au/a/tickets/170581 https://support.ehelp.edu.au/a/tickets/172542

adam-collins commented 1 year ago

Confirmed that the problem is indeed the comma in the fq. org.springframework.core.convert.support.StringToArrayConverter is used when there is a single fq and it splits on commas. Noting that this is appropriate for the facets parameter that is the same type String[].

The fault will always occur when there is a comma in a query with a single fq value. An ugly workaround is to add &fq= to the end of a request or swap the fq containing the comma with the q that does not.

adam-collins commented 1 year ago

https://github.com/AtlasOfLivingAustralia/biocache-service/tree/remove-fq-delimiter

sughics commented 1 year ago

Released with 3.2.0