Question

I want to the exact results for my query.

For e.g. when I search "New york" , then it doesn't give me exact results about New York But it also gives me results like:

"New York"

"New Delhi"

And other cities starting from "New"

So how can I get only results for "New York"?

Was it helpful?

Solution

Phrase query should do the job. Just put quotes around your query terms.

OTHER TIPS

From your question What i Understand is you want "New York" to be consider as single token ,you can do that by modifying tokenizer for field Change Tokenizer from StandardTokenizerFactory to KeywordTokenizerFactory reindex data and query again

Depending on exactly what you expect to get as search results, Stupid Lucene Tricks: Exact Match, Starts With, Ends With might also be worth a look.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top