Is facet filter allowed inside a filtered query?

Hi, I got the following exception, saying "No parser for element
[term]", when putting a facet filter inside a filtered query.

[2011-10-01 16:37:57,759][DEBUG][action.search.type ]
[Stratosfire] [master][0], node[i6Fw5LCsSPekSt4tvKYLkA], [P],
s[STARTED]: Failed to execute
[org.elasticsearch.action.search.SearchRequest@a3ba72]
org.elasticsearch.search.SearchParseException: [master][0]:
query[ConstantScore(FilterCacheFilterWrapper(account:acct_1))],from[-1],size[-1]:
Parse Failure [Failed to parse source [{"query":{"filtered":{"query":
{"match_all":{}},"filter":{"term":{"account":"acct_1"}},"from":
0,"size":10,"sort":[],"facets":{"daily_success":{"date_histogram":
{"field":"timeStamp","interval":"day","global":false},"facet_filter":
{"term":{"status":"success"}}}}}}}]]
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:619)
Caused by: org.elasticsearch.search.SearchParseException: [master][0]:
query[ConstantScore(FilterCacheFilterWrapper(account:acct_1))],from[-1],size[-1]:
Parse Failure [No parser for element [term]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:
481)
... 10 more

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": {
"account": "acct_1"
}
},
"from": 0,
"size": 10,
"sort": [],
"facets": {
"daily_success": {
"date_histogram": {
"field": "timeStamp",
"interval": "day",
"global": false
},
"facet_filter": {
"term": {
"status": "success"
}
}
}
}
}
}
}

But if I remove the term clause

        "term": {
          "status": "success"
        }

Then the query worked fine.

Any sugguestions?

Thanks,

-- Liyu

OK, It appears to me the facet must be outside of the query. So the right
query should be

{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": { "term": { "account": "acct_1" }
}
},
"from": 0,
"size": 10,
"sort": ,
"facets": {
"daily_success": {
"date_histogram": {
"field": "timeStamp",
"interval": "day",
"global": false
},
"facet_filter": {
"term": { "status": "success" }
}
}
}
}
}

On Sat, Oct 1, 2011 at 5:50 PM, Liyu liyuyi@gmail.com wrote:

Hi, I got the following exception, saying "No parser for element
[term]", when putting a facet filter inside a filtered query.

[2011-10-01 16:37:57,759][DEBUG][action.search.type ]
[Stratosfire] [master][0], node[i6Fw5LCsSPekSt4tvKYLkA], [P],
s[STARTED]: Failed to execute
[org.elasticsearch.action.search.SearchRequest@a3ba72]
org.elasticsearch.search.SearchParseException: [master][0]:

query[ConstantScore(FilterCacheFilterWrapper(account:acct_1))],from[-1],size[-1]:
Parse Failure [Failed to parse source [{"query":{"filtered":{"query":
{"match_all":{}},"filter":{"term":{"account":"acct_1"}},"from":
0,"size":10,"sort":,"facets":{"daily_success":{"date_histogram":
{"field":"timeStamp","interval":"day","global":false},"facet_filter":
{"term":{"status":"success"}}}}}}}]]
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:619)
Caused by: org.elasticsearch.search.SearchParseException: [master][0]:

query[ConstantScore(FilterCacheFilterWrapper(account:acct_1))],from[-1],size[-1]:
Parse Failure [No parser for element [term]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:
481)
... 10 more

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": {
"account": "acct_1"
}
},
"from": 0,
"size": 10,
"sort": ,
"facets": {
"daily_success": {
"date_histogram": {
"field": "timeStamp",
"interval": "day",
"global": false
},
"facet_filter": {
"term": {
"status": "success"
}
}
}
}
}
}
}

But if I remove the term clause

       "term": {
         "status": "success"
       }

Then the query worked fine.

Any sugguestions?

Thanks,

-- Liyu