栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Elasticsearch-将字段从not_analyzed更改为分析

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Elasticsearch-将字段从not_analyzed更改为分析

不能修改现有字段,但是,您可以创建其他字段或子字段添加到您的

not_analyzed
领域。

我要使用后一种解决方案。因此,首先,将一个新的子字段添加到您现有的字段中,如下所示:

curl -XPUT localhost:9200/index/_mapping/type -d '{    "properties": {        "your_field": { "type": "string", "index": "not_analyzed", "fields": {     "sub": {         "type": "string"     } }        }    }}'

上面,我们已经添加了子场称为

your_field.sub
(被分析)现有的
your_field
(这是
not_analyzed

接下来,我们需要填充该新子字段。如果您运行的是最新的ES 2.3,则可以使用功能强大的Reindex
API

curl -XPUT localhost:9200/_reindex -d '{  "source": {    "index": "index"  },  "dest": {    "index": "index"  },  "script": {    "inline": "ctx._source.your_field = ctx._source.your_field"  }}'

否则,您可以简单地使用以下Logstash配置,该配置将为您的数据重新索引以便填充新的子字段

input {  elasticsearch {   hosts => "localhost:9200"   index => "index"   docinfo => true  }}filter { mutate {  remove_field => [ "@version", "@timestamp" ] }}output { elasticsearch {   hosts => ["localhost:9200"]   manage_template => false   index => "%{[@metadata][_index]}"   document_type => "%{[@metadata][_type]}"   document_id => "%{[@metadata][_id]}" }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/403676.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号