ElasticSearch 索引配置
新建简单索引
curl -XPUT [address]/index_name
带参数新建索引
1 | curl -XPUT [address]/index_name -d '{ |
配置 ik
分词器(ElasticSearch 版本 2.4.5)
按照上面的方法配置 ik
分词器不成功,需要按照 elasticsearch-analysis-ik 官方 README 方法才能成功
删除索引
curl -XDELETE [address]/index_name
错误
建立映射1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'
{
"fulltext": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost": 8
}
}
}
}'
响应为 400
1
2
3
4
5
6
7
8
9
10
11
12
13{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "No handler for type [text] declared on field [content]"
}
],
"type": "mapper_parsing_exception",
"reason": "No handler for type [text] declared on field [content]"
},
"status": 400
}
上面这个请求在2.3.4版本的es服务器上会执行失败,原因是es 2.3.4上面还没有text这种类型,”type”:”text” 改为 “type”:”String”即可
参考文章: