I am currently using this mapping for indexing it in elastic-search:
{
"product": {
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"variations": {
"type": "nested",
"properties": {
"sku": {"type": "string"},
"price": {"type": "float"},
"attributes" : {
"type": "object"
}
}
}
}
}
}
Is this the correct way to map it, and if yes, how can I query for example
all the products that have at least one variation with price 10.15 and
colour blue?
With inner dccuments, you cannot query two different attributes for the
same inner object. Internally, Elasticsearch/Lucene will flatten all the
inner properties into one array. You would need to switch to nested
documents or even parent/child documents in order to query on a single
deeper document. Searching the mailing list/web will find lots of examples.
Here are a couple:
I am currently using this mapping for indexing it in elastic-search:
{
"product": {
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"variations": {
"type": "nested",
"properties": {
"sku": {"type": "string"},
"price": {"type": "float"},
"attributes" : {
"type": "object"
}
}
}
}
}
}
Is this the correct way to map it, and if yes, how can I query for example
all the products that have at least one variation with price 10.15 and
colour blue?
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.