You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ramo Karahasan <ra...@googlemail.com> on 2012/03/01 10:34:57 UTC

Problem using double quotes in search string

Hi,

 

I've got an issue when searching with a searchtstring like:  'title:"Blue"
on "Blu' . the original searchstring is: 'title:"Blue" on "Blue"' and this
works well. If I now delete the last double quote and the "e" than I get the
error below. Is there any filter that can handle such searches which I have
to configure?

 

 

 

 

org.apache.solr.common.SolrException log SEVERE:
org.apache.solr.common.SolrException:
org.apache.lucene.queryParser.ParseException: Cannot parse 'title:"Blue" on
"Blu': Lexical error at line 1, column 21. Encountered: <EOF> after :
"\"Blu" at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java
:125) at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHand
ler.java:173) at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.
java:129) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372) at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:3
56) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:
252) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127
) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:588) at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at
java.lang.Thread.run(Thread.java:636) Caused by:
org.apache.lucene.queryParser.ParseException: Cannot parse 'title:"Blue" on
"Blu': Lexical error at line 1, column 21. Encountered: <EOF> after :
"\"Blu" at
org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:216) at
org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:80) at
org.apache.solr.search.QParser.getQuery(QParser.java:142) at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java
:101) ... 17 more Caused by: org.apache.lucene.queryParser.TokenMgrError:
Lexical error at line 1, column 21. Encountered: <EOF> after : "\"Blu" at
org.apache.lucene.queryParser.QueryParserTokenManager.getNextToken(QueryPars
erTokenManager.java:1229) at
org.apache.lucene.queryParser.QueryParser.jj_scan_token(QueryParser.java:170
9) at
org.apache.lucene.queryParser.QueryParser.jj_3R_2(QueryParser.java:1598) at
org.apache.lucene.queryParser.QueryParser.jj_3_1(QueryParser.java:1605) at
org.apache.lucene.queryParser.QueryParser.jj_2_1(QueryParser.java:1585) at
org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1280) at
org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1266) at
org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:122
6) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
... 20 more Mar 1, 2012 10:23:50 AM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException:
org.apache.lucene.queryParser.ParseException: Cannot parse 'title:"Blue" on
"Bl': Lexical error at line 1, column 20. Encountered: <EOF> after : "\"Bl"
at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java
:125) at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHand
ler.java:173) at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.
java:129) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372) at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:3
56) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:
252) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127
) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:588) at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at
java.lang.Thread.run(Thread.java:636) Caused by:
org.apache.lucene.queryParser.ParseException: Cannot parse 'title:"Blue" on
"Bl': Lexical error at line 1, column 20. Encountered: <EOF> after : "\"Bl"
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:216) at
org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:80) at
org.apache.solr.search.QParser.getQuery(QParser.java:142) at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java
:101) ... 17 more Caused by: org.apache.lucene.queryParser.TokenMgrError:
Lexical error at line 1, column 20. Encountered: <EOF> after : "\"Bl" at
org.apache.lucene.queryParser.QueryParserTokenManager.getNextToken(QueryPars
erTokenManager.java:1229) at
org.apache.lucene.queryParser.QueryParser.jj_scan_token(QueryParser.java:170
9) at
org.apache.lucene.queryParser.QueryParser.jj_3R_2(QueryParser.java:1598) at
org.apache.lucene.queryParser.QueryParser.jj_3_1(QueryParser.java:1605) at
org.apache.lucene.queryParser.QueryParser.jj_2_1(QueryParser.java:1585) at
org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1280) at
org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1266) at
org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:122
6) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
... 20 more

 

 

Best regards,

Ramo


Re: AW: AW: Problem using double quotes in search string

Posted by Ahmet Arslan <io...@yahoo.com>.
> what about, if a search string starts with "$o$" ? this is
> not recognized by
> dismax too, right? Is there another filter I have to use?

I don't fully follow your question but it seems that you want to search special characters too? With raw or term query parser plugin you can do that. 

