After reading your scenario again, I have modified slightly my suggestion.
You would still need to use a post filter since the facets need to work on
set of documents that is greater than the set returned. You can apply the
same post filter as a facet filter on the facet you want to reduce. Here is
an example:

https://gist.github.com/brusic/8185134

-- 
Ivan


On Mon, Dec 30, 2013 at 7:57 AM, Volker <s...@klest.de> wrote:

> >Hopefully this makes sense. :)
>
> after reading through your provided links... not totally ;-)
>
> If I apply the selected facet before the the facet calculation, the facet
> will count only elements, that are part of the result. That would mean,
> that I would not get numbers for the not selected models (in this case no
> numbers for bmw and ford).
>
> If I apply the selected facet as a post_filter, I will get the correct
> numbers for the unselected models, but the facets for the color does not
> represent the numbers for the selected model, but for all models.
>
> But probably I have not understood it, as it was meant. :-)
>
> Could you please elaborate further, how the query/filter for a selected
> facet should be formulated? I have not found any example for this. If there
> is one online, I would appreciate a link to that example.
>
> Kind regards
>
>
>
> Am Freitag, 27. Dezember 2013 18:58:13 UTC+1 schrieb Ivan Brusic:
>
>> Facets work on the documents returned by the query.  This behavior will
>> not work in your case since you would like to gather facets on a greater
>> set of documents, not just the ones returned by the query. To solve this
>> issue, elasticsearch provides a post filter, which affects the result
>> document set, but not the set of documents that the facets work on.
>>
>> The term "filter" is a bit overloaded in elasticsearch, so the team
>> renamed the post filter to a more explicit "post_filter":
>>
>> http://www.elasticsearch.org/guide/en/elasticsearch/
>> reference/current/search-request-post-filter.html
>> https://github.com/elasticsearch/elasticsearch/issues/4119
>>
>> The post filter documentation has some insight on how the filters affect
>> the facets. In your case, you want a filtered query (
>> http://www.elasticsearch.org/guide/en/elasticsearch/
>> reference/current/query-dsl-filtered-query.html ) with the color as the
>> filter, but the model filter will be applied as a post filter. Hopefully
>> this makes sense. :)
>>
>> Cheers,
>>
>> Ivan
>>
>>
>> On Fri, Dec 27, 2013 at 9:41 AM, Volker <s...@klest.de> wrote:
>>
>>> Dear Readers
>>>
>>> I have a question about facets and doing some filtering based on facets.
>>>
>>> In the moment I am using hibernate search in combination with bobobrowse
>>> for facetting and I am thinking about switching to ES. But before that I
>>> would like to check whether I can still get the same functionality.
>>>
>>> lets asume that I have an index about cars and some facets -- eg. model
>>> and color.
>>>
>>> color
>>> [ ] red (10)
>>> [ ] blue (5)
>>> [ ] green (2)
>>>
>>> model
>>> [ ] bmw (4)
>>> [ ] vw (5)
>>> [ ] ford (8)
>>>
>>> if I select a model I would like to get only color facets for that
>>> model, but I still would like to get facets for all models. eg:
>>>
>>> color
>>> [ ] red (2)
>>> [ ] blue (2)
>>> [ ] green (1)
>>>
>>> model
>>> [ ] bmw (4)
>>> [x] vw (5)
>>> [ ] ford (8)
>>>
>>> I have searched I did not find an example about this usecase. Is this
>>> possible and if yes, how do I filter a query to get these results?
>>>
>>> Kind regards
>>>
>>>
>>>
>>>  --
>>> 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 elasticsearc...@googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/elasticsearch/9d1f3008-aff2-4936-8e6c-7611734e7418%
>>> 40googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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/2609a3ee-1124-4bc1-95e6-c6e7cdb06128%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%3DcQC1i0wUL2gMVEt37PdZLNZXyTi7PTNGKUzDedR6Gpx-5w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to