Advertisement
saxxi

elasticsearch attempt to grouping

Aug 28th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. curl -X DELETE "http://localhost:9200/articles"
  2.  
  3. curl -X PUT "http://localhost:9200/articles" -d '{
  4. "settings": {
  5. "index": {
  6. "number_of_shards": 1, "number_of_replicas": 0
  7. }
  8. }
  9. }'
  10.  
  11. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 111, "owner": ["user_1"], "title": "One bad doc" }'
  12. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 222, "owner": ["user_2"], "title": "Two bad doc" }'
  13. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 333, "owner": ["user_3"], "title": "Three good doc" }'
  14.  
  15. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 444, "owner": ["user_1"], "title": "Four good doc" }'
  16. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 555, "owner": ["user_2"], "title": "Five good doc" }'
  17. curl -X POST "http://localhost:9200/articles/article" -d '{ "id": 666, "owner": ["user_1"], "title": "Six good doc" }'
  18.  
  19.  
  20. curl -XPOST 'http://localhost:9200/articles/_refresh'
  21.  
  22. curl -X POST "http://localhost:9200/articles/_search?pretty=true" -d '{
  23. "query": {
  24. "bool":{
  25. "must":[{ "query_string":{ "query":"doc", "default_operator":"AND" } }],
  26. "should":[{ "query_string":{ "query":"user_2", "default_operator":"AND", "boost":2000 } }]
  27. }
  28. },
  29.  
  30. "facets": {
  31. "tags": { "terms": {"field": "owner", "size": 10} }
  32. }
  33.  
  34. }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement