我要在 ES 中创建一个索引,它包含多个字段。我想让其中一些字段使用“空格分词”,另一些字段使用“标准分词”。
示例代码如下:
PUT /my_index
{
"settings": {
"analysis": {
"analyzer": {
"space_analyzer": {
"type": "custom",
"tokenizer": "space_tokenizer"
}
},
"tokenizer": {
"space_tokenizer": {
"type": "whitespace"
}
}
}
},
"mappings": {
"properties": {
"field1": {
"type": "text",
"analyzer": "space_analyzer"
},
"field2": {
"type": "text",
"analyzer": "space_analyzer"
},
"field3": {
"type": "text",
"analyzer": "standard"
},
"field4": {
"type": "text",
"analyzer": "standard"
}
}
}
}
