Lucene.Net - How to treat a space-seperated phrase as a single token?

Posted by Gareth D on Stack Overflow See other posts from Stack Overflow or by Gareth D
Published on 2011-01-14T10:16:53Z Indexed on 2011/01/14 10:53 UTC
Read the original article Hit count: 161

Filed under:
|
|
|

I've implemented a search facility using Lucene.Net. The index includes UK academic qualifications, including "A Level".

I'd like the users to be able to search using the phrase "A Level", but using the Standrad Analyser the "A" is stripped out as a stop-word and therefore only "Level" is indexed/searched.

What's my best option to work around this? I'm guessing I need to somehow tokenise "A Level" to "A-Level" or similar by creating a custom analyser.

Is this the best approach?

Note that I want don't want the whole search to be a phrase query. i.e. in my search box I want the user to be able to enter <"A Level" AND English Maths Physics> and this would return any with "A Level" and either of English MAths or Physics. Question updated to reflect this.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET