This is what I'm trying to do, taking the example from http://www.elasticsearch.org/guide/reference/api/search/facets/
Imagine that the Tags are on a separate type, not on the same article
type.
You know which tags go to which article because both article and the
corresponding tags have the same _id value.
Now I can search across both types (in my real app I have 6 types in
my search), by just omitting the type on the query url, but using
facets, I only get values matching the type that returns values.
What I mean is that if the query term is just a tag, the facet will
return just information from the tags type, not from the articles
type. Is there a way to get facet values from "all" types?
In other words, looking at the example from the site, you search for
"T*" and still get facet values for the tags, even though the tags are
not on the Article type.
This is what I'm trying to do, taking the example from Elasticsearch Platform — Find real-time answers at scale | Elastic
Imagine that the Tags are on a separate type, not on the same article
type.
You know which tags go to which article because both article and the
corresponding tags have the same _id value.
Now I can search across both types (in my real app I have 6 types in
my search), by just omitting the type on the query url, but using
facets, I only get values matching the type that returns values.
What I mean is that if the query term is just a tag, the facet will
return just information from the tags type, not from the articles
type. Is there a way to get facet values from "all" types?
In other words, looking at the example from the site, you search for
"T*" and still get facet values for the tags, even though the tags are
not on the Article type.
This is what I'm trying to do, taking the example from Elasticsearch Platform — Find real-time answers at scale | Elastic
Imagine that the Tags are on a separate type, not on the same article
type.
You know which tags go to which article because both article and the
corresponding tags have the same _id value.
Now I can search across both types (in my real app I have 6 types in
my search), by just omitting the type on the query url, but using
facets, I only get values matching the type that returns values.
What I mean is that if the query term is just a tag, the facet will
return just information from the tags type, not from the articles
type. Is there a way to get facet values from "all" types?
In other words, looking at the example from the site, you search for
"T*" and still get facet values for the tags, even though the tags are
not on the Article type.
The facet area is empty, I understand why it is empty, but I was
looking for a way around it, because in my use case, I know how the
articles and tags are related (using the id of each document type)
One way around it is by adding a __id field to each document on
articles and tags that has the same document id. I then do a regular
search not asking for the facets, just the articles with title of T*,
then I parse the _id fields of those results, and query the index
again, but this time looking for the _id values on the manually
updated __id fields (using the default OR operator) and this time
asking for a facet. This works, but I wonder if there is a cleaner
way.
This is what I'm trying to do, taking the example from Elasticsearch Platform — Find real-time answers at scale | Elastic
Imagine that the Tags are on a separate type, not on the same article
type.
You know which tags go to which article because both article and the
corresponding tags have the same _id value.
Now I can search across both types (in my real app I have 6 types in
my search), by just omitting the type on the query url, but using
facets, I only get values matching the type that returns values.
What I mean is that if the query term is just a tag, the facet will
return just information from the tags type, not from the articles
type. Is there a way to get facet values from "all" types?
In other words, looking at the example from the site, you search for
"T*" and still get facet values for the tags, even though the tags are
not on the Article type.
Now I can search across both types (in my real app I have 6 types in
my search), by just omitting the type on the query url, but using
facets, I only get values matching the type that returns values.
What I mean is that if the query term is just a tag, the facet will
return just information from the tags type, not from the articles
type. Is there a way to get facet values from "all" types?
The search API accepts a 'query' and a 'filter'.
The facets are calculated on the results of the 'query'. The top-level
'filter' parameter allows you to post-process the query results, after
the facets are calculated.
So if you run your query across both types (tags and articles), then you
set the filter to
{ "type": { "value": "articles" }}
... then your final result set should just include the articles, but
your facets should take the tags into account
Thanks Clint, maybe I didn't fully understand your answer, but I
didn't get it to work.
These are the steps I'm doing:
Create data:
Search using filter:
Desired output:
Thanks
Diego
The search API accepts a 'query' and a 'filter'.
The facets are calculated on the results of the 'query'. The top-level
'filter' parameter allows you to post-process the query results, after
the facets are calculated.
So if you run your query across both types (tags and articles), then you
set the filter to
{ "type": { "value": "articles" }}
... then your final result set should just include the articles, but
your facets should take the tags into account
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.