# Path Analyzer : path\_hierarchy : Query throws error

**URL:** <https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082>\
**Category:** Elasticsearch\
**Created:** [March 1, 2016, 6:42am UTC](https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082 "2016-03-01T06:42:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shiv\_Naidu](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Shiv\_Naidu](https://discuss.elastic.co/u/Shiv_Naidu)\
**Post date:** [March 1, 2016, 6:42am UTC](https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082/1 "2016-03-01T06:42:54Z")

</div>

I am trying to use the path\_hierarchy and followed the sample from doc portal. It seems that it is parsing correctly b/c it is didn't throw any error when inserted the record but when I query using the same analyzer it throws error. But when I try to use only a term with no analyzer, it works fine. What am i doing wrong ?

**Mapping:**

> ```
> {
> "shivtestindex2": {
> "aliases": {},
> "mappings": {
> "movies3": {
> "properties": {
> "Info": {
> "properties": {
> "CategoryPath": {
> "type": "string",
> "analyzer": "path_custom1"
> },
> "EntityId": {
> "type": "long"
> }
> }
> },
> "info": {
> "properties": {
> "CategoryPath": {
> "type": "string"
> },
> "EntityId": {
> "type": "long"
> }
> }
> }
> }
> }
> },
> "settings": {
> "index": {
> "creation_date": "1456814725044",
> "uuid": "O9osuOnpT-mFtBkv_ppGvw",
> "analysis": {
> "analyzer": {
> "path_custom1": {
> "type": "custom",
> "filter": [
> "lowercase"
> ],
> "tokenizer": "path_hierarchy"
> }
> }
> },
> "number_of_replicas": "1",
> "number_of_shards": "5",
> "version": {
> "created": "1070299"
> }
> }
> },
> "warmers": {}
> }
> }
> 
> ```

**Inserted Records:**

> ```
> POST /shivtestindex2/movies3
> {
> "info": {
> "EntityId": 12345645673455,
> "CategoryPath" : "/cat1/cat2/sku/sku1"
> }
> }
> 
> ```

> ```
> POST /shivtestindex2/movies3
> {
> "info": {
> "EntityId": 12345645673455456,
> "CategoryPath" : "/cat1/cat2/sku/sku2"
> }
> }
> 
> ```

**Non Working Query:**

> ```
> GET /shivtestindex2/movies3/_search
> {
> "query": {
> "filtered": {
> "filter": {
> "query": {
> "query_string": {
> "default_field": "CategoryPath",
> "query": "sku/sku2",
> "analyzer": "path_custom1"
> }
> }
> }
> }
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 1, 2016, 9:33pm UTC](https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082/2 "2016-03-01T21:33:04Z")

</div>

It'd help if you could post the error as well! 🙂

---

<div class="post-metadata">

**Author:** ![Shiv\_Naidu](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Shiv\_Naidu](https://discuss.elastic.co/u/Shiv_Naidu)\
**Post date:** [March 1, 2016, 9:35pm UTC](https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082/3 "2016-03-01T21:35:13Z")

</div>

Sorry it is a general parse exception.. see the exception below,

{  
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[xrXBJ2McRQKODGwzZL74Lg][shivtestindex2][0]: SearchParseException[[shivtestindex2][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "filtered": {\n "filter": {\n "query": {\n "query\_string": {\n "default\_field": "CategoryPath",\n "query": "sku/sku\_category2",\n "analyzer": "path\_custom1"\n }\n }\n }\n }\n }\n}\n]]]; nested: QueryParsingException[[shivtestindex2] Failed to parse query [sku/sku\_category2]]; nested: ParseException[Cannot parse 'sku/sku\_category2': Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; nested: TokenMgrError[Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; }{[xrXBJ2McRQKODGwzZL74Lg][shivtestindex2][1]: SearchParseException[[shivtestindex2][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "filtered": {\n "filter": {\n "query": {\n "query\_string": {\n "default\_field": "CategoryPath",\n "query": "sku/sku\_category2",\n "analyzer": "path\_custom1"\n }\n }\n }\n }\n }\n}\n]]]; nested: QueryParsingException[[shivtestindex2] Failed to parse query [sku/sku\_category2]]; nested: ParseException[Cannot parse 'sku/sku\_category2': Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; nested: TokenMgrError[Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; }{[xrXBJ2McRQKODGwzZL74Lg][shivtestindex2][2]: SearchParseException[[shivtestindex2][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "filtered": {\n "filter": {\n "query": {\n "query\_string": {\n "default\_field": "CategoryPath",\n "query": "sku/sku\_category2",\n "analyzer": "path\_custom1"\n }\n }\n }\n }\n }\n}\n]]]; nested: QueryParsingException[[shivtestindex2] Failed to parse query [sku/sku\_category2]]; nested: ParseException[Cannot parse 'sku/sku\_category2': Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; nested: TokenMgrError[Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; }{[xrXBJ2McRQKODGwzZL74Lg][shivtestindex2][3]: SearchParseException[[shivtestindex2][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "filtered": {\n "filter": {\n "query": {\n "query\_string": {\n "default\_field": "CategoryPath",\n "query": "sku/sku\_category2",\n "analyzer": "path\_custom1"\n }\n }\n }\n }\n }\n}\n]]]; nested: QueryParsingException[[shivtestindex2] Failed to parse query [sku/sku\_category2]]; nested: ParseException[Cannot parse 'sku/sku\_category2': Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; nested: TokenMgrError[Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; }{[xrXBJ2McRQKODGwzZL74Lg][shivtestindex2][4]: SearchParseException[[shivtestindex2][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n "query": {\n "filtered": {\n "filter": {\n "query": {\n "query\_string": {\n "default\_field": "CategoryPath",\n "query": "sku/sku\_category2",\n "analyzer": "path\_custom1"\n }\n }\n }\n }\n }\n}\n]]]; nested: QueryParsingException[[shivtestindex2] Failed to parse query [sku/sku\_category2]]; nested: ParseException[Cannot parse 'sku/sku\_category2': Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; nested: TokenMgrError[Lexical error at line 1, column 18. Encountered: after : "/sku\_category2"]; }]",  
"status": 400  
}

---

<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:** [July 5, 2017, 11:12pm UTC](https://discuss.elastic.co/t/path-analyzer-path-hierarchy-query-throws-error/43082/4 "2017-07-05T23:12:17Z")

</div>


