//新增索引并同时设置分词器和映射mapping
PUT /my_index
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"type": "whitespace"
}
}
}
},
"mappings": {
"properties": {
"name": {
"type": "text"
},
"team_name": {
"type": "text"
},
"position": {
"type": "text"
},
"play_year": {
"type": "long"
},
"jerse_no": {
"type": "keyword"
},
"title": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
//添加测试文档
PUT /my_index/_doc/1
{
"name": "库⾥里里",
"team_name": "勇⼠士",
"position": "控球后卫",
"play_year": 10,
"jerse_no": "30",
"title": "The best 3-points shooter is Curry!"
}
//测试分词的效果
POST /my_index/_search
{
"query": {
"match": {
"title": "Curry!"
}
}
}