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

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Thierry Collogne
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.
Reply | Threaded
Open this post in threaded view
|

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

thomas arni
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.
>

Reply | Threaded
Open this post in threaded view
|

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

Thierry Collogne
Thanks. Apparently I overlooked it.

On 27/03/07, thomas arni <[hidden email]> 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.
> >
>
>
Reply | Threaded
Open this post in threaded view
|

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

Walter Underwood, Netflix
In reply to this post by Thierry Collogne
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" <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

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

Mike Klaas
On 3/27/07, Walter Underwood <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

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

Walter Underwood, Netflix
On 3/27/07 10:57 AM, "Mike Klaas" <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

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

Chris Hostetter-3
In reply to this post by Mike Klaas

: 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

Reply | Threaded
Open this post in threaded view
|

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

Chris Hostetter-3
In reply to this post by Walter Underwood, Netflix

: 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

Reply | Threaded
Open this post in threaded view
|

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

Mike Klaas
In reply to this post by Chris Hostetter-3
On 3/27/07, Chris Hostetter <[hidden email]> 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