Solr的synonym.txt添加到Elasticsearch。

huangapple go评论73阅读模式
英文:

Solr synonym.txt adding at elasticsearch

问题

我已经在solr中有一个工作正常的synonym.txt文件。现在我想将相同的txt文件添加到elasticsearch中。我该怎么做呢?在solr中很简单,我只需将该文件放在系统中即可。在elasticsearch中,我添加了这个文件,并且运行了一些命令,但是它没有起作用。

PUT /test_index
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym": {
            "tokenizer": "whitespace",
            "filter": ["synonym"]
          }
        },
        "filter": {
          "synonym": {
            "type": "synonym",
            "synonyms_path": "analysis/synonym.txt"
          }
        }
      }
    }
  }
}

出了什么问题?我需要重新索引吗,还是需要将其与任何字段映射?我的搜索结果依赖于多个字段。

英文:

I have already a working synonym.txt in solr. Now I want to add that same txt file at elasticsearch. What can I do for it? At solr it was easy, I just kept that file in the system. At elasticsearch I added this and also run some command, but it is not working.

PUT /test_index
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym": {
            "tokenizer": "whitespace",
            "filter": [ "synonym" ]
          }
        },
        "filter": {
          "synonym": {
            "type": "synonym",
            "synonyms_path": "analysis/synonym.txt"
          }
        }
      }
    }
  }
}

What's wrong? Do I need to index it again or do I need to map this with any field? My search result depends on multiple fields.

答案1

得分: 1

希望您已经在现有的ES映射中应用了您的 synonym,您刚刚提供了您的索引设置,您需要提供索引映射来确认它。

此外,为现有字段添加分析器是一个破坏性的更改,您必须重新索引数据,以查看更新后的标记。

您必须使用Analyze API来查看索引上的更新后标记,还请核对一下您是否正确添加了 synonym.txt,并且在使用这个文件创建索引设置时是否没有出现错误。

英文:

Hope you have applied your synonym on your existing fields in your ES mapping, you have just provided your index setting, and you need to provide the index mapping to confirm it.

Also adding an analyzer to the existing field is a breaking change and you have to reindex the data again to see the updated tokens.

You must use Analyze API to see the updated tokens on your index, Also please cross-check if you have added the synonym.txt properly and there was no error while creating the index setting with this file.

huangapple
  • 本文由 发表于 2020年10月15日 13:27:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/64365364.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定