Pergunta

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

Foi útil?

Solução

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top