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 Alex Grilo <al...@umamao.com> on 2011/05/17 15:51:19 UTC

Exact match

Hi,

Can I make a query that returns only exact match or do I have to change the
fields to achieve that?

Thanks in advance

Alex Grilo

Re: Exact match

Posted by Anuj Kumar <an...@gmail.com>.
Hi Alex,

You need to define that field of type String in the schema and then search
for it. That will give you an exact match.

Regards,
Anuj

On Tue, May 17, 2011 at 7:21 PM, Alex Grilo <al...@umamao.com> wrote:

> Hi,
>
> Can I make a query that returns only exact match or do I have to change the
> fields to achieve that?
>
> Thanks in advance
>
> Alex Grilo
>

Re: Exact match

Posted by Jan Høydahl <ja...@cominvent.com>.
There's a JIRA issue assigned to this feature: https://issues.apache.org/jira/browse/SOLR-1980
However, it's not yet implemented. Anyone?

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

On 17. mai 2011, at 15.51, Alex Grilo wrote:

> Hi,
> 
> Can I make a query that returns only exact match or do I have to change the
> fields to achieve that?
> 
> Thanks in advance
> 
> Alex Grilo


Re: Exact match

Posted by Jonathan Rochkind <ro...@jhu.edu>.
You've got to change the fields to do it.

If you use a String field, then only exact matches will match, but 
they'll be REALLY exact matches -- spacing, punctuation, etc.

Also, if you are using the lucene or dismax query parsers, you'll need 
to phrase quote your query if it has any spaces in it, to avoid query 
parser pre-tokenization.  (I call it 'pre-tokenization', not sure what 
Solr calls it).

So you could use a textfield with the keyword tokenizer (does not split 
on word boundaries), and apply some punctuation/spacing normalization, 
to make your match a little bit less 'exact' if desired. You'd still 
need to issue your query as phrase quoted if it contains any spaces, to 
the lucene or dismax query parsers. Or use a different query parser, 
like "field" or "raw" or that new one I can't remember the name of.

Another idea I've had for exact matching, but haven't tried out myself 
yet:  Use a text/analyzed field, WITH tokenization, but manually add a 
token such as "THE_START" to the start of the field before indexing, and 
"THE_END" to the end of the field before indexing. Then when you do a 
query, phrase quote it AND manually add those tokens before issuing the 
query. So if the user entered "quick brown fix", you'd actually send a 
search for (phrase quoted) "THE_START quick brown fox THE_END".  That 
would hypothetically be another way of getting an 'exact' match (with 
whatever normalization the field's analysis does), in a field that could 
also be used for 'ordinary' searching.  Haven't tried it myself yet.  
Those extra tokens might (or might not) alter Solr's relevancy scores 
somewhat.

Jonathan

On 5/17/2011 9:51 AM, Alex Grilo wrote:
> Hi,
>
> Can I make a query that returns only exact match or do I have to change the
> fields to achieve that?
>
> Thanks in advance
>
> Alex Grilo
>

Re: Exact match

Posted by roySolr <ro...@gmail.com>.
Try this: "search term"

--
View this message in context: http://lucene.472066.n3.nabble.com/Exact-match-tp2952591p2952699.html
Sent from the Solr - User mailing list archive at Nabble.com.