Elasticsearch Developer Cheat Sheet PDF
Elasticsearch Developer Cheat Sheet PDF
Elasticsearch, Kibana, Logstash, and Beats are trademarks of Elasticsearch BV, registered in the U.S. and in other countries.
Sematext Group, Inc. is not affiliated with Elasticsearch BV.
Elasticsearch Developer Cheat Sheet
Solr &Elasticsearch Consulting. Training. Support.
Grouping by nesting aggregations Queries (and aggregations) need to be aware of this and do the join:
The following gets the top results, ordered by _score, grouped by the value of bar (one hit per "query": {
value). "nested": {
"query": { "path": "authors",
"match": { "query": {
"foo": "f sh" "match": {
} "authors.f rst_name": "Jane"
}, }
"size": 0, }
"aggs": { }
"most_foo": { }
"terms": {
"f eld": "bar.keyword", Parent-child
"order": { When updates are frequent and you want to avoid reindexing the whole ensemble (as you
"max_score": "desc" would with nested documents). These are completely separate documents, going in different
} types:
}, "mappings": {
"aggs": { "authors": {
"max_score": { "_parent": {
"max": { "type": "posts"
"script": { }
"inline": "_score" }
} }
}
}, Children point to parents via the _parent field:
"top_hit": { curl -XPOST localhost:9200/blog/posts/1 -d '{
"top_hits": { "title": "Fish & Chips"
"size": 1 }'
}
} curl -XPOST localhost:9200/blog/authors?parent=1 -d '{
} "f rst_name": "John",
} "last_name": "Smith"
} }'
Like with nested documents, the query has to specify that a join needs to be done:
"query": {
"has_child": {
"type": "authors",
"query": {
"match": {
"f rst_name": "Jane"
}
}
}
}
Elasticsearch, Kibana, Logstash, and Beats are trademarks of Elasticsearch BV, registered in the U.S. and in other countries.
Sematext Group, Inc. is not affiliated with Elasticsearch BV.