http://wiki.apache.org/solr/SolrQuerySyntax#Other_built-in_useful_query_parsers

Another approach is to escape those special characters. 

http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html#Escaping%20Special%20Characters

AW: AW: Problem using double quotes in search string

Posted by Ramo Karahasan <ra...@googlemail.com>.
Hi,

what about, if a search string starts with "$o$" ? this is not recognized by
dismax too, right? Is there another filter I have to use?


Thanks,
Ramo

-----Ursprüngliche Nachricht-----
Von: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Gesendet: Donnerstag, 1. März 2012 12:44
An: solr-user@lucene.apache.org
Betreff: Re: AW: Problem using double quotes in search string


> does that effect my result list? Because if i use the dismax, and type 
> into my search field the title "blue on blue" (without quotes), I get 
> this product as a first result. If I use dismax without boosting and 
> search for "blue on blue" (without quotes) I'm not getting this result 
> in the first 10 shown items.

Did you use q=blue on blue&defType=dismax&qf=title&pf=title&mm=100%  ?

DisMax makes more sense when you search on multiple fields. It has some
useful parameters to tweak relevancy.

However you can steal and use the same code (stripIllegalOperators and
stripUnbalancedQuotes) on the client side. 

http://lucene.apache.org/solr/api/org/apache/solr/util/SolrPluginUtils.html#
stripUnbalancedQuotes%28java.lang.CharSequence%29


Re: AW: Problem using double quotes in search string

Posted by Ahmet Arslan <io...@yahoo.com>.
> does that effect my result list? Because if i use the 
> dismax, and type into
> my search field the title "blue on blue" (without quotes), I
> get this
> product as a first result. If I use dismax without boosting
> and search for
> "blue on blue" (without quotes) I'm not getting this result
> in the first 10
> shown items.

Did you use q=blue on blue&defType=dismax&qf=title&pf=title&mm=100%  ?

DisMax makes more sense when you search on multiple fields. It has some useful parameters to tweak relevancy.

However you can steal and use the same code (stripIllegalOperators and  stripUnbalancedQuotes) on the client side. 

http://lucene.apache.org/solr/api/org/apache/solr/util/SolrPluginUtils.html#stripUnbalancedQuotes%28java.lang.CharSequence%29

AW: Problem using double quotes in search string

Posted by Ramo Karahasan <ra...@googlemail.com>.
Hi,

does that effect my result list? Because if i use the  dismax, and type into
my search field the title "blue on blue" (without quotes), I get this
product as a first result. If I use dismax without boosting and search for
"blue on blue" (without quotes) I'm not getting this result in the first 10
shown items.

Thanks
Ramo

-----Ursprüngliche Nachricht-----
Von: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Gesendet: Donnerstag, 1. März 2012 10:56
An: solr-user@lucene.apache.org
Betreff: Re: Problem using double quotes in search string

 
> I've got an issue when searching with a searchtstring
> like:  'title:"Blue"
> on "Blu' . the original searchstring is: 'title:"Blue" on "Blue"' and 
> this works well. If I now delete the last double quote and the "e" 
> than I get the error below. Is there any filter that can handle such 
> searches which I have to configure?

This is about query parser. " is a special character.

dismax query parser strips unbalanced quotes. 
http://www.lucidimagination.com/blog/2010/05/23/whats-a-dismax/


Re: Problem using double quotes in search string

Posted by Ahmet Arslan <io...@yahoo.com>.
 
> I've got an issue when searching with a searchtstring
> like:  'title:"Blue"
> on "Blu' . the original searchstring is: 'title:"Blue" on
> "Blue"' and this
> works well. If I now delete the last double quote and the
> "e" than I get the
> error below. Is there any filter that can handle such
> searches which I have
> to configure?

This is about query parser. " is a special character.

dismax query parser strips unbalanced quotes. 
http://www.lucidimagination.com/blog/2010/05/23/whats-a-dismax/