Guest User

Untitled

a guest
Jan 16th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. PUT my_index
  2. {
  3. "mappings": {
  4. "my_parent": {},
  5. "my_child": {
  6. "_parent": {
  7. "type": "my_parent"
  8. }
  9. }
  10. }
  11. }
  12.  
  13. PUT my_index/my_parent/1
  14. {
  15. "text": "This is a parent document"
  16. }
  17.  
  18. PUT my_index/my_child/2?parent=1
  19. {
  20. "text": "This is a child document"
  21. }
  22.  
  23. PUT my_index/my_child/3?parent=1&refresh=true
  24. {
  25. "text": "This is another child document"
  26. }
  27.  
  28. GET my_index/my_parent/_search
  29. {
  30. "query": {
  31. "has_child": {
  32. "type": "my_child",
  33. "query": {
  34. "match": {
  35. "text": "child document"
  36. }
  37. }
  38. }
  39. }
  40. }
  41.  
  42. GET my_index/my_child/_search
  43. {
  44. "query": {
  45. "has_parent": {
  46. "parent_type": "my_parent",
  47. "query": {
  48. "match": {
  49. "text": "parent"
  50. }
  51. }
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment