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 Thierry Collogne <th...@gmail.com> on 2007/03/27 15:01:51 UTC

How to make the search default use AND instead of OR?

Hello,

I have a small question.When I do a search and enter 2 words, seperated with
a space (for example small business), the query is done like small OR
business.

So I get results containing small, business or small and business. In our
case I would like only the results that contain small AND business

Can I configure this somewhere, or do I need to parse the searchquery and
add the AND keyword myself?

Thank you.

Re: How to make the search default use AND instead of OR?

Posted by Thierry Collogne <th...@gmail.com>.
Thanks. Apparently I overlooked it.

On 27/03/07, thomas arni <ar...@zhwin.ch> wrote:
>
> You can configure that in the "schema.xml" file:
>
> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
> <solrQueryParser defaultOperator="AND"/>
>
>
> Thierry Collogne wrote:
> > Hello,
> >
> > I have a small question.When I do a search and enter 2 words,
> > seperated with
> > a space (for example small business), the query is done like small OR
> > business.
> >
> > So I get results containing small, business or small and business. In
> our
> > case I would like only the results that contain small AND business
> >
> > Can I configure this somewhere, or do I need to parse the searchquery
> and
> > add the AND keyword myself?
> >
> > Thank you.
> >
>
>

Re: How to make the search default use AND instead of OR?

Posted by thomas arni <ar...@zhwin.ch>.
You can configure that in the "schema.xml" file:

 <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
 <solrQueryParser defaultOperator="AND"/>


Thierry Collogne wrote:
> Hello,
>
> I have a small question.When I do a search and enter 2 words, 
> seperated with
> a space (for example small business), the query is done like small OR
> business.
>
> So I get results containing small, business or small and business. In our
> case I would like only the results that contain small AND business
>
> Can I configure this somewhere, or do I need to parse the searchquery and
> add the AND keyword myself?
>
> Thank you.
>


Re: How to make the search default use AND instead of OR?

Posted by Mike Klaas <mi...@gmail.com>.
On 3/27/07, Chris Hostetter <ho...@fucit.org> wrote:

> if you want strict "AND" style matching with dismax, just use "100%" for
> mm.
>
> MinShouldMatch is one of the few things about DisMax that is extremely
> well documented...
>
> http://lucene.apache.org/solr/api/org/apache/solr/util/doc-files/min-should-match.html

Indeed it is, though I wasn't aware of the detailed documentation.
Not that it that hard to find, but it is three links away from the
main dismax page on the wiki.  I might add a link directly from the
main dismax javadoc to help people like me find it,

-Mike

Re: How to make the search default use AND instead of OR?

Posted by Chris Hostetter <ho...@fucit.org>.
: A more nuanced answer would be to finesse the MM parameter so shorter
: multi-word queries behave as AND, and longer queries allow more
: flexibility (this could probably be achieved by using a  high
: percentage setting, but I'd have to double check how the rounding is
: done).

you are correct, something like "5<90%" will say that in a query of up to
5 clauses, they are all required, but once you have 6 clauses, only 90%
rounded down are required ... if you want the 90% to be "round up" use
"3<-10%" (the percentages are allways "rounded down" but if it's negative,
it's rounded down before the subtraction happens, so -10% is like rounding
up 90%)

if you want strict "AND" style matching with dismax, just use "100%" for
mm.

MinShouldMatch is one of the few things about DisMax that is extremely
well documented...

http://lucene.apache.org/solr/api/org/apache/solr/util/doc-files/min-should-match.html


-Hoss


Re: How to make the search default use AND instead of OR?

Posted by Chris Hostetter <ho...@fucit.org>.
: I disabled MM. It was giving me too many no-hits on real
: user queries. I think it makes the engine somewhat mysterious
: to users.

if you have some examples you can share i'd love to hear about them ... it
seemed like a good idea when i wrote it, and it seems to work well in the
instances where i've done serious investigation, but i also have it
configured fairly high so that it only comes into play when people
cut/past really long product names into hte search box from other sources
and we want to match even if part of their product name isn't in our
version of the product's name.

-Hoss


Re: How to make the search default use AND instead of OR?

Posted by Walter Underwood <wu...@netflix.com>.
On 3/27/07 10:57 AM, "Mike Klaas" <mi...@gmail.com> wrote:

> I agree with your point above, but I fear "AND: bad! OR: good!"
> becoming dogma--often AND+spellcheck is the better option.

AND-with-spell-suggestion is better, but the spelling suggestion
needs to be really, really good. That is really hard, while
setting "OR" is really easy.

Google uses AND, but they have way more data (and engineers)
for building good spelling suggestions, and they have a desperate
need to cut down the number of servers involved in a query.
The AND default probably saves them thousands of servers.

> A more nuanced answer would be to finesse the MM parameter so shorter
> multi-word queries behave as AND, and longer queries allow more
> flexibility (this could probably be achieved by using a  high
> percentage setting, but I'd have to double check how the rounding is
> done).

I disabled MM. It was giving me too many no-hits on real
user queries. I think it makes the engine somewhat mysterious
to users.

wunder


Re: How to make the search default use AND instead of OR?

Posted by Mike Klaas <mi...@gmail.com>.
On 3/27/07, Walter Underwood <wu...@netflix.com> wrote:
> I don't recommend defaulting to AND. This will increase the number
> of failed searches (no hits) for your users. If one word is misspelled
> in a multi-word AND query, you'll get no results. Since About 10% of
> queries are misspelled and about half of queries are multi-word, that
> will immediately increase your failed queries by five percentage points.

The filtering benefits of AND shouldn't be underestimated.  Dismax
helps (a lot) but it sufficient to guarantee that matches containing
both terms appear first.

I agree with your point above, but I fear "AND: bad! OR: good!"
becoming dogma--often AND+spellcheck is the better option.

A more nuanced answer would be to finesse the MM parameter so shorter
multi-word queries behave as AND, and longer queries allow more
flexibility (this could probably be achieved by using a  high
percentage setting, but I'd have to double check how the rounding is
done).

-Mike

Re: How to make the search default use AND instead of OR?

Posted by Walter Underwood <wu...@netflix.com>.
I don't recommend defaulting to AND. This will increase the number
of failed searches (no hits) for your users. If one word is misspelled
in a multi-word AND query, you'll get no results. Since About 10% of
queries are misspelled and about half of queries are multi-word, that
will immediately increase your failed queries by five percentage points.

wunder


On 3/27/07 6:01 AM, "Thierry Collogne" <th...@gmail.com> wrote:

> Hello,
> 
> I have a small question.When I do a search and enter 2 words, seperated with
> a space (for example small business), the query is done like small OR
> business.
> 
> So I get results containing small, business or small and business. In our
> case I would like only the results that contain small AND business
> 
> Can I configure this somewhere, or do I need to parse the searchquery and
> add the AND keyword myself?
> 
> Thank you.