has-parent-query.asciidoc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  24. supported score types are `score` or `none`. The default is `none` and
  25. this ignores the score from the parent document. The score is in this
  26. case equal to the boost on the `has_parent` query (Defaults to 1). If
  27. the score type is set to `score`, then the score of the matching parent
  28. document is aggregated into the child documents belonging to the
  29. matching parent document. The score type can be specified with the
  30. `score_mode` field inside the `has_parent` query:
  31. [source,js]
  32. --------------------------------------------------
  33. {
  34. "has_parent" : {
  35. "parent_type" : "blog",
  36. "score_mode" : "score",
  37. "query" : {
  38. "term" : {
  39. "tag" : "something"
  40. }
  41. }
  42. }
  43. }
  44. --------------------------------------------------