File: search.asciidoc

package info (click to toggle)
elasticsearch 1.0.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 37,220 kB
  • sloc: java: 365,486; xml: 1,258; sh: 714; python: 505; ruby: 354; perl: 134; makefile: 41
file content (52 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[[search-search]]
== Search

The search API allows to execute a search query and get back search hits
that match the query. The query can either be provided using a simple
<<search-uri-request,query string as a parameter>>, or using a
<<search-request-body,request body>>.

["float",id="search-multi-index-type"]
=== Multi-Index, Multi-Type

All search APIs can be applied across multiple types within an index, and
across multiple indices with support for the
<<multi-index,multi index syntax>>. For
example, we can search on all documents across all types within the
twitter index:

[source,js]
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/twitter/_search?q=user:kimchy'
--------------------------------------------------

We can also search within specific types:

[source,js]
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/twitter/tweet,user/_search?q=user:kimchy'
--------------------------------------------------

We can also search all tweets with a certain tag across several indices
(for example, when each user has his own index):

[source,js]
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/kimchy,elasticsearch/tweet/_search?q=tag:wow'
--------------------------------------------------

Or we can search all tweets across all available indices using `_all`
placeholder:

[source,js]
--------------------------------------------------
$ curl - XGET 'http://localhost:9200/_all/tweet/_search?q=tag:wow'
--------------------------------------------------

Or even search across all indices and all types:

[source,js]
--------------------------------------------------
$ curl -XGET 'http://localhost:9200/_search?q=tag:wow'
--------------------------------------------------