In my company we are considering to migrate from SOLR to ES, so I'm looking
if all business criteria can be met with ES without to much of a hassle.
So far I have everything pretty much worked out except for filter exclusion.
Let me give you an example:
I want to filter out documents whose field 'A' is equal to 'a', and I want
to facet the field 'A' at the same time, excluding of course the previous
filter.
I know that you can put the filter 'outside' the query in order to get the
facets without that filter applied, like:
ElasticSearch (mind the minor errors that i could have here)
{
"query : { "match_all" : { } },
"filter" : { "term : { "A" : "a" } },
"facets" : {
"A" : { "terms" : { "field" : "A" } } //this should exclude the filter A:a
}
}
That is, for facet A I want to keep all filters except A:a, for facet B all
except B:b, and so on.
The most obvious way would be to do n queries (one per each of the n
facets), but I'd like to stay away from that.
I think you use the 'facet_filter' for this. Which is described here:
It basically allows you to specify a filter per facet to reduce the
count, so instead of specifying what filters should be excluded, you
specify what filters do apply on a specific facet. This is different
from Solr's excluding facets, but you can basically achieve the
same behavior.
In my company we are considering to migrate from SOLR to ES, so I'm looking
if all business criteria can be met with ES without to much of a hassle.
So far I have everything pretty much worked out except for filter exclusion.
Let me give you an example:
I want to filter out documents whose field 'A' is equal to 'a', and I want
to facet the field 'A' at the same time, excluding of course the previous
filter.
I know that you can put the filter 'outside' the query in order to get the
facets without that filter applied, like:
Elasticsearch (mind the minor errors that i could have here)
{
"query : { "match_all" : { } },
"filter" : { "term : { "A" : "a" } },
"facets" : {
"A" : { "terms" : { "field" : "A" } } //this should exclude the filter A:a
}
}
That is, for facet A I want to keep all filters except A:a, for facet B all
except B:b, and so on.
The most obvious way would be to do n queries (one per each of the n
facets), but I'd like to stay away from that.
It basically allows you to specify a filter per facet to reduce the
count, so instead of specifying what filters should be excluded, you
specify what filters do apply on a specific facet. This is different
from Solr's excluding facets, but you can basically achieve the
same behavior.
In my company we are considering to migrate from SOLR to ES, so I'm
looking
if all business criteria can be met with ES without to much of a hassle.
So far I have everything pretty much worked out except for filter
exclusion.
Let me give you an example:
I want to filter out documents whose field 'A' is equal to 'a', and I
want
to facet the field 'A' at the same time, excluding of course the previous
filter.
I know that you can put the filter 'outside' the query in order to get
the
facets without that filter applied, like:
Elasticsearch (mind the minor errors that i could have here)
{
"query : { "match_all" : { } },
"filter" : { "term : { "A" : "a" } },
"facets" : {
"A" : { "terms" : { "field" : "A" } } //this should exclude the filter
A:a
}
}
That is, for facet A I want to keep all filters except A:a, for facet B
all
except B:b, and so on.
The most obvious way would be to do n queries (one per each of the n
facets), but I'd like to stay away from that.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.