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 Spyros Kapnissis <sk...@yahoo.com> on 2011/07/02 01:50:20 UTC

Match only documents which contain all query terms

Hello to all,


Is it possible that I can make solr return only documents that contain all or most of my query terms for a specific field? Or will I need some post-processing on the results?

So, for example, if I search for (a b c), I would like the following documents returned:

a b c
a' c b (where a' is a stem for example)

but not 
x y a b c z

Thanks,
Spyros

Re: Match only documents which contain all query terms

Posted by Michael Sokolov <so...@ifactory.com>.
I believe you should be able to get results ordered so that the 
documents you want will always come first, so you can truncate the 
results efficiently on the client side.

You could also try a regexp query (untested):

a b c -/~(a|b|c)/

-Mike

On 7/1/2011 7:50 PM, Spyros Kapnissis wrote:
> Hello to all,
>
>
> Is it possible that I can make solr return only documents that contain all or most of my query terms for a specific field? Or will I need some post-processing on the results?
>
> So, for example, if I search for (a b c), I would like the following documents returned:
>
> a b c
> a' c b (where a' is a stem for example)
>
> but not 
> x y a b c z
>
> Thanks,
> Spyros