# ElasticSearch Path Hierarchy Tokenizer Aggregation

**URL:** <https://discuss.elastic.co/t/elasticsearch-path-hierarchy-tokenizer-aggregation/227191>\
**Category:** Elasticsearch\
**Created:** [April 8, 2020, 6:14pm UTC](https://discuss.elastic.co/t/elasticsearch-path-hierarchy-tokenizer-aggregation/227191 "2020-04-08T18:14:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oemer](https://avatars.discourse-cdn.com/v4/letter/o/3bc359/32.png) [@oemer](https://discuss.elastic.co/u/oemer)\
**Post date:** [April 8, 2020, 6:14pm UTC](https://discuss.elastic.co/t/elasticsearch-path-hierarchy-tokenizer-aggregation/227191/1 "2020-04-08T18:14:56Z")

</div>

I'm going with the this example here.

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

My mapping code is below:

```auto
    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"
    }

```

The query below seems empty.

```auto
    GET / file-path-test / _search
    {
      
       "aggs": {
         "FILTER": {
           "terms": {
             "field": "file_path."
           }
         }
       }
    }

```

Response:

```auto
    "aggregations": {
         "FILTER": {
           "doc_count_error_upper_bound": 0,
           "sum_other_doc_count": 0,
           "buckets": []
         }
       }

```

What is the reason?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 6, 2020, 6:15pm UTC](https://discuss.elastic.co/t/elasticsearch-path-hierarchy-tokenizer-aggregation/227191/2 "2020-05-06T18:15:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
