.net – City name query

lucenelucene.net

Am a newbie to Lucene an working on a city search API using Lucene.
If user types in san francisco as search input, then it should give cities with exact match only and not San Jose /San Diego,etc.

How should i index city names in Lucene?and which Lucene analyzer and query class do i need to use?

Best Answer

Index your content with StandardAnalyzer. And then use PhraseQuery to search. For this, simply use the query string as "san francisco" with double quotes.