Reputation: 4232
Total novice when it comes to Lucene Query Syntax so need a bit of help!
Searching a database by email and using
email: <someone's email here>
in the URL as the search param.
How would one go about implementing this so it would only return the record with the exact email address?
So if I were to search
email: [email protected]
and the database contained a '[email protected]' and '[email protected]' only the latter would be returned?
I've had a look at http://www.lucenetutorial.com/lucene-query-syntax.html however the answer eludues me.
Any help would be much appreciated as always!
Upvotes: 1
Views: 122
Reputation: 174
This is analyzer's question.
If you want search the exact word, you should build the address field with Field.Index.NOT_ANALYZED
, then the address "[email protected]" will be analyze to "[email protected]".
The code like this:
Document doc = new Document();
doc.add(new Field("email", "[email protected]", Field.Store.YES, Field.Index.NOT_ANALYZED));
Upvotes: 1