我是Elasticsearch的新手,对路径的分层标记化器有疑问.这是我的代码示例:
我的映射代码:
PUT /my_index
{
"settings": {
"analysis": {
"analyzer": {
"path-analyzer": {
"type": "custom",
"tokenizer": "path-tokenizer"
}
},
"tokenizer": {
"path-tokenizer": {
"type": "path_hierarchy",
"delimiter": "."
}
}
}
},
"mappings": {
"my_type": {
"dynamic": "strict",
"properties": {
"group_path": {
"type": "string",
"index_analyzer": "path-analyzer",
"search_analyzer": "keyword"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的PUT:
PUT /my_index/my_type/1
{
"group_path": ["Book.Thriller.Adult","DVD.Comedy.Kids"]
}
Run Code Online (Sandbox Code Playgroud)
这是我的查询:
GET /my_index/my_type/_search?search_type=count
{
"aggs": {
"category": {
"terms": {
"field": "group_path",
"size": 0
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
{
... …Run Code Online (Sandbox Code Playgroud)