Issue 17104

Registry solr exception

17104
Reporter: mdoering
Assignee: fmendez
Type: Bug
Summary: Registry solr exception
Priority: Major
Resolution: Fixed
Status: Resolved
Created: 2015-02-06 10:13:50.704
Updated: 2015-02-07 02:09:00.303
Resolved: 2015-02-07 02:09:00.244
        
Description: Found this in the registry logs:
-----
ERROR [2015-02-06 01:57:20,466+0100] [qtp1876233337-2258] org.apache.solr.core.SolrCore: org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError: Can
not parse '(dataset_title_nedge:"Psychotria greenwellieae\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram
:greenwellieae\\^200)': Lexical error at line 1, column 177.  Encountered:  after : "\"Psychotria greenwellieae\\\"^1000 OR dataset_title_nedge:Psychotria^1000)
OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\\\^200)"
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:171)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)
        at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:150)
        at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
        at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
        at org.gbif.common.search.service.SolrSearchSuggestService.suggest(SolrSearchSuggestService.java:133)
        at org.gbif.registry.ws.resources.DatasetResource.suggest(DatasetResource.java:173)


...


Caused by: org.apache.solr.search.SyntaxError: Cannot parse '(dataset_title_nedge:"Psychotria greenwellieae\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\^200)': Lexical error at line 1, column 177.  Encountered:  after : "\"Psychotria greenwellieae\\\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\\\^200)"
        at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:167)
        at org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:50)
        at org.apache.solr.search.QParser.getQuery(QParser.java:142)
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:142)
        ... 54 more
Caused by: org.apache.solr.parser.TokenMgrError: Lexical error at line 1, column 177.  Encountered:  after : "\"Psychotria greenwellieae\\\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\\\^200)"
        at org.apache.solr.parser.QueryParserTokenManager.getNextToken(QueryParserTokenManager.java:1197)
        at org.apache.solr.parser.QueryParser.jj_ntk(QueryParser.java:581)
        at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:175)
        at org.apache.solr.parser.QueryParser.Query(QueryParser.java:108)
        at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:190)
        at org.apache.solr.parser.QueryParser.Query(QueryParser.java:108)
        at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:97)
        at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:160)
        ... 57 more

WARN  [2015-02-06 01:57:20,471+0100] [qtp1876233337-2258] org.eclipse.jetty.servlet.ServletHandler: /dataset/suggest
org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError: Cannot parse '(dataset_title_nedge:"Psychotria greenwellieae\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\^200)': Lexical error at line 1, column 177.  Encountered:  after : "\"Psychotria greenwellieae\\\"^1000 OR dataset_title_nedge:Psychotria^1000) OR (dataset_title_ngram:Psychotria^300 OR dataset_title_ngram:greenwellieae\\\\^200)"
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:171) ~[registry-ws-2.20.jar:2.21-SNAPSHOT]
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187) ~[registry-ws-2.20.jar:2.21-SNAPSHOT]
]]>
    


Author: fmendez@gbif.org
Created: 2015-02-06 17:06:49.551
Updated: 2015-02-06 17:06:49.551
        
This error happens in the 'suggest' service when the input query it's a phrase and contains apostrophes, the following example:
http://api.gbif.org/v1/dataset/suggest?q=%22mad%20dog%22&type=OCCURRENCE

throws the same error:

org.apache.solr.common.SolrException: org.apache.solr.search.SyntaxError: Cannot parse '(dataset_title_nedge:""mad dog""^1000 OR dataset_title_nedge:"mad^1000) OR (dataset_title_ngram:\"mad^300 OR dataset_title_ngram:dog\"^200)': Lexical error at line 1, column 140.  Encountered:  after : "\"mad^1000) OR (dataset_title_ngram:\\\"mad^300 OR dataset_title_ngram:dog\\\"^200)"
	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:171)
	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187)
    


Author: fmendez@gbif.org
Created: 2015-02-07 02:09:00.299
Updated: 2015-02-07 02:09:00.299
        
gbif-common-search was fixed to escape correctly special characters in phrase queries

https://github.com/gbif/common-search/commit/0f9722b7869334fd5cd3ed8eec5d4db8d68d59ba

example: http://api.gbif-dev.org/v1/dataset/suggest?q=%22puma%20con%22