Unable to execute "Terms Facet " query

Hi,

I am facing a problem with "terms facet".
The document contains "userscore" and "userid" fields. I m sorting
them on "userscore" field . I want two things from one query .1) top
score 2) score of given userid .

I have been trying the following query by passing it in the request
body.

{
"query" : {
"term" : {
"tournamentid" : "220"
}
},
"sort": {
"userscore" : {"reverse" : true}
},
"facets" : {
"tag" : {
"terms" : {
"userid" : "potter",
"size" : 10
} ,
"global" : false
}
}
}

and i m getting this error "Parse Failure [No facet type found for
[tag]]];"

Please let me know a solution for this.

Hi,

I think you need to say:

"facets" : {
"tag" : {
"terms" : {
"field" : "userid", // <-- note the "field" string
"size" : 10
} ,
"global" : false
}
}

Note that where you originally said "userid" there was "field" expected.

Regards,
Lukas

On Mon, Jul 26, 2010 at 12:24 PM, vishal ingle vishalingle@gmail.comwrote:

Hi,

I am facing a problem with "terms facet".
The document contains "userscore" and "userid" fields. I m sorting
them on "userscore" field . I want two things from one query .1) top
score 2) score of given userid .

I have been trying the following query by passing it in the request
body.

{
"query" : {
"term" : {
"tournamentid" : "220"
}
},
"sort": {
"userscore" : {"reverse" : true}
},
"facets" : {
"tag" : {
"terms" : {
"userid" : "potter",
"size" : 10
} ,
"global" : false
}
}
}

and i m getting this error "Parse Failure [No facet type found for
[tag]]];"

Please let me know a solution for this.

Hi,

I tried your solution Lukas but still its giving error. I think its the
condition for the facet query .

Regards,
Vishal Ingle

I am using a very similar query and the facets portion of the json looks
good to me (except the "field" part, you really need to use "field" string
to tell elasticsearch which field you want to aggregate facets on).

Which version of elasticsearch are you using?

Lukas

On Mon, Jul 26, 2010 at 1:12 PM, vishal ingle vishalingle@gmail.com wrote:

Hi,

I tried your solution Lukas but still its giving error. I think its the
condition for the facet query .

Regards,
Vishal Ingle

Version 0.8 .

I tried your solution but still its throwing error .

Do you think you can try it with 0.9.0-SNAPSHOT?
0.9.0 should be released very very soon (probably today or tomorrow) anyway.

Also if you can send a stack trace from the server log it could help.

Regards,
Lukas

On Mon, Jul 26, 2010 at 1:54 PM, vishal ingle vishalingle@gmail.com wrote:

Version 0.8 .

I tried your solution but still its throwing error .

[17:40:52,773][DEBUG][action.search.type ] [Aunt May Parker]
[tournament][3], Node[057b434a-6bc3-4660-b17f-b3bb24f3b440], [P],
S[STARTED]: Failed to execute
[org.elasticsearch.action.search.SearchRequest@2db51a5c]
org.elasticsearch.search.SearchParseException: [tournament][3]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [Failed to parse [{
"query" : {
"term" : {
"tournamentid" : "220"
}
},
"sort": {
"userscore" : {"reverse" : true}
},
"facets" : {
"tag" : {
"terms" : {
"userid" : "potter",
"size" : 10
} ,
"global" : false
}
}
}]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:355)
at
org.elasticsearch.search.SearchService.createContext(SearchService.java:292)
at
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:161)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:129)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:77)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:180)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:78)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.run(TransportSearchTypeAction.java:142)
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: [tournament][3]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [No facet type found for [tag]]
at
org.elasticsearch.search.facets.FacetsParseElement.parse(FacetsParseElement.java:90)
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:349)
... 10 more

The earlier was for the query i was trying... and as u suggested the query
gave following error..

[18:00:45,910][DEBUG][action.search.type ] [Aunt May Parker]
[tournament][0], Node[057b434a-6bc3-4660-b17f-b3bb24f3b440], [P],
S[STARTED]: Failed to execute
[org.elasticsearch.action.search.SearchRequest@72556b3d]
org.elasticsearch.search.SearchParseException: [tournament][0]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [Failed to parse [{
"query" : {
"term" : {
"tournamentid" : "220"
}
},
"sort": {
"userscore" : {"reverse" : true}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "userid",
"size" : 10
} ,
"global" : false
}
}
}]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:355)
at
org.elasticsearch.search.SearchService.createContext(SearchService.java:292)
at
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:161)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:129)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:77)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:180)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:78)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.run(TransportSearchTypeAction.java:142)
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: [tournament][0]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [No facet type found for [tag]]
at
org.elasticsearch.search.facets.FacetsParseElement.parse(FacetsParseElement.java:90)
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:349)
... 10 more

The syntax of query DSL has changed, so if I understand old documentation
correctly (
http://github.com/elasticsearch/elasticsearch.github.com/blob/09f7ac3248e6607e6bf1825fa26c0bb2b3b08e60/docs/elasticsearch/rest_api/search/index.textile

search for Facet Queries) then you should probably use "term" instead of
"terms":

"facets" : {
"tag" : {
"term" : { // <- here is the change
"userid" : "potter",
"size" : 10
} ,
"global" : false
}
}

But note that current online documentation is prepared for new 0.9.0 release
and is not valid for older releases (so I am not sure about the "size" usage
inside the facets in your case).

Regards,
Lukas

On Mon, Jul 26, 2010 at 2:18 PM, vishal ingle vishalingle@gmail.com wrote:

[17:40:52,773][DEBUG][action.search.type ] [Aunt May Parker]
[tournament][3], Node[057b434a-6bc3-4660-b17f-b3bb24f3b440], [P],
S[STARTED]: Failed to execute
[org.elasticsearch.action.search.SearchRequest@2db51a5c]
org.elasticsearch.search.SearchParseException: [tournament][3]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [Failed to parse [{

"query" : {
"term" : {
"tournamentid" : "220"
}
},
"sort": {
"userscore" : {"reverse" : true}
},
"facets" : {
"tag" : {
"terms" : {
"userid" : "potter",
"size" : 10
} ,
"global" : false
}
}
}]]
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:355)
at
org.elasticsearch.search.SearchService.createContext(SearchService.java:292)
at
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:161)
at
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:129)
at
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:77)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:180)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:78)
at
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.run(TransportSearchTypeAction.java:142)
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: [tournament][3]:
query[tournamentid:[220 TO 220]],from[-1],size[-1],sort[<double:
"userscore">!]: Parse Failure [No facet type found for [tag]]
at
org.elasticsearch.search.facets.FacetsParseElement.parse(FacetsParseElement.java:90)
at
org.elasticsearch.search.SearchService.parseSource(SearchService.java:349)
... 10 more