search.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [[search-search]]
  2. == Search
  3. The search API allows to execute a search query and get back search hits
  4. that match the query. The query can either be provided using a simple
  5. <<search-uri-request,query string as a parameter>>, or using a
  6. <<search-request-body,request body>>.
  7. ["float",id="search-multi-index-type"]
  8. === Multi-Index, Multi-Type
  9. All search APIs can be applied across multiple types within an index, and
  10. across multiple indices with support for the
  11. <<multi-index,multi index syntax>>. For
  12. example, we can search on all documents across all types within the
  13. twitter index:
  14. [source,js]
  15. --------------------------------------------------
  16. $ curl -XGET 'http://localhost:9200/twitter/_search?q=user:kimchy'
  17. --------------------------------------------------
  18. We can also search within specific types:
  19. [source,js]
  20. --------------------------------------------------
  21. $ curl -XGET 'http://localhost:9200/twitter/tweet,user/_search?q=user:kimchy'
  22. --------------------------------------------------
  23. We can also search all tweets with a certain tag across several indices
  24. (for example, when each user has his own index):
  25. [source,js]
  26. --------------------------------------------------
  27. $ curl -XGET 'http://localhost:9200/kimchy,elasticsearch/tweet/_search?q=tag:wow'
  28. --------------------------------------------------
  29. Or we can search all tweets across all available indices using `_all`
  30. placeholder:
  31. [source,js]
  32. --------------------------------------------------
  33. $ curl -XGET 'http://localhost:9200/_all/tweet/_search?q=tag:wow'
  34. --------------------------------------------------
  35. Or even search across all indices and all types:
  36. [source,js]
  37. --------------------------------------------------
  38. $ curl -XGET 'http://localhost:9200/_search?q=tag:wow'
  39. --------------------------------------------------