I'd like to inspect the _mapping of given a specific field/value in an ES
index of a specific type. The way we set up our data (due to design of
nesting/parent-child relationships) was to put them all under one type,
then have a subType field. Unfortunately, as data is indexed and the
_mapping schema dynamically builds out, the _mapping shows all the possible
fields of that type, and I can't query or filter the _mapping. This makes
sense (_mapping is more of a config schema file per se, not a search API as
I understand it), but is there any workaround that could give us the
desired result? Here is an example:
index: Farm
type: Animal
So localhost:9200/Farm/Animal/_mapping retrieves the mapping. But in our
data we have a field animalType. I want to get the 'populated' fields, i.e.
the dynamically built mappings file, but only when animalType is Cow, for
instance.
A clear workaround is to redesign our data and index to look like
/Farm/Cow, /Farm/Sheep, in which case /Farm/Cow/_mapping would return the
desired fields for the Cow type. But that disrupts other aspects of our
data design due for maintaining parent-children.
Is it possible to query/generate a field list when we have Farm/Animal and
animalType is Cow, without scanning all data? Sort of like a facets query,
where the facet is on the field names (instead of a specific field), the
counts being how often they are used! It would be like faceting on the
schema, if it were searchable. Sorry if that's confusing!
On the top of my head I do not think that this is possible. The reason for
this is, that the type is just another metadata field in the data
structure, which is used to store the indexed documents. On that level we
do not have any type information, as all documents regardless of its type
of an index are stored in that data structure.
I also dont have any awesome idea to work around that at the moment.
I'd like to inspect the _mapping of given a specific field/value in an ES
index of a specific type. The way we set up our data (due to design of
nesting/parent-child relationships) was to put them all under one type,
then have a subType field. Unfortunately, as data is indexed and the
_mapping schema dynamically builds out, the _mapping shows all the possible
fields of that type, and I can't query or filter the _mapping. This makes
sense (_mapping is more of a config schema file per se, not a search API as
I understand it), but is there any workaround that could give us the
desired result? Here is an example:
index: Farm
type: Animal
So localhost:9200/Farm/Animal/_mapping retrieves the mapping. But in our
data we have a field animalType. I want to get the 'populated' fields, i.e.
the dynamically built mappings file, but only when animalType is Cow, for
instance.
A clear workaround is to redesign our data and index to look like
/Farm/Cow, /Farm/Sheep, in which case /Farm/Cow/_mapping would return the
desired fields for the Cow type. But that disrupts other aspects of our
data design due for maintaining parent-children.
Is it possible to query/generate a field list when we have Farm/Animal and
animalType is Cow, without scanning all data? Sort of like a facets query,
where the facet is on the field names (instead of a specific field), the
counts being how often they are used! It would be like faceting on the
schema, if it were searchable. Sorry if that's confusing!
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.