gpt4 book ai didi

elasticsearch - ElasticSearch路径层次结构 token 生成器聚合

转载 作者:行者123 更新时间:2023-12-02 23:45:52 24 4
gpt4 key购买 nike

我在这里使用这个例子。

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pathhierarchy-tokenizer-examples.html#analysis-pathhierarchy-tokenizer-examples

我的映射代码如下:我的映射代码如下:我的映射代码如下:

PUT file-path-test
{
"settings": {
"analysis": {
"analyzer": {
"custom_path_tree": {
"tokenizer": "custom_hierarchy"
},
"custom_path_tree_reversed": {
"tokenizer": "custom_hierarchy_reversed"
}
},
"tokenizer": {
"custom_hierarchy": {
"type": "path_hierarchy",
"delimiter": "/"
},
"custom_hierarchy_reversed": {
"type": "path_hierarchy",
"delimiter": "/",
"reverse": "true"
}
}
}
},
"mappings": {
"properties": {
"file_path": {
"type": "text",
"fields": {
"tree": {
"type": "text",
"analyzer": "custom_path_tree"
},
"tree_reversed": {
"type": "text",
"analyzer": "custom_path_tree_reversed"
}
}
}
}
}
}

POST file-path-test/_doc/1
{
"file_path": "/User/alice/photos/2017/05/16/my_photo1.jpg"
}

POST file-path-test/_doc/2
{
"file_path": "/User/alice/photos/2017/05/16/my_photo2.jpg"
}

POST file-path-test/_doc/3
{
"file_path": "/User/alice/photos/2017/05/16/my_photo3.jpg"
}

POST file-path-test/_doc/4
{
"file_path": "/User/alice/photos/2017/05/15/my_photo1.jpg"
}

POST file-path-test/_doc/5
{
"file_path": "/User/bob/photos/2017/05/16/my_photo1.jpg"
}

下面的查询似乎为空。
GET / file-path-test / _search
{
  
   "aggs": {
     "FILTER": {
       "terms": {
         "field": "file_path."
       }
     }
   }
}

响应:
"aggregations": {
     "FILTER": {
       "doc_count_error_upper_bound": 0,
       "sum_other_doc_count": 0,
       "buckets": []
     }
   }

是什么原因?

最佳答案

您提到的示例非常简单,并且没有向tokeniser字段映射添加任何内容...基本上将以下内容添加到字段中

          "search_analyzer": "keyword",
"fielddata": true

还请确保汇总完整字段: file_path.treefile_path.tree_reversed
例如。
GET /file-path-test/_search
{
"aggs": {
"_doc": {
"terms": {
"field": "file_path.tree"
}
}
}
}

关于elasticsearch - ElasticSearch路径层次结构 token 生成器聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61104497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com