Created
August 30, 2011 04:53
-
-
Save sbeckeriv/1180213 to your computer and use it in GitHub Desktop.
query problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mapping: | |
| { | |
| "seattlefood" : { | |
| "inspection" : { | |
| "properties" : { | |
| "phone" : { | |
| "type" : "string" | |
| }, | |
| "location" : { | |
| "type" : "geo_point" | |
| }, | |
| "zipcode" : { | |
| "type" : "string" | |
| }, | |
| "inspection_score" : { | |
| "type" : "integer" | |
| }, | |
| "inspection_type" : { | |
| "type" : "string" | |
| }, | |
| "blog" : { | |
| "index" : "not_analyzed", | |
| "store" : "yes", | |
| "type" : "string" | |
| }, | |
| "type" : { | |
| "type" : "string" | |
| }, | |
| "city" : { | |
| "type" : "string" | |
| }, | |
| "violations" : { | |
| "properties" : { | |
| "_id" : { | |
| "store" : "yes", | |
| "type" : "integer" | |
| }, | |
| "description" : { | |
| "type" : "string" | |
| }, | |
| "points" : { | |
| "type" : "integer" | |
| }, | |
| "type" : { | |
| "type" : "string" | |
| } | |
| } | |
| }, | |
| "results" : { | |
| "type" : "string" | |
| }, | |
| "address" : { | |
| "type" : "string" | |
| }, | |
| "description" : { | |
| "type" : "string" | |
| }, | |
| "name" : { | |
| "store" : "yes", | |
| "type" : "string" | |
| }, | |
| "closed" : { | |
| "type" : "boolean" | |
| }, | |
| "inspected_at" : { | |
| "format" : "dateOptionalTime", | |
| "type" : "date" | |
| } | |
| }, | |
| "dynamic_date_formats" : [ "yyyy-MM-dd", "dd-MM-yyyy" ] | |
| } | |
| } | |
| } | |
| Query 1 works | |
| { | |
| "size": 1000, | |
| "query": { | |
| "filtered": { | |
| "filter": { | |
| "geo_bounding_box": { | |
| "location": { | |
| "bottom_right": [ | |
| -122.312939607765, | |
| 47.613121501997 | |
| ], | |
| "top_left": [ | |
| -122.323314392235, | |
| 47.6155624695172 | |
| ] | |
| } | |
| } | |
| }, | |
| "query": { | |
| "match_all": {}, | |
| "filter": { | |
| "range": { | |
| "inspection_score": { | |
| "from": 30 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| Query 2 does not work | |
| { | |
| "size": 1000, | |
| "query": { | |
| "filtered": { | |
| "filter": { | |
| "geo_bounding_box": { | |
| "location": { | |
| "bottom_right": [ | |
| -122.312939607765, | |
| 47.613121501997 | |
| ], | |
| "top_left": [ | |
| -122.323314392235, | |
| 47.6155624695172 | |
| ] | |
| } | |
| } | |
| }, | |
| "query": { | |
| "filter": { | |
| "range": { | |
| "inspection_score": { | |
| "from": 30 | |
| } | |
| } | |
| }, | |
| "match_all": {} | |
| } | |
| } | |
| } | |
| } | |
| Error | |
| [2011-08-29 21:51:34,262][DEBUG][action.search.type ] [Hogun] [seattlefood][1], node[Bdq7YnAyTc29JhB6ieA17Q], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@762c8dbc] | |
| org.elasticsearch.search.SearchParseException: [seattlefood][1]: from[-1],size[1000]: Parse Failure [Failed to parse source [{"size":1000,"query":{"filtered":{"filter":{"geo_bounding_box":{"location":{"bottom_right":[-122.312939607765,47.613121501997],"top_left":[-122.323314392235,47.6155624695172]}}},"query":{"filter":{"range":{"inspection_score":{"from":30}}},"match_all":{}}}}}]] | |
| at org.elasticsearch.search.SearchService.parseSource(SearchService.java:495) | |
| at org.elasticsearch.search.SearchService.createContext(SearchService.java:407) | |
| at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:230) | |
| at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:134) | |
| at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80) | |
| at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204) | |
| at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191) | |
| at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177) | |
| at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) | |
| at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) | |
| at java.lang.Thread.run(Thread.java:680) | |
| Caused by: org.elasticsearch.index.query.QueryParsingException: [seattlefood] No query registered for [filter] | |
| at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:154) | |
| at org.elasticsearch.index.query.FilteredQueryParser.parse(FilteredQueryParser.java:63) | |
| at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:156) | |
| at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:232) | |
| at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:212) | |
| at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:32) | |
| at org.elasticsearch.search.SearchService.parseSource(SearchService.java:483) | |
| ... 10 more | |
| MORE CORRECT QUERY | |
| { | |
| "query": { | |
| "filtered": { | |
| "filter": { | |
| "and": [ | |
| { | |
| "geo_bounding_box": { | |
| "location": { | |
| "bottom_right": [ | |
| -122.315513187315, | |
| 47.6137317545592 | |
| ], | |
| "top_left": [ | |
| -122.320740812685, | |
| 47.6149522383193 | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "range": { | |
| "inspection_score": { | |
| "from": 50 | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| "query": { | |
| "match_all": {} | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment