简体   繁体   English

在Lucene中搜索确切的短语

[英]Searching exact phrase in Lucene

I have a single table of 10 GB in MySQL. 我在MySQL中有一个10 GB的表。 The table consists of data about the suppliers, products and contracts. 该表包含有关供应商,产品和合同的数据。 I am indexing the data using Lucene and to make the search faster. 我正在使用Lucene索引数据,并使搜索更快。 I have many conditions on which I filter my data like Supplier name, product name or contract Number or combination of any two. 我有很多条件可以过滤我的数据,例如供应商名称,产品名称或合同编号或任意两个的组合。

The issue is Example: When I am searching for Products by entering the supplier name. 问题是示例:当我通过输入供应商名称搜索产品时。 Let the supplier name be "Company of Clothes". 让供应商名称为“服装公司”。 What I am getting is a list of products supplied by "Company of Clothes", "Company of Shoes","Company of bags" and not only the products supplied by the "Company of Clothes". 我得到的是“服装公司”,“鞋公司”,“箱包公司”提供的产品清单,而不仅仅是“服装公司”提供的产品清单。 How can I make Lucene search for only the exact word/phrase I entered. 我如何才能让Lucene仅搜索输入的确切单词/短语。

I assume you are using the QueryParser to construct your queries. 我假设您正在使用QueryParser构造查询。 You may find it helpful to give a read to the query syntax documentation . 您可能会发现阅读查询语法文档很有帮助。


You can use a phrase query, by surrounding your query with double quotes: 您可以在词组查询中用双引号引起来:

"Company of Clothes"

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

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