You should be able to use filtered queries instead, where the filter is
your facet filter:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html

The filtered query will filter documents before the query. Facets work on
the documents returned by the query, so if the documents are pre-filtered,
the facets will not even work on them.

-- 
Ivan




On Mon, Apr 7, 2014 at 6:56 PM, Alex G <alex.gr...@crowdstrike.com> wrote:

> Hello,
>
> I'm implementing a faceted interface that requires that all the facets be
> filtered by a shared filter - below is roughly how the queries currently
> look, is there a more efficient/performant way to make this kind of query?
> Less fussed about actual query verbosity but if there some way of sharing
> or referencing the repeated facet_filter other than search templates that'd
> be fantastic.
>
> Thanks,
>
> Alex
>
> {
>     "facets": {
>         "facetOne": {
>             "facet_filter": {
>                 "bool": {
>                     "must": [
>                         {
>                             "term": {
>                                 "foo.bar": "test"
>                             }
>                         },
>                         {
>                             "term": {
>                                 "baz":"test*"
>                             }
>                         }
>                     ]
>                 }
>             },
>             "terms": {
>                 "field": "facetOne.field",
>                 "order": ["count"],
>                 "size": 50
>             }
>         },
>
>         "facetTwo": {
>             "facet_filter": {
>                 "bool": {
>                     "must": [
>                         {
>                             "term": {
>                                 "foo.bar": "test"
>                             }
>                         },
>                         {
>                             "term": {
>                                 "baz":"test*"
>                             }
>                         }
>                     ]
>                 }
>             },
>             "terms": {
>                 "field": "facetTwo.field",
>                 "order": ["count"],
>                 "size": 50
>             }
>         },
>
>         "facetThree": {
>             "facet_filter": {
>                 "bool": {
>                     "must": [
>                         {
>                             "term": {
>                                 "foo.bar": "test"
>                             }
>                         },
>                         {
>                             "term": {
>                                 "baz":"test*"
>                             }
>                         }
>                     ]
>                 }
>             },
>             "terms": {
>                 "field": "facetThree.field",
>                 "order": ["count"],
>                 "size": 50
>             }
>         }
>     },
>     "size": 0
> }
>
>
>
>
> ------------------------------
>
> *CONFIDENTIALITY NOTICE:* The information contained in this message may be 
> privileged and/or confidential. It is the property of CrowdStrike.  If you 
> are not the intended recipient, or responsible for delivering this message to 
> the intended recipient, any review, forwarding, dissemination, distribution 
> or copying of this communication or any attachment(s) is strictly prohibited. 
> If you have received this message in error, please notify the sender 
> immediately, and delete it and all attachments from your computer and network.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/0993b970-b60c-4e38-b42c-953394abdac1%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/0993b970-b60c-4e38-b42c-953394abdac1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCMqCGyvmv025zuy-GovaKMQkY7GTf5uj63fdJaH8Biaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to