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 manuel aldana <al...@gmx.de> on 2009/07/26 23:14:28 UTC

problems with + operator (seem to be treated as normal char and not as operator)

hi,

I am having queries:
+a b
a b

I always wondered why the + operator did not work. Looking at the 
http://localhost:8983/solr/admin/analysis.jsp analysis trace the query 
analzyer indeed is removing the + through the 
WordDelemiterFilterFactory. So I removed this filter (btw: why is this 
the default setting, which I think is a bit dangerous because the 
special + - operators are thus removed).

Still '+a b' matches documents which have no 'a' inside the field. Now I 
guess solr is handling the '+' as a normal match character and not as an 
lucene (required) operator at all? Is this correct. If so, why is this 
lucene operator overridden? Maybe I need to escape the + for solr, so it 
treats it as an operator?

thanks.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


Re: problems with + operator (seem to be treated as normal char and not as operator)

Posted by manuel aldana <al...@gmx.de>.
Koji Sekiguchi wrote:
> To debug quert parser, use FULL INTERFACE admin form 
> (http://localhost:8983/solr/admin/form.jsp)
> and check Debug: enable and see debug info. You cannot use 
> analysis.jsp for this purpose
> because it doesn't use query parser.
I see, good to know... I was already very confused and debugged my head 
off :)

> Solr should use lucene query parser as long as you never explicitly 
> use query parser
> other than lucene through defType, localParams, etc...
> I'm just guessing 'a' was filtered out by StopFilter?
>
you were right, the default lucene query parser was overridden.

thanks.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


Re: problems with + operator (seem to be treated as normal char and not as operator)

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
manuel aldana wrote:
> hi,
>
> I am having queries:
> +a b
> a b
>
> I always wondered why the + operator did not work. Looking at the 
> http://localhost:8983/solr/admin/analysis.jsp analysis trace the query 
> analzyer indeed is removing the + through the 
> WordDelemiterFilterFactory. So I removed this filter (btw: why is this 
> the default setting, which I think is a bit dangerous because the 
> special + - operators are thus removed).
>
To debug quert parser, use FULL INTERFACE admin form 
(http://localhost:8983/solr/admin/form.jsp)
and check Debug: enable and see debug info. You cannot use analysis.jsp 
for this purpose
because it doesn't use query parser.

> Still '+a b' matches documents which have no 'a' inside the field. Now 
> I guess solr is handling the '+' as a normal match character and not 
> as an lucene (required) operator at all? Is this correct. If so, why 
> is this lucene operator overridden? Maybe I need to escape the + for 
> solr, so it treats it as an operator?
>
> thanks.
>
Solr should use lucene query parser as long as you never explicitly use 
query parser
other than lucene through defType, localParams, etc...
I'm just guessing 'a' was filtered out by StopFilter?

With example schema.xml, you can see:

http://localhost:8983/solr/select?q=%2Ba+b&debugQuery=on

<str name="rawquerystring">+a b</str>
<str name="querystring">+a b</str>
<str name="parsedquery">text:b</str>
<str name="parsedquery_toString">text:b</str>


http://localhost:8983/solr/select?q=cat%3A(%2Ba+b)&debugQuery=on

<str name="rawquerystring">cat:(+a b)</str>
<str name="querystring">cat:(+a b)</str>
<str name="parsedquery">+cat:a cat:b</str>
<str name="parsedquery_toString">+cat:a cat:b</str>

Koji