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 John Brewer <Jo...@atozdatabases.com> on 2011/08/11 19:38:46 UTC

Searching For Term 'OR'

Hello,

  I am looking for some advice on how to index and search a field that contains a two character state name without the query parser dying on the OR and also not treating it as an 'OR' Boolean operator.

  For example:

  The following query with a filter query key/value pair causes an exception:

  q=*:*&fq=(state:OR)

Caused by: org.apache.lucene.queryParser.ParseException: Encountered " <OR> "OR "" at line 1, column 7.
Was expecting one of:
    "(" ...
    "*" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...

  Note: we had the same issue with Indiana (IN), but removing that stop word fixed it. Removing the stopword 'or', has not helped.

  The field itself is indexed and stored as string field during indexing.
   <field name="state" type="string" indexed="true" stored="true"/>


Thanks in advance,
John Brewer


RE: Searching For Term 'OR'

Posted by Rode González <ro...@libnova.es>.
hi, 

use the filter LowerCaseFilterFactory (don't work with string type, you must
create a new fieldtype of text type) 

or use scaped forms:

\OR
\AND

I tried it a moment ago and it works.

saludos
---
Rode González


> -----Mensaje original-----
> De: Tomás Fernández Löbbe [mailto:tomasflobbe@gmail.com]
> Enviado el: jueves, 11 de agosto de 2011 19:58
> Para: solr-user@lucene.apache.org
> Asunto: Re: Searching For Term 'OR'
> 
> I guess this is because Lucene QP is interpreting the 'OR' operator.
> You can either:
>      use lowercase
>      use other query parser, like the term query parser. See
> http://lucene.apache.org/solr/api/org/apache/solr/search/TermQParserPlu
> gin.html
> 
> Also, if you just removed the "or" term from the stopwords, you'll
> probably
> have to reindex if you want it in the index.
> 
> Regards,
> 
> Tomás
> 
> On Thu, Aug 11, 2011 at 2:38 PM, John Brewer
> <Jo...@atozdatabases.com>wrote:
> 
> > Hello,
> >
> >  I am looking for some advice on how to index and search a field that
> > contains a two character state name without the query parser dying on
> the OR
> > and also not treating it as an 'OR' Boolean operator.
> >
> >  For example:
> >
> >  The following query with a filter query key/value pair causes an
> > exception:
> >
> >  q=*:*&fq=(state:OR)
> >
> > Caused by: org.apache.lucene.queryParser.ParseException: Encountered
> " <OR>
> > "OR "" at line 1, column 7.
> > Was expecting one of:
> >    "(" ...
> >    "*" ...
> >    <QUOTED> ...
> >    <TERM> ...
> >    <PREFIXTERM> ...
> >    <WILDTERM> ...
> >    "[" ...
> >    "{" ...
> >    <NUMBER> ...
> >
> >  Note: we had the same issue with Indiana (IN), but removing that
> stop word
> > fixed it. Removing the stopword 'or', has not helped.
> >
> >  The field itself is indexed and stored as string field during
> indexing.
> >   <field name="state" type="string" indexed="true" stored="true"/>
> >
> >
> > Thanks in advance,
> > John Brewer
> >
> >
> 
> -----
> No se encontraron virus en este mensaje.
> Comprobado por AVG - www.avg.com
> Versión: 10.0.1392 / Base de datos de virus: 1520/3827 - Fecha de
> publicación: 08/11/11

-----
No se encontraron virus en este mensaje.
Comprobado por AVG - www.avg.com
Versión: 10.0.1392 / Base de datos de virus: 1520/3827 - Fecha de
publicación: 08/11/11



Re: Searching For Term 'OR'

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
I guess this is because Lucene QP is interpreting the 'OR' operator.
You can either:
     use lowercase
     use other query parser, like the term query parser. See
http://lucene.apache.org/solr/api/org/apache/solr/search/TermQParserPlugin.html

Also, if you just removed the "or" term from the stopwords, you'll probably
have to reindex if you want it in the index.

Regards,

Tomás

On Thu, Aug 11, 2011 at 2:38 PM, John Brewer
<Jo...@atozdatabases.com>wrote:

> Hello,
>
>  I am looking for some advice on how to index and search a field that
> contains a two character state name without the query parser dying on the OR
> and also not treating it as an 'OR' Boolean operator.
>
>  For example:
>
>  The following query with a filter query key/value pair causes an
> exception:
>
>  q=*:*&fq=(state:OR)
>
> Caused by: org.apache.lucene.queryParser.ParseException: Encountered " <OR>
> "OR "" at line 1, column 7.
> Was expecting one of:
>    "(" ...
>    "*" ...
>    <QUOTED> ...
>    <TERM> ...
>    <PREFIXTERM> ...
>    <WILDTERM> ...
>    "[" ...
>    "{" ...
>    <NUMBER> ...
>
>  Note: we had the same issue with Indiana (IN), but removing that stop word
> fixed it. Removing the stopword 'or', has not helped.
>
>  The field itself is indexed and stored as string field during indexing.
>   <field name="state" type="string" indexed="true" stored="true"/>
>
>
> Thanks in advance,
> John Brewer
>
>

RE: Searching For Term 'OR'

Posted by John Brewer <Jo...@atozdatabases.com>.
Thanks for the advice everyone. I am rebuilding the index with a lowercase field instead of string.

-----Original Message-----
From: Chris Hostetter [mailto:hossman_lucene@fucit.org] 
Sent: Thursday, August 11, 2011 1:10 PM
To: solr-user@lucene.apache.org
Subject: Re: Searching For Term 'OR'


:   I am looking for some advice on how to index and search a field that 
: contains a two character state name without the query parser dying on
: the OR and also not treating it as an 'OR' Boolean operator.

fq={!term f=state}OR

...this kind of filter you don't want a query parser that has any metacharacters.


-Hoss

Re: Searching For Term 'OR'

Posted by Chris Hostetter <ho...@fucit.org>.
:   I am looking for some advice on how to index and search a field that 
: contains a two character state name without the query parser dying on 
: the OR and also not treating it as an 'OR' Boolean operator.

fq={!term f=state}OR

...this kind of filter you don't want a query parser that has any 
metacharacters.


-Hoss