创建索引并设置默认分词器
PUT /nbademo
{
"settings" : {
"index" : {
"analysis.analyzer.default.type": "ik_max_word"
}
},
"mappings": {
"properties": {
"age":{
"type": "integer"
},
"displayName":{
"type": "text"
}
}
}
}
# or 或者
PUT /nbademo
{
"mappings": {
"properties": {
"age":{
"type": "integer"
},
"displayName":{
"type": "text"
}
}
},
"settings": {
"analysis": {
"analyzer": {
"default":{
"type":"ik_max_word"
}
}
}
}
}
返回结果
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "nbademo"
}
添加数据
PUT nbademo/_doc/1
{
"age":10,
"displayName":"清华大学"
}
PUT nbademo/_doc/2
{
"age":10,
"displayName":"102,103,101"
}
查询数据
GET nbademo/_search
{
"query": {
"match": {
"displayName": "清华"
}
}
}
GET nbademo/_search
{
"query": {
"match": {
"displayName": "103"
}
}
}