Is it possible to make filter queries for every named_query

Is it possible to make filter queries for every named_query?
Suppose i have several named queries, i want some kind of aggregation for them: make filter to narrow for dynamic named queries.
The problem is that in one query i cannot achieve this, because during query i don't know the name.

https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-request-named-queries-and-filters.html

Sorry but I have trouble understanding what you want to achieve. Are you looking for the terms aggregation maybe? https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

What i read in docs is facets implemented on fields, for example dates or authors, then filtering is done like this:

Tom (345)
Mary (218)
...

But this is not what i want. I have in my models only 1 text field and facets are aggregated dynamically during search. So, for movie texts i want facets like this:

Detective (633)
Comedy (237)
...

and each genre is calculated by search query:

Detective

text: "Columbo is an American television series starring Peter Falk as Columbo, a homicide detective with the Los Angeles Police Department.[2][3] The character and show, created by William Link and Richard Levinson, popularized the inverted detective story format, which begins by showing the commission of the crime and its perpetrator; the series therefore has no "whodunit" element. The plot revolves around how a perpetrator whose identity is already known to the audience will finally be caught and exposed (which the show's writers called a "howcatchem," rather than a "whodunit")."

to detect category we do search: (cop | murder | crime | ...) OR (story | ...)
The key idea, that i do several complex named queries to make some data mining.

Then, after i done named queries, i must write name_of_query (_name) data to database to allow user filter it in web interface of my app.

Is there a way to get name_of_query with elastic to do filtering like facets?

OK, got it. You can use a filters aggregation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html

For the record, note that it would bemore efficient to compute the genre at index time and then to do a terms aggregation on the genre field.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.