如何在现有索引中更改elasticsearch中的tokenizer

时间:2013-08-14 11:20:53

标签: indexing tokenize

我有以下问题: 我有一个3000万个文档的索引,映射如下:

curl -XPUT localhost:8080/xxxxx/yyyyy/_mapping?pretty=true -d '{"xxxxx":{"_id":{"type":"string","index":"not_analyzed"},"properties":{"content":
{"type":"string","store":"no"},"title":{"type":"string","index":"no"},"created_date":{"type":"integer","index":"not_analyzed"},"url":
{"type":"string","index":"not_analyzed"},"author":{"type":"string","index":"no"},"author_url":{"type":"string","index":"no"},"domain":
{"type":"string","index":"not_analyzed"},"lang":{"type":"string","index":"no"}}}}'

未在设置中选择Tokenizer,因此请应用标准。 我想请求“facets”在字段“content”中创建排名链接(url)。不幸的是我无法做到这一点,因为标准的tokenizer会将链接(url)分享到碎片。 题: 没有重新索引的现有索引是否可以更改标记生成器,以便添加到索引的新文档处理新的标记生成器(uax_url_email),旧文档保持不变。

我试过了:

curl -XPUT localhost:8080/xxxxx -d '{
  "settings" : {
    "index": {
      "analysis" :{
        "analyzer": {
          "default": {
            "type" : "custom",
            "tokenizer" : "uax_url_email",
            "filter" : "lowercase"
          }
        }
      }
    }
  }
}
'

但是我收到一个错误: {"error": "IndexAlreadyExistsException [[xxxxx] Already exists]", "status": 400}

有没有其他方法可以不使用查询“facets”重新索引来创建排名链接(网址)?

提前感谢您的任何帮助

1 个答案:

答案 0 :(得分:1)

对于现有索引“xxxxx”

,请尝试下一步
curl -XPUT localhost:8080/xxxxx/_settings -d '{
      "analysis" :{
        "analyzer": {
          "default": {
            "type" : "custom",
            "tokenizer" : "uax_url_email",
            "filter" : "lowercase"
          }
        }
      }
}

确保您的elasticsearch端口为8080,默认为9200