更改动态弹性搜索同义词

问题描述:

可以在索引中存储elasticsearch的同义词吗?还是可以从couchdb这样的数据库中获取同义词列表?
我想通过REST-API动态添加同义词弹性搜索。

Is it possible to store the synonyms for elasticsearch in the index? Or is it possible to get the synonym list from a database like couchdb? I'd like to add synonyms dynamically to elasticsearch via the REST-API.

使用同义词时有两种方法:

There are two approaches when working with synonyms :


  • 在索引时扩展它们,

  • 在查询时展开它们。

在查询时间扩展同义词不被推荐,因为它引发了以下问题:

Expanding synonyms at query time is not recommended since it raises issues with :


  • 评分,因为同义词具有不同的文档频率, >
  • 多符号同义词,因为查询解析器分割在空格上。

a href =http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory =noreferrer> http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory (在Solr wiki上,但与ElasticSearch相关)。

More details on this at http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory (on Solr wiki, but relevant for ElasticSearch too).

所以推荐的方法是在索引时扩展同义词。在您的情况下,如果同义词列表是动态管理的,则意味着您应重新索引每个包含其同义词列表已被更新的术语的文档,以便在前后更新分析的文档之间保持一致。我不是说这是不可能的,但它需要一些工作,并可能会提高性能问题的同义词在你的索引频率很高。

So the recommended approach is to expand synonyms at indexing time. In your case, if the synonym list is managed dynamically, it means that you should re-index every document which contains a term whose synonym list has been updated so that scoring remains consistent between documents analyzed pre and post update. I'm not saying that it is not possible but it requires some work and will probably raise performance issues with synonyms which have a high frequency in your index.