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 Bastien Latard - MDPI AG <la...@mdpi.com.INVALID> on 2016/04/22 11:26:27 UTC

How can I set the defaultOperator to be AND?

Hi guys,

How can I set the defaultOperator to be AND?
If I add the following line to the schema.xml, even if I do a search 
'title:"test" OR author:"me"', it will returns documents matching 
'title:"test" AND author:"me"':
<solrQueryParser defaultOperator="AND"/>

solr version: 6.0

I know that I can overwrite the query with q.op, but this is not that 
convenient...
I would need to write a complex query for a simple search '(a:x AND b:y) 
OR c:z'

Kind regards,
Bastien Latard
Web engineer
-- 
MDPI AG
Postfach, CH-4005 Basel, Switzerland
Office: Klybeckstrasse 64, CH-4057
Tel. +41 61 683 77 35
Fax: +41 61 302 89 18
E-mail:
latard@mdpi.com
http://www.mdpi.com/


Re: How can I set the defaultOperator to be AND?

Posted by Georg Sorst <g....@findologic.com>.
With Solr 6.0 I've had to set mm=100% & q.op=AND for a full AND query (and
mm=1 & q.op=OR for a full OR query).

Jan Høydahl <ja...@cominvent.com> schrieb am Mo., 25. Apr. 2016 um
16:04 Uhr:

> I think a workaround for your specific case could be to set mm=100% &
> q.op=OR (although it used to work for q.op=AND before)
>
> --
> Jan Høydahl, search solution architect
> Cominvent AS - www.cominvent.com
>
> > 25. apr. 2016 kl. 14.53 skrev Shawn Heisey <ap...@elyograg.org>:
> >
> > On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
> >> Remember:
> >> If I add the following line to the schema.xml, even if I do a search
> >> 'title:"test" OR author:"me"', it will returns documents matching
> >> 'title:"test" AND author:"me"':
> >> <solrQueryParser defaultOperator="AND"/>
> >
> > The settings in the schema for default field and default operator were
> > deprecated a long time ago.  I actually have no idea whether they are
> > even supported in newer Solr versions.
> >
> > The q.op parameter controls the default operator, and the df parameter
> > controls the default field.  These can be set in the request handler
> > definition in solrconfig.xml -- usually in "defaults" but there might be
> > reason to put them in "invariants" instead.
> >
> > If you're using edismax, you'd be better off using the mm parameter
> > rather than the q.op parameter.  The behavior you have described above
> > sounds like a change in behavior (some call it a bug) introduced in the
> > 5.5 version:
> >
> > https://issues.apache.org/jira/browse/SOLR-8812
> >
> > If you are using edismax, I suspect that if you set mm=100% instead of
> > q.op=AND (or the schema default operator) that the problem might go away
> > ... but I am not sure.  Someone who is more familiar with SOLR-8812
> > probably should comment.
> >
> > Thanks,
> > Shawn
> >
>
> --
*Georg M. Sorst I CTO*
FINDOLOGIC GmbH



Jakob-Haringer-Str. 5a | 5020 Salzburg I T.: +43 662 456708
E.: g.sorst@findologic.com
www.findologic.com Folgen Sie uns auf: XING
<https://www.xing.com/profile/Georg_Sorst>facebook
<https://www.facebook.com/Findologic> Twitter
<https://twitter.com/findologic>

Wir sehen uns auf dem *Shopware Community Day in Ahaus am 20.05.2016!* Hier
<beratung@findologic.com?subject=Terminvereinbarung%20SCD> Termin
vereinbaren!
Wir sehen uns auf der* dmexco in Köln am 14.09. und 15.09.2016!* Hier
<beratung@findologic.com?subject=Terminvereinbarung%20dmexco> Termin
vereinbaren!

Re: How can I set the defaultOperator to be AND?

Posted by Jan Høydahl <ja...@cominvent.com>.
I think a workaround for your specific case could be to set mm=100% & q.op=OR (although it used to work for q.op=AND before)

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 25. apr. 2016 kl. 14.53 skrev Shawn Heisey <ap...@elyograg.org>:
> 
> On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
>> Remember:
>> If I add the following line to the schema.xml, even if I do a search
>> 'title:"test" OR author:"me"', it will returns documents matching
>> 'title:"test" AND author:"me"':
>> <solrQueryParser defaultOperator="AND"/> 
> 
> The settings in the schema for default field and default operator were
> deprecated a long time ago.  I actually have no idea whether they are
> even supported in newer Solr versions.
> 
> The q.op parameter controls the default operator, and the df parameter
> controls the default field.  These can be set in the request handler
> definition in solrconfig.xml -- usually in "defaults" but there might be
> reason to put them in "invariants" instead.
> 
> If you're using edismax, you'd be better off using the mm parameter
> rather than the q.op parameter.  The behavior you have described above
> sounds like a change in behavior (some call it a bug) introduced in the
> 5.5 version:
> 
> https://issues.apache.org/jira/browse/SOLR-8812
> 
> If you are using edismax, I suspect that if you set mm=100% instead of
> q.op=AND (or the schema default operator) that the problem might go away
> ... but I am not sure.  Someone who is more familiar with SOLR-8812
> probably should comment.
> 
> Thanks,
> Shawn
> 


Re: How can I set the defaultOperator to be AND?

Posted by Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>.
Thank you Erick.
You're fully right that it can be an expected behavior to get more docs 
with more words...why not...

However, when I set the default OP to "AND" in solrconfig.xml, then a 
simple query "q=a OR b" doesn't work as expected... as described in the 
previous email:
-> a search 'title:"test" OR author:"me"' will returns documents 
matching 'title:"test" AND author:"me"'

Kind regards,
Bastien

On 27/04/2016 05:30, Erick Erickson wrote:
> Defaulting to "OR" has been the behavior since forever, so changing 
> the behavior now is just not going to happen. Making it fit a new 
> version of "correct" will change the behavior for every application 
> out there that has not specified the default behavior.
>
> There's no a-priori reason to expect "more words to equal fewer docs", 
> I can just as easily argue that "more words should return more docs". 
> Which you expect depends on your mental model.
>
> And providing the default op in your solrconfig.xml request handlers 
> allows you to implement whatever model your application chooses...
>
> Best,
> Erick
>
> On Mon, Apr 25, 2016 at 11:32 PM, Bastien Latard - MDPI AG 
> <latard@mdpi.com.invalid <ma...@mdpi.com.invalid>> wrote:
>
>     Thank you Shawn, Jan and Georg for your answers.
>
>     Yes, it seems that if I simply remove the defaultOperator it works
>     well for "composed queries" like '(a:x AND b:y) OR c:z'.
>     But I think that the default Operator should/could be the AND.
>
>     Because when I add an extra search word, I expect that the results
>     get more accurate...
>     (It seems to be what google is also doing now)
>        |    |
>
>     Otherwise, if you make a search and apply another filter (e.g.:
>     sort by publication date, facets, ...) , user can get the less
>     relevant item (only 1 word in 4 matches) in first position only
>     because of its date...
>
>     What do you think?
>
>
>     Kind regards,
>     Bastien
>
>
>     On 25/04/2016 14:53, Shawn Heisey wrote:
>>     On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
>>>     Remember:
>>>     If I add the following line to the schema.xml, even if I do a search
>>>     'title:"test" OR author:"me"', it will returns documents matching
>>>     'title:"test" AND author:"me"':
>>>     <solrQueryParser defaultOperator="AND"/>
>>     The settings in the schema for default field and default operator were
>>     deprecated a long time ago.  I actually have no idea whether they are
>>     even supported in newer Solr versions.
>>
>>     The q.op parameter controls the default operator, and the df parameter
>>     controls the default field.  These can be set in the request handler
>>     definition in solrconfig.xml -- usually in "defaults" but there might be
>>     reason to put them in "invariants" instead.
>>
>>     If you're using edismax, you'd be better off using the mm parameter
>>     rather than the q.op parameter.  The behavior you have described above
>>     sounds like a change in behavior (some call it a bug) introduced in the
>>     5.5 version:
>>
>>     https://issues.apache.org/jira/browse/SOLR-8812
>>
>>     If you are using edismax, I suspect that if you set mm=100% instead of
>>     q.op=AND (or the schema default operator) that the problem might go away
>>     ... but I am not sure.  Someone who is more familiar with SOLR-8812
>>     probably should comment.
>>
>>     Thanks,
>>     Shawn
>>
>>
>
>     Kind regards,
>     Bastien Latard
>     Web engineer
>     -- 
>     MDPI AG
>     Postfach, CH-4005 Basel, Switzerland
>     Office: Klybeckstrasse 64, CH-4057
>     Tel.+41 61 683 77 35 <tel:%2B41%2061%20683%2077%2035>Fax: +41 61 302
>     89 18 <tel:%2B41%2061%20302%2089%2018> E-mail: latard@mdpi.com
>     <ma...@mdpi.com> http://www.mdpi.com/
>
>

