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"?

有帮助吗?

解决方案

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top