How can I use Lucene for personal name (first name, last name) search?

Posted by os111 on Stack Overflow See other posts from Stack Overflow or by os111
Published on 2010-05-07T18:44:49Z Indexed on 2010/05/07 18:48 UTC
Read the original article Hit count: 365

Filed under:

I'm writing a search feature for a database of NFL players.

The user enters a search string like "Jason Campbell" or "Campbell" or "Jason".

I'm having trouble getting the appropriate results.

Which Analyzer should I use when indexing? Which Query when querying? Should I distinguish between first name and last name or just index the full name string?

I'd like the following behavior:

Query: "Jason Campbell" -> Result: exact match for 1 player, Jason Campbell

Query: "Campbell" -> Result: all players with Campbell in their name

Query: "Jason" -> Result: all players with Jason in their name

Query: "Cambel" [misspelled] -> Result: all players with Campbell in their name

© Stack Overflow or respective owner

Related posts about lucene