Kind regards,
Bastien Latard
Web engineer
-- 
MDPI AG
Postfach, CH-4005 Basel, Switzerland
Office: Klybeckstrasse 64, CH-4057
Tel. +41 61 683 77 35
Fax: +41 61 302 89 18
E-mail:
latard@mdpi.com
http://www.mdpi.com/


Re: How can I set the defaultOperator to be AND?

Posted by Erick Erickson <er...@gmail.com>.
Defaulting to "OR" has been the behavior since forever, so changing the
behavior now is just not going to happen. Making it fit a new version of
"correct" will change the behavior for every application out there that has
not specified the default behavior.

There's no a-priori reason to expect "more words to equal fewer docs", I
can just as easily argue that "more words should return more docs". Which
you expect depends on your mental model.

And providing the default op in your solrconfig.xml request handlers allows
you to implement whatever model your application chooses...

Best,
Erick

On Mon, Apr 25, 2016 at 11:32 PM, Bastien Latard - MDPI AG <
latard@mdpi.com.invalid> wrote:

> Thank you Shawn, Jan and Georg for your answers.
>
> Yes, it seems that if I simply remove the defaultOperator it works well
> for "composed queries" like '(a:x AND b:y) OR c:z'.
> But I think that the default Operator should/could be the AND.
>
> Because when I add an extra search word, I expect that the results get
> more accurate...
> (It seems to be what google is also doing now)
>    |       |
>
> Otherwise, if you make a search and apply another filter (e.g.: sort by
> publication date, facets, ...) , user can get the less relevant item (only
> 1 word in 4 matches) in first position only because of its date...
>
> What do you think?
>
>
> Kind regards,
> Bastien
>
>
> On 25/04/2016 14:53, Shawn Heisey wrote:
>
> On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
>
> Remember:
> If I add the following line to the schema.xml, even if I do a search
> 'title:"test" OR author:"me"', it will returns documents matching
> 'title:"test" AND author:"me"':
> <solrQueryParser defaultOperator="AND"/>
>
> The settings in the schema for default field and default operator were
> deprecated a long time ago.  I actually have no idea whether they are
> even supported in newer Solr versions.
>
> The q.op parameter controls the default operator, and the df parameter
> controls the default field.  These can be set in the request handler
> definition in solrconfig.xml -- usually in "defaults" but there might be
> reason to put them in "invariants" instead.
>
> If you're using edismax, you'd be better off using the mm parameter
> rather than the q.op parameter.  The behavior you have described above
> sounds like a change in behavior (some call it a bug) introduced in the
> 5.5 version:
> https://issues.apache.org/jira/browse/SOLR-8812
>
> If you are using edismax, I suspect that if you set mm=100% instead of
> q.op=AND (or the schema default operator) that the problem might go away
> ... but I am not sure.  Someone who is more familiar with SOLR-8812
> probably should comment.
>
> Thanks,
> Shawn
>
>
>
>
> Kind regards,
> Bastien Latard
> Web engineer
> --
> MDPI AG
> Postfach, CH-4005 Basel, Switzerland
> Office: Klybeckstrasse 64, CH-4057
> Tel. +41 61 683 77 35
> Fax: +41 61 302 89 18
> E-mail: latard@mdpi.comhttp://www.mdpi.com/
>
>

Re: How can I set the defaultOperator to be AND?

Posted by Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>.
Thank you Shawn, Jan and Georg for your answers.

Yes, it seems that if I simply remove the defaultOperator it works well 
for "composed queries" like '(a:x AND b:y) OR c:z'.
But I think that the default Operator should/could be the AND.

Because when I add an extra search word, I expect that the results get 
more accurate...
(It seems to be what google is also doing now)
    |    |

Otherwise, if you make a search and apply another filter (e.g.: sort by 
publication date, facets, ...) , user can get the less relevant item 
(only 1 word in 4 matches) in first position only because of its date...

What do you think?


Kind regards,
Bastien


