简体   繁体   English

用等效词查询Elasticsearch

[英]Elasticsearch query by equivalent words

I have an ES index where I store companies indexed by name. 我有一个ES索引,用于存储按名称索引的公司。 Is there any way so I can search by similar words ? 有什么办法可以搜索相似的单词吗?

For example I have the name "Discount Pets & Supplies" and I want to also be able to query like "Discount Pets and Supplies", so basically I'm asking if there is a way to mark "&" as equivalent to "and". 例如,我的名字是“ Discount Pets&Supplies”,我还希望能够像“ Discount Pets&Supplies”一样进行查询,所以基本上我想问是否有一种方法可以将“&”标记为等于“ and ”。

Thank you, Teodor 谢谢Teodor

Yes, during the analysis phase when you are indexing documents you can define synonyms using a Synonym Token Filter: 是的,在分析阶段,当您为文档建立索引时,可以使用“同义词标记过滤器”来定义同义词:

Synonym Token Filter 同义词令牌过滤器

The synonym token filter allows to easily handle synonyms during the analysis process. 同义词标记过滤器可以在分析过程中轻松处理同义词。 Synonyms are configured using a configuration file. 使用配置文件配置同义词。

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html

In your specific case, however, you will need to be careful about what other analysis is being done as the & symbol may get stripped out. 但是,在您的特定情况下,由于&符号可能会被剥离,因此您需要注意正在执行的其他分析。

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

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