ElasticSearch nested query filters and dynamic data ElasticSearch nested query filters and dynamic data elasticsearch elasticsearch

ElasticSearch nested query filters and dynamic data


The mapping you get back from elasticsearch doesn't show your "fields" and "variations" nodes as nested. Make sure you put the mapping before indexing anything into this type. Delete the index, create the index with the correct mapping and only then index your objects.

Edit

After looking at your updated info, maybe the empty range filter you have on your original query is what is filtering out all results?
Also - your "fields" field is also supposed to be nested, is it really? You query doesn't treat it as nested.


I think you need to set the nested fields as type nested, like this:

{   "products":{      "product":{         "properties":{            "_advertiser_id":{               "type":"long"            },            "advertiser":{               "type":"string"            },            "category":{               "type":"string"            },            "created_at":{               "type":"date",               "format":"dateOptionalTime"            },            "description":{               "type":"string"            },            "fields":{               "type" : "nested",               "properties":{                  "gender":{                     "type":"string"                  },                  "short_type":{                     "type":"string"                  }               }            },            "id":{               "type":"string"            },            "images":{               "type" : "nested",               "properties":{                  "id":{                     "type":"string"                  },                  "url":{                     "type":"string"                  }               }            },            "name":{               "type":"string"            },            "price":{               "type":"double"            },            "product_type":{               "type":"string"            },            "updated_at":{               "type":"date",               "format":"dateOptionalTime"            },            "variations":{               "type" : "nested",                "properties":{                  "colour":{                     "type":"string"                  },                  "female_tops":{                     "type":"string"                  },                  "image":{                     "type":"string"                  },                  "length":{                     "type":"string"                  },                  "size":{                     "type":"string"                  },                  "sleeve_length":{                     "type":"string"                  },                  "type":{                     "type":"string"                  },                  "zip_type":{                     "type":"string"                  }               }            }         }      }   }}