# Path Hierarchy tokenizer - Wildcard search

**URL:** <https://discuss.elastic.co/t/path-hierarchy-tokenizer-wildcard-search/81639>\
**Category:** Elasticsearch\
**Created:** [April 7, 2017, 4:24pm UTC](https://discuss.elastic.co/t/path-hierarchy-tokenizer-wildcard-search/81639 "2017-04-07T16:24:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nil/32/8720_2.png) [@nil](https://discuss.elastic.co/u/nil)\
**Post date:** [April 7, 2017, 4:24pm UTC](https://discuss.elastic.co/t/path-hierarchy-tokenizer-wildcard-search/81639/1 "2017-04-07T16:24:36Z")

</div>

Hi guys,

Here are some sample documents:

```
{
    "id": 1,
    "path": "a/b/c"
}
{
    "id": 2,
    "path": "a/b/d"
}
{
    "id": 3,
    "path": "a/d/c"
}

```

I need to be able to search for documents whose path is under "a" (docs 1, 2, 3), or "a/b" (docs 1, 2). I can do that by using a path\_hierarchy tokenizer on the path field, and then using a terms query. This works great and runs very fast.

Now I also need to run a query that would return all documents under "a" with the last level being "c" (docs 1 and 3). I can use a wildcard query (something like "a/\*/c"), but I'm wondering if there's a more efficient option since the wildcard query can be slow.

Thank you in advance.

---

<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 5, 2017, 4:29pm UTC](https://discuss.elastic.co/t/path-hierarchy-tokenizer-wildcard-search/81639/2 "2017-05-05T16:29:39Z")

</div>

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