Gist d57b4594607d7185a88e
✓ Published0🌍 Public
CCBasis
Last edited Feb 29, 2012
Created on Sep 17, 2014
This example demonstrates parent-child relationships in Elasticsearch by indexing stores, departments, and products as nested document types. It shows how to query hierarchical data using the `has_child` filter to find stores containing departments whose products match a specific trademark. The code uses Elasticsearch’s REST API with `curl` commands to define mappings, index sample data, and execute filtered queries. It illustrates the `_parent` field for linking document types and `_routing` to enforce shard placement, while the final search combines term queries with nested `has_child` filters to retrieve relevant parent documents.
AI-generated description