首页  

Elasticsearch analyzer 和 search_analyzer     所属分类 elasticsearch 浏览量 1110
Elasticsearch5.6.8

分析器
analyzer         索引文档时使用 
search_analyzer  搜索时先对query分词再查询

分词接口
POST /_analyze

{"text": "Java is the best programming language"}

{"text": "java是最好的编程语言"}
默认不支持中文分析,只能分析出java  
高版本ES 默认分词器 是 standard ,中文分词 单字拆分
浙江东阳 拆分成  浙 江 东 阳


{
    "analyzer": "ik_smart",
     "text": "java是最好的编程语言"
}

failed to find global analyzer [ik_smart]

IKAnalyzer 开源的java中文分词工具
ik_smart
ik_max_word  


index.analysis.analyzer.default.type: ik

禁用自动索引创建和自动mapping
action.auto_create_index: false
index.mapper.dynamic: false

创建索引
curl -X PUT /INDEXNAME?pretty -d '{"settings":{"number_of_shards":1,"number_of_replicas":0}}'


PUT
/blogs

创建索引类型
PUT /blogs/_mapping/blog?pretty
{"dynamic":"strict","properties":{"id":{"type":"long"},"content":{"type":"string"}}}

PUT /索引名/索引类型/_mapping
{"dynamic":false}
 
严格模式 不在mapping中的字段不能写入
{"dynamic":"strict"}


索引查看
/_cat/indices?v

查看索引信息
/blogs


添加或更新文档
PUT  /blogs/blog/1
{"id":1,"content":"hello world"}

PUT  /blogs/blog/2
{"id":2,"content":"Java is the best programming language"}

严格模式,写入未定义的字段报错
mapping set to strict, dynamic introduction of [xxx] within [blog] is not allowed


查看文档
/blogs/blog/1
/blogs/blog/2


/blogs/_search
/blogs/blog/_search
/blogs/blog/_search?q=*&sort=id:desc



elasticsearch5.0入门之索引操作

上一篇     下一篇
三国演义里的职场道理

linux文本处理shell命令

elasticsearch集群搭建

Elasticsearch5快速入门

Elasticsearch分词器

ElasticSearch 状态查询Cat接口