Skip to content

Instantly share code, notes, and snippets.

@alebsack

alebsack/Error Secret

Last active December 16, 2015 15:58
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 alebsack/fc8f0b377c1ca1e780fd to your computer and use it in GitHub Desktop.
Save alebsack/fc8f0b377c1ca1e780fd to your computer and use it in GitHub Desktop.
Multiple facets error
[2013-04-25 13:08:59,346][DEBUG][action.search.type ] [Human Robot] [directory_users][3], node[q90bIsQ_RwaB7kn4qpwziQ], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@29c114f2]
org.elasticsearch.search.SearchParseException: [directory_users][3]: query[ConstantScore(NotDeleted(+cache(customer_id:bd9058f4-bf18-416c-8e0d-07e1a1c9819a)))],from[-1],size[-1]: Parse Failure [Failed to parse source [{
"query": {
"filtered": {
"filter": {
"and": [
{
"term": {
"customer_id": "bd9058f4-bf18-416c-8e0d-07e1a1c9819a"
}
}
]
},
"query": {
"match_all": {}
}
}
},
"facets": {
"inactive_1w": {
"range": {
"field": "last_seen_at",
"ranges": {
"ranges": [
{
"to": "2013-04-18T13:04:58+01:00"
}
]
}
}
},
"inactive_2w": {
"range": {
"field": "last_seen_at",
"ranges": {
"ranges": [
{
"to": "2013-04-11T13:04:58+01:00"
}
]
}
}
}
},
"size": 1000
}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:481)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:466)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.elasticsearch.search.SearchParseException: [directory_users][3]: query[ConstantScore(NotDeleted(+cache(customer_id:bd9058f4-bf18-416c-8e0d-07e1a1c9819a)))],from[-1],size[-1]: Parse Failure [No parser for element [inactive_2w]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:552)
... 11 more
curl -X GET 'http://127.0.0.1:9200/directory_users/directory_user/_search?size=1000&pretty' -d '{
"query": {
"filtered": {
"filter": {
"and": [
{
"term": {
"customer_id": "bd9058f4-bf18-416c-8e0d-07e1a1c9819a"
}
}
]
},
"query": {
"match_all": {}
}
}
},
"facets": {
"inactive_1w": {
"range": {
"field": "last_seen_at",
"ranges": {
"ranges": [
{
"to": "2013-04-18T13:04:58+01:00"
}
]
}
}
},
"inactive_2w": {
"range": {
"field": "last_seen_at",
"ranges": {
"ranges": [
{
"to": "2013-04-11T13:04:58+01:00"
}
]
}
}
}
},
"size": 1000
}'
customer_id = customer.id
result = DirectoryUser.search(:per_page => MAX_RESULTS) do
query do
filtered do
query { all }
filter :term, :customer_id => customer_id
end
end
facet 'inactive_1w' do
range :last_seen_at, :ranges => [{:to => 1.week.ago}]
end
facet 'inactive_2w' do
range :last_seen_at, :ranges => [{:to => 2.weeks.ago}]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment