has-parent-query.asciidoc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. [[query-dsl-has-parent-query]]
  2. === Has Parent Query
  3. The `has_parent` query accepts a query and a parent type. The query is
  4. executed in the parent document space, which is specified by the parent
  5. type. This query returns child documents which associated parents have
  6. matched. For the rest `has_parent` query has the same options and works
  7. in the same manner as the `has_child` query.
  8. [source,js]
  9. --------------------------------------------------
  10. {
  11. "has_parent" : {
  12. "parent_type" : "blog",
  13. "query" : {
  14. "term" : {
  15. "tag" : "something"
  16. }
  17. }
  18. }
  19. }
  20. --------------------------------------------------
  21. [float]
  22. ==== Scoring capabilities
  23. The `has_parent` also has scoring support. The default is `false` which
  24. ignores the score from the parent document. The score is in this
  25. case equal to the boost on the `has_parent` query (Defaults to 1). If
  26. the score is set to `true`, then the score of the matching parent
  27. document is aggregated into the child documents belonging to the
  28. matching parent document. The score mode can be specified with the
  29. `score` field inside the `has_parent` query:
  30. [source,js]
  31. --------------------------------------------------
  32. {
  33. "has_parent" : {
  34. "parent_type" : "blog",
  35. "score" : true,
  36. "query" : {
  37. "term" : {
  38. "tag" : "something"
  39. }
  40. }
  41. }
  42. }
  43. --------------------------------------------------
  44. [float]
  45. ==== Ignore Unmapped
  46. When set to `true` the `ignore_unmapped` option will ignore an unmapped `type`
  47. and will not match any documents for this query. This can be useful when
  48. querying multiple indexes which might have different mappings. When set to
  49. `false` (the default value) the query will throw an exception if the `type`
  50. is not mapped.