search.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. [[search-search]]
  2. == Search
  3. The search API allows you 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 within the twitter index:
  13. [source,js]
  14. --------------------------------------------------
  15. GET /twitter/_search?q=user:kimchy
  16. --------------------------------------------------
  17. // CONSOLE
  18. // TEST[setup:twitter]
  19. We can also search all tweets with a certain tag across several indices
  20. (for example, when each user has his own index):
  21. [source,js]
  22. --------------------------------------------------
  23. GET /kimchy,elasticsearch/_search?q=tag:wow
  24. --------------------------------------------------
  25. // CONSOLE
  26. // TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
  27. Or we can search all tweets across all available indices using `_all`
  28. placeholder:
  29. [source,js]
  30. --------------------------------------------------
  31. GET /_all/_search?q=tag:wow
  32. --------------------------------------------------
  33. // CONSOLE
  34. // TEST[setup:twitter]
  35. Or even search across all indices and all types:
  36. [source,js]
  37. --------------------------------------------------
  38. GET /_search?q=tag:wow
  39. --------------------------------------------------
  40. // CONSOLE
  41. // TEST[setup:twitter]