has-parent-query.asciidoc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. [[query-dsl-has-parent-query]]
  2. === Has Parent Query
  3. The `has_parent` query works the same as the
  4. <<query-dsl-has-parent-filter,has_parent>>
  5. filter, by automatically wrapping the filter with a constant_score (when
  6. using the default score type). It has the same syntax as the
  7. <<query-dsl-has-parent-filter,has_parent>>
  8. filter.
  9. [source,js]
  10. --------------------------------------------------
  11. {
  12. "has_parent" : {
  13. "parent_type" : "blog",
  14. "query" : {
  15. "term" : {
  16. "tag" : "something"
  17. }
  18. }
  19. }
  20. }
  21. --------------------------------------------------
  22. [float]
  23. ==== Scoring capabilities
  24. The `has_parent` also has scoring support. The
  25. supported score types are `score` or `none`. The default is `none` and
  26. this ignores the score from the parent document. The score is in this
  27. case equal to the boost on the `has_parent` query (Defaults to 1). If
  28. the score type is set to `score`, then the score of the matching parent
  29. document is aggregated into the child documents belonging to the
  30. matching parent document. The score type can be specified with the
  31. `score_type` field inside the `has_parent` query:
  32. [source,js]
  33. --------------------------------------------------
  34. {
  35. "has_parent" : {
  36. "parent_type" : "blog",
  37. "score_type" : "score",
  38. "query" : {
  39. "term" : {
  40. "tag" : "something"
  41. }
  42. }
  43. }
  44. }
  45. --------------------------------------------------
  46. [float]
  47. ==== Memory Considerations
  48. With the current implementation, all `_id` values are loaded to memory
  49. (heap) in order to support fast lookups, so make sure there is enough
  50. memory for it.