njain
njain

Reputation: 33

Match an exact phrase in Solr

I have indexed data in solr. I have many phrases such as 'The Dark Knight' and 'The Dark Knight Rises'. When I query for 'The Dark Knight', I get both the results, I want match this query with only 'The Dark Knight' and not the 'The Dark Knight Rises', is it possible to this

Upvotes: 2

Views: 1311

Answers (2)

Hafiz Muhammad Shafiq
Hafiz Muhammad Shafiq

Reputation: 8678

Yes, it is possible as discussed by "Hector Correa". Following should be the way to update schema for exact search.

<field name="exact_field" type="string" indexed="true" stored="true"/>

I have used this case for dictionary implementation where exact word is searched. "string" field type is the solution.

Upvotes: 1

Hector Correa
Hector Correa

Reputation: 26690

If you want exact matches you could use a String field in Solr. I suspect the field that you are searching on is a Text field.

Be aware that on String fields the search will only succeed if the values are identical (including case, punctuation, spaces).

You can use the Analysis Screen to see how matches will be made for these two different kind of field types.

Upvotes: 1

Related Questions