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"
}
}
}
}
}
}
warkolm
(Mark Walkom)
March 1, 2016, 9:33pm
2
It'd help if you could post the error as well!
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
}