Guest User

query books script

a guest
Mar 21st, 2013
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.15 KB | None | 0 0
  1. curl -XPUT localhost:9200/authors/bare_author/1 -d'{
  2.  "name": "Multi G. Enre"
  3. }'
  4.  
  5. curl -XPUT localhost:9200/authors/bare_author/2 -d'{
  6.  "name": "Alastair Reynolds"
  7. }'
  8.  
  9. curl -XPOST localhost:9200/authors/book/_mapping -d '{
  10.  "book":{
  11.    "_parent": {"type": "bare_author"}
  12.  }
  13. }'
  14.  
  15. curl -XPOST localhost:9200/authors/book/1?parent=2 -d '{
  16.   "name": "Revelation Space",
  17.   "genre": "scifi",
  18.   "publisher": "penguin"
  19. }'
  20.  
  21. curl -XPOST localhost:9200/authors/book/2?parent=1 -d '{
  22.   "name": "Guns and lasers",
  23.   "genre": "scifi",
  24.   "publisher": "orbit"
  25. }'
  26.  
  27. curl -XPOST localhost:9200/authors/book/3?parent=1 -d '{
  28.   "name": "Dead in the night",
  29.   "genre": "thriller",
  30.   "publisher": "penguin"
  31. }'
  32.  
  33. # just a query to test that the authors term query is working
  34. curl -XPOST localhost:9200/authors/bare_author/_search?pretty=true -d'{
  35.     "query": {
  36.         "term" : {
  37.             "name" : "enre"
  38.         }
  39.     }
  40. }'
  41.  
  42. # the has_parent query with the same query
  43. curl -XPOST localhost:9200/authors/books/_search?pretty=true -d'{
  44.     "query": {
  45.         "has_parent": {
  46.             "parent_type" : "bare_author",
  47.             "query" : {
  48.                 "term" : { "name" : "enre" }
  49.             }
  50.         }
  51.     }
  52. }'
Advertisement
Add Comment
Please, Sign In to add comment