On 25/04/2016 14:53, Shawn Heisey wrote:
> On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
>> Remember:
>> If I add the following line to the schema.xml, even if I do a search
>> 'title:"test" OR author:"me"', it will returns documents matching
>> 'title:"test" AND author:"me"':
>> <solrQueryParser defaultOperator="AND"/>
> The settings in the schema for default field and default operator were
> deprecated a long time ago.  I actually have no idea whether they are
> even supported in newer Solr versions.
>
> The q.op parameter controls the default operator, and the df parameter
> controls the default field.  These can be set in the request handler
> definition in solrconfig.xml -- usually in "defaults" but there might be
> reason to put them in "invariants" instead.
>
> If you're using edismax, you'd be better off using the mm parameter
> rather than the q.op parameter.  The behavior you have described above
> sounds like a change in behavior (some call it a bug) introduced in the
> 5.5 version:
>
> https://issues.apache.org/jira/browse/SOLR-8812
>
> If you are using edismax, I suspect that if you set mm=100% instead of
> q.op=AND (or the schema default operator) that the problem might go away
> ... but I am not sure.  Someone who is more familiar with SOLR-8812
> probably should comment.
>
> Thanks,
> Shawn
>
>

Kind regards,
Bastien Latard
Web engineer
-- 
MDPI AG
Postfach, CH-4005 Basel, Switzerland
Office: Klybeckstrasse 64, CH-4057
Tel. +41 61 683 77 35
Fax: +41 61 302 89 18
E-mail:
latard@mdpi.com
http://www.mdpi.com/


Re: How can I set the defaultOperator to be AND?

Posted by Shawn Heisey <ap...@elyograg.org>.
On 4/25/2016 6:39 AM, Bastien Latard - MDPI AG wrote:
> Remember:
> If I add the following line to the schema.xml, even if I do a search
> 'title:"test" OR author:"me"', it will returns documents matching
> 'title:"test" AND author:"me"':
> <solrQueryParser defaultOperator="AND"/> 

The settings in the schema for default field and default operator were
deprecated a long time ago.  I actually have no idea whether they are
even supported in newer Solr versions.

The q.op parameter controls the default operator, and the df parameter
controls the default field.  These can be set in the request handler
definition in solrconfig.xml -- usually in "defaults" but there might be
reason to put them in "invariants" instead.

If you're using edismax, you'd be better off using the mm parameter
rather than the q.op parameter.  The behavior you have described above
sounds like a change in behavior (some call it a bug) introduced in the
5.5 version:

https://issues.apache.org/jira/browse/SOLR-8812

If you are using edismax, I suspect that if you set mm=100% instead of
q.op=AND (or the schema default operator) that the problem might go away
... but I am not sure.  Someone who is more familiar with SOLR-8812
probably should comment.

Thanks,
Shawn


Re: How can I set the defaultOperator to be AND?

Posted by Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>.
Any news?

Remember:
If I add the following line to the schema.xml, even if I do a search 
'title:"test" OR author:"me"', it will returns documents matching 
'title:"test" AND author:"me"':
<solrQueryParser defaultOperator="AND"/>

kr,
Bast

On 22/04/2016 13:22, Bastien Latard - MDPI AG wrote:
> Yes Jan, I'm using edismax.
>
> This is (a part of) my requestHandler:
>
> <requestHandler name="/select" class="solr.SearchHandler">
>      <lst name="defaults">
>         <str name="indent">false</str>
>        <str name="echoParams">explicit</str>
>        <int name="rows">10</int>
>        <str name="df">title,abstract,authors,doi</str>
>        <str name="defType">edismax</str>
>        <str name="qf">title^1.0  author^1.0</str>
> [...]
>
> Is there anything I should do to improve/fix it?
>
> Kind regards,
> Bastien
>
> On 22/04/2016 12:42, Jan Høydahl wrote:
>> Hi
>>
>> Which query parser are you using? If using edismax yo may be hitting 
>> a recent bug concerning default operator and explicit boolean operators.
>>
>> -- 
>> Jan Høydahl, search solution architect
>> Cominvent AS - www.cominvent.com
>>
>>> 22. apr. 2016 kl. 11.26 skrev Bastien Latard - MDPI AG 
>>> <la...@mdpi.com.INVALID>:
>>>
>>> Hi guys,
>>>
>>> How can I set the defaultOperator to be AND?
>>> If I add the following line to the schema.xml, even if I do a search 
>>> 'title:"test" OR author:"me"', it will returns documents matching 
>>> 'title:"test" AND author:"me"':
>>> <solrQueryParser defaultOperator="AND"/>
>>>
>>> solr version: 6.0
>>>
>>> I know that I can overwrite the query with q.op, but this is not 
>>> that convenient...
>>> I would need to write a complex query for a simple search '(a:x AND 
>>> b:y) OR c:z'
>>>
>>> Kind regards,
>>> Bastien Latard
>>> Web engineer
>>> -- 
>>> MDPI AG
>>> Postfach, CH-4005 Basel, Switzerland
>>> Office: Klybeckstrasse 64, CH-4057
>>> Tel. +41 61 683 77 35
>>> Fax: +41 61 302 89 18
>>> E-mail:
>>> latard@mdpi.com
>>> http://www.mdpi.com/
>>>
>>
>
> Kind regards,
> Bastien Latard
> Web engineer

Kind regards,
Bastien Latard
Web engineer
-- 
MDPI AG
Postfach, CH-4005 Basel, Switzerland
Office: Klybeckstrasse 64, CH-4057
Tel. +41 61 683 77 35
Fax: +41 61 302 89 18
E-mail:
latard@mdpi.com
http://www.mdpi.com/


Re: How can I set the defaultOperator to be AND?

Posted by Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>.
Yes Jan, I'm using edismax.

This is (a part of) my requestHandler:

<requestHandler name="/select" class="solr.SearchHandler">
      <lst name="defaults">
         <str name="indent">false</str>
        <str name="echoParams">explicit</str>
        <int name="rows">10</int>
        <str name="df">title,abstract,authors,doi</str>
        <str name="defType">edismax</str>
        <str name="qf">title^1.0  author^1.0</str>
[...]

Is there anything I should do to improve/fix it?

Kind regards,
Bastien

On 22/04/2016 12:42, Jan Høydahl wrote:
> Hi
>
> Which query parser are you using? If using edismax yo may be hitting a recent bug concerning default operator and explicit boolean operators.
>
> --
> Jan Høydahl, search solution architect
> Cominvent AS - www.cominvent.com
>
>> 22. apr. 2016 kl. 11.26 skrev Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>:
>>
>> Hi guys,
>>
>> How can I set the defaultOperator to be AND?
>> If I add the following line to the schema.xml, even if I do a search 'title:"test" OR author:"me"', it will returns documents matching 'title:"test" AND author:"me"':
>> <solrQueryParser defaultOperator="AND"/>
>>
>> solr version: 6.0
>>
>> I know that I can overwrite the query with q.op, but this is not that convenient...
>> I would need to write a complex query for a simple search '(a:x AND b:y) OR c:z'
>>
>> Kind regards,
>> Bastien Latard
>> Web engineer
>> -- 
>> MDPI AG
>> Postfach, CH-4005 Basel, Switzerland
>> Office: Klybeckstrasse 64, CH-4057
>> Tel. +41 61 683 77 35
>> Fax: +41 61 302 89 18
>> E-mail:
>> latard@mdpi.com
>> http://www.mdpi.com/
>>
>

Kind regards,
Bastien Latard
Web engineer
-- 
MDPI AG
Postfach, CH-4005 Basel, Switzerland
Office: Klybeckstrasse 64, CH-4057
Tel. +41 61 683 77 35
Fax: +41 61 302 89 18
E-mail:
latard@mdpi.com
http://www.mdpi.com/


Re: How can I set the defaultOperator to be AND?

Posted by Jan Høydahl <ja...@cominvent.com>.
Hi

Which query parser are you using? If using edismax yo may be hitting a recent bug concerning default operator and explicit boolean operators.

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 22. apr. 2016 kl. 11.26 skrev Bastien Latard - MDPI AG <la...@mdpi.com.INVALID>:
> 
> Hi guys,
> 
> How can I set the defaultOperator to be AND?
> If I add the following line to the schema.xml, even if I do a search 'title:"test" OR author:"me"', it will returns documents matching 'title:"test" AND author:"me"':
> <solrQueryParser defaultOperator="AND"/>
> 
> solr version: 6.0
> 
> I know that I can overwrite the query with q.op, but this is not that convenient...
> I would need to write a complex query for a simple search '(a:x AND b:y) OR c:z'
> 
> Kind regards,
> Bastien Latard
> Web engineer
> -- 
> MDPI AG
> Postfach, CH-4005 Basel, Switzerland
> Office: Klybeckstrasse 64, CH-4057
> Tel. +41 61 683 77 35
> Fax: +41 61 302 89 18
> E-mail:
> latard@mdpi.com
> http://www.mdpi.com/
>