1

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!

1 Answer 1

1

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));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.