Gribouille
Gribouille

Reputation: 122

Precise expression or word solr match

I am looking for way to match a very specific expression or word in my solr collection. Here is an example : I want the query to return me : "Paris" And not : "Paris is great" And not : "I like Paris"

Thanks :)

Upvotes: 0

Views: 60

Answers (2)

Oyeme
Oyeme

Reputation: 11225

You need to use KeywordTokenizer

This tokenizer treats the entire text field as a single token

https://lucene.apache.org/solr/guide/6_6/tokenizers.html#Tokenizers-KeywordTokenizer

Upvotes: 0

MatsLindh
MatsLindh

Reputation: 52792

If you only want exact matches, make sure the field type is defined as string. A string field will not do any tokenization or use any filters, and will only generate hits when the query is exactly the same as the value indexed.

Upvotes: 1

Related Questions