简体   繁体   English

Lucene查询语法搜索

[英]Lucene Query Syntax Search

Total novice when it comes to Lucene Query Syntax so need a bit of help! 关于Lucene查询语法的新手知识,所以需要一些帮助!

Searching a database by email and using 通过电子邮件搜索数据库并使用

email: <someone's email here>

in the URL as the search param. 在URL中作为搜索参数。

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: test@gmail.com

and the database contained a 'test@email.com' and 'test@gmail.com' only the latter would be returned? 并且数据库包含“ test@email.com”和“ test@gmail.com”,只有后者会被返回?

I've had a look at http://www.lucenetutorial.com/lucene-query-syntax.html however the answer eludues me. 我已经看过http://www.lucenetutorial.com/lucene-query-syntax.html,但是答案不值一提。

Any help would be much appreciated as always! 一如既往,任何帮助将不胜感激!

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 "test@email.com" will be analyze to "test@email.com". 如果要搜索确切的单词,则应使用Field.Index.NOT_ANALYZED构建地址字段,然后将地址“ test@email.com”分析为“ test@email.com”。

The code like this: 像这样的代码:

Document doc = new Document();
doc.add(new Field("email", "test@email.com", Field.Store.YES, Field.Index.NOT_ANALYZED));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM