问题
在处理elasticsearch的时候,通常需要不断地调整索引的配置,以期达到期望的效果。最近在试验各种analyzer的效果的时候就碰到一个问题:修改索引配置后,并不能立即生效。后来才发现需要先关闭索引,然后再打开才能生效。
过程
下面是我的过程:
创建索引:
curl -XPUT http://localhost:9200/analyzetest/ -d ' { "settings":{ "analysis":{ "analyzer":{ "testpatternanalyzer":{ "type":"pattern", "pattern":"\\s+" } } } } } '
测试分析器效果:
curl -Xpost http://localhost:9200/analyzetest/_analyze?analyzer=testpatternanalyzer -d ' hello elasticsearch '
效果达成,试验一个自定义的分析器,该分析器采用nGram的tokenizer:
更新索引配置:
curl -XPUT http://localhost:9200/analyzetest/_settings -d ' { "analysis":{ "analyzer":{ "acompoundenglish":{ "type":"custom", "tokenizer":"my_ngram_tokenizer", "filter":[ "my_ngram_filter" ] } }, "tokenizer":{ "my_ngram_tokenizer":{ "type":"nGram", "min_gram":1, "max_gram":3 } }, "filter":{ "my_ngram_filter":{ "type":"nGram", "min_gram":1, "max_gram":3 } } } } '
返回:
{ "ok": true }
测试效果:
curl -Xpost http://localhost:9200/analyzetest/_analyze?analyzer=compoundenglish -d ' english '
结果返回的token只有一个:“english”。这明显不是nGram应该达到的效果。反复试验过几次均不见效果。
通过
curl -Xget http://localhost:9200/analyzetest/_settings
发现第二次设置的索引配置根本没有出现。可是更新配置的时候明名返回成功的。
原来(https://groups.google.com/forum/#!msg/elasticsearch/dVPq9GAh8-g/Gs3Lg7Zjt1QJ)需要先关闭索引后才能生效:
kimchy 写道
It might just be the number of replicas setting, where it should handle things better in case of a closed index. All other settings should work. Open an issue for the number of replica settings update problem on a closed index.
通过
curl -XPOST http://localhost:9200/analyzetest/_close curl -XPOST http://localhost:9200/analyzetest/_open
发现更新过的配置生效了,分析器也返回了期望的效果。
相关推荐
对elasticsearch的索引做了一个简单的介绍,可以作为项目培训的课件使用
elasticsearch索引流程,以前的笔记,希望有用
elasticsearch索引安装后所需的网页插件,plugin-head插件,安装下载即可
lasticsearch整合分词、创建索引、搜索例子,elasticsearch版本为1.0,索引数据从数据表中动态读取生成,有关键字高亮效果,查询分页 1 在dababase目录中导致相关的数据库文件,修改DBCOperation java文件数据库连接...
Elasticsearch7.0备份索引脚本,配置linux crontab可以自定完成定时备份功能,希望大家给个好评,谢谢
Elasticsearch索引恢复
elasticsearch.yml 配置文件 ,大自然的搬运工
Spring Boot elasticsearch7.6.2基础操作:创建索引、新增数据、查询数据
资源方法有单个的增删改查,模糊查询分页 ,固定字段的模糊查询,所有属性字段的模糊查询
es索引模板
elasticsearch 同义词创建索引实例
Elasticsearch-深入理解索引原理
内容包括9部分 一、 Elasticsearch 简介 简单描述Elasticsearch ...五、Elasticsearch索引和分片 六、索引过程 七、Elasticsearch存储原理 八、Elasticsearch使用过程中的坑 九、Elasticsearch写一致性保障
另外索引创建之后,数据库数据如有改动,索引无法联动修改,ElasticSearch没有相关功能,我们只能根据修改频率重建索引,基本上没有实时性可言。 db-river-es正是为了解决这些问题而生。 项目介绍 名称:es-...
Elasticsearch 可以用于:分布式实时文件存储,并将每一个字段都编入索引,使其可以被搜索;实时分析的分布式搜索引擎;可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据。 Elasticsearch的文件存储 ...
(狂神)ElasticSearch快速入门笔记,ElasticSearch基本操作以及爬虫(Java-ES仿京东实战),包含了小狂神讲的东西,特别适合新手学习,笔记保存下来可以多看看。好记性不如烂笔头哦~,ElasticSearch,简称es,es是一个...
ElasticSearch数据导出 elasticsearch单文档数据导出 支持自定义查询 导出数据Json文件
该篇文章源码:Nodejs实现自动清理elasticsearch过期索引(日志清理)--学习笔记 http://blog.csdn.net/gzy11/article/details/55260615
## ElasticSearch ### 概念 - 倒排索引 - 文档:每一条数据就是一个文档 - 词条:由文档分词得到,为词条创建索引 - 查询过程:将用户的搜索内容进行分词,根据词到索引中进行查找 - 与正向索引比较:正向...
docker run --name elasticsearch7.16.3 -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v /Users/xingyue/Home/xingyue/学习/工程化/es/elasticsearch.yml:/usr/share/elastic...