Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2013 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4475755 to your computer and use it in GitHub Desktop.
Save anonymous/4475755 to your computer and use it in GitHub Desktop.
I'm trying to filter the search results based on facetted search where multiple terms can be selected per facet. Request body beneath results in following exception: No query registered for [and]. Someone pointing me in de right direction?
// Request Body
{
"from":0,
"size":25,
"facets":{
"Mime":{
"terms":{
"field":"mime_type",
"all_terms":true
}
},
"Created":{
"date_histogram":{
"field":"epoch_created",
"all_terms":true,
"interval":"day"
}
},
"Modified":{
"date_histogram":{
"field":"epoch_modified",
"all_terms":true,
"interval":"day"
}
},
"Accessed":{
"date_histogram":{
"field":"epoch_accessed",
"all_terms":true,
"interval":"day"
}
},
"FileSize":{
"range":{
"field":"size_bytes",
"ranges":[
{
"to":1024000
},
{
"from":1024001,
"to":2048000
},
{
"from":2048001,
"to":3072000
},
{
"from":3072001,
"to":4096000
},
{
"from":4096001
}
]
}
},
"Width":{
"range":{
"field":"width",
"ranges":[
{
"to":100
},
{
"from":101,
"to":500
},
{
"from":501,
"to":1000
},
{
"from":1001,
"to":2000
},
{
"from":2001
}
]
}
},
"Height":{
"range":{
"field":"height",
"ranges":[
{
"to":100
},
{
"from":101,
"to":500
},
{
"from":501,
"to":1000
},
{
"from":1001,
"to":2000
},
{
"from":2001
}
]
}
}
},
"query":{
"filtered":{
"query":{
"match_all":[
]
},
"filter":{
"and":[
{
"range":{
"epoch_created":[
{
"from":1339200000000,
"to":1339286400000
},
{
"from":1343001600000,
"to":1343088000000
}
]
}
},
{
"terms":{
"mime_type":[
"image\/jpeg",
"image\/gif"
]
}
}
]
}
}
}
}
// Error Reponse:
{
"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[BkRghoQSQvekvKMjcw5Aag][967b3d1a605818b757a8baad08e0fd596b7ef9a2][0]: SearchParseException[[967b3d1a605818b757a8baad08e0fd596b7ef9a2][0]: from[0],size[25]: Parse Failure [Failed to parse source [{\"from\":0,\"size\":25,\"facets\":{\"Mime\":{\"terms\":{\"field\":\"mime_type\",\"all_terms\":true}},\"Created\":{\"date_histogram\":{\"field\":\"epoch_created\",\"all_terms\":true,\"interval\":\"day\"}},\"Modified\":{\"date_histogram\":{\"field\":\"epoch_modified\",\"all_terms\":true,\"interval\":\"day\"}},\"Accessed\":{\"date_histogram\":{\"field\":\"epoch_accessed\",\"all_terms\":true,\"interval\":\"day\"}},\"FileSize\":{\"range\":{\"field\":\"size_bytes\",\"ranges\":[{\"to\":1024000},{\"from\":1024001,\"to\":2048000},{\"from\":2048001,\"to\":3072000},{\"from\":3072001,\"to\":4096000},{\"from\":4096001}]}},\"Width\":{\"range\":{\"field\":\"width\",\"ranges\":[{\"to\":100},{\"from\":101,\"to\":500},{\"from\":501,\"to\":1000},{\"from\":1001,\"to\":2000},{\"from\":2001}]}},\"Height\":{\"range\":{\"field\":\"height\",\"ranges\":[{\"to\":100},{\"from\":101,\"to\":500},{\"from\":501,\"to\":1000},{\"from\":1001,\"to\":2000},{\"from\":2001}]}}},\"query\":{\"filtered\":{\"query\":{\"match_all\":[]},\"filter\":{\"and\":[{\"range\":{\"epoch_created\":[{\"from\":1339200000000,\"to\":1339286400000},{\"from\":1343001600000,\"to\":1343088000000}]}},{\"terms\":{\"mime_type\":[\"image\\\/jpeg\",\"image\\\/gif\"]}}]}}}}]]]; nested: QueryParsingException[[967b3d1a605818b757a8baad08e0fd596b7ef9a2] No query registered for [and]]; }]",
"status":500
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment