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 Jörg Kiegeland <ki...@ikv.de> on 2008/01/31 14:53:19 UTC

exact matches not possible?

Normally I do substring-queries on my field named X. Now however I also 
require exact-match queries, however I do not know how to do this!

If I do

X:"blabla"

or

X:blabla


.. all documents containing "blabla" in field X are returned. However 
these are much too much, since I know there is exactly one  document 
matching "blabla" on field X exactly.
One solution would be to filter the search result for exact-matches on 
client side - however can I shift this filtering to Solr somehow?

Re: exact matches not possible?

Posted by Yonik Seeley <yo...@apache.org>.
On Jan 31, 2008 10:26 AM, Jörg Kiegeland <ki...@ikv.de> wrote:
> > I guess you can try specifying your search as a filter query e.g.
> > q=blabla&fq=X:"blabla", which will give back only the exact match.
> >
> I tried this syntax in may Firefox URL field, however seems not to help.
> How do I specify a filter query with Solrj (i.e. using SolrQuery)?

You could index special start and end tokens before and after the
field value, and then use those values in a phrase query.

So index something like _start_ blabla _end_
and then search for "_start_ blabla _end_"

Re: exact matches not possible?

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
Sorry, this method will not work with tokenized fields I guess. Andy's
approach is the standard in this case, however Yonik's method should also
work.

As for specifying filter queries with SolrJ, use
SolrQuery.addFilterQuery(String
filterQuery) to specify filter queries in code.

On Jan 31, 2008 8:56 PM, Jörg Kiegeland <ki...@ikv.de> wrote:

>
> > I guess you can try specifying your search as a filter query e.g.
> > q=blabla&fq=X:"blabla", which will give back only the exact match.
> >
> I tried this syntax in may Firefox URL field, however seems not to help.
> How do I specify a filter query with Solrj (i.e. using SolrQuery)?
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: exact matches not possible?

Posted by Jörg Kiegeland <ki...@ikv.de>.
> I guess you can try specifying your search as a filter query e.g.
> q=blabla&fq=X:"blabla", which will give back only the exact match.
>   
I tried this syntax in may Firefox URL field, however seems not to help.
How do I specify a filter query with Solrj (i.e. using SolrQuery)?

Re: exact matches not possible?

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
I guess you can try specifying your search as a filter query e.g.
q=blabla&fq=X:"blabla", which will give back only the exact match.

On Jan 31, 2008 7:23 PM, Jörg Kiegeland <ki...@ikv.de> wrote:

> Normally I do substring-queries on my field named X. Now however I also
> require exact-match queries, however I do not know how to do this!
>
> If I do
>
> X:"blabla"
>
> or
>
> X:blabla
>
>
> .. all documents containing "blabla" in field X are returned. However
> these are much too much, since I know there is exactly one  document
> matching "blabla" on field X exactly.
> One solution would be to filter the search result for exact-matches on
> client side - however can I shift this filtering to Solr somehow?
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: exact matches not possible?

Posted by Andy Blower <an...@proquest.co.uk>.
Disclaimer: I've only been working (evaluating) Solr for three weeks.

I had exactly this issue, and I found that using a field of type string gave
exact matches. So, if you need to do both substring and exact match queries,
you'll need two fields. One non-tokenized field using class StrField and one
tokenized field using class TextField. Very easy to feed into both using
copyField.

Your query would need to use the different field name instead of an exact
operator like with some commercial search engines.

hope that helps,

Andy


Jörg Kiegeland wrote:
> 
> Normally I do substring-queries on my field named X. Now however I also 
> require exact-match queries, however I do not know how to do this!
> 
> If I do
> 
> X:"blabla"
> 
> or
> 
> X:blabla
> 
> 
> .. all documents containing "blabla" in field X are returned. However 
> these are much too much, since I know there is exactly one  document 
> matching "blabla" on field X exactly.
> One solution would be to filter the search result for exact-matches on 
> client side - however can I shift this filtering to Solr somehow?
> 
> 

-- 
View this message in context: http://www.nabble.com/exact-matches-not--possible--tp15205318p15206164.html
Sent from the Solr - User mailing list archive at Nabble.com.