@@ -8,9 +8,9 @@ Returns search hits that match the query defined in the request.
8
8
9
9
[source,console]
10
10
----
11
- GET /twitter /_search
11
+ GET /my-index-000001 /_search
12
12
----
13
- // TEST[setup:twitter ]
13
+ // TEST[setup:my_index ]
14
14
15
15
[[search-search-api-request]]
16
16
==== {api-request-title}
@@ -594,9 +594,9 @@ Key is the field name. Value is the value for the field.
594
594
595
595
[source,console]
596
596
----
597
- GET /twitter /_search?q=user:kimchy
597
+ GET /my-index-000001 /_search?q=user.id :kimchy
598
598
----
599
- // TEST[continued ]
599
+ // TEST[setup:my_index ]
600
600
601
601
The API returns the following response:
602
602
@@ -619,14 +619,28 @@ The API returns the following response:
619
619
"max_score": 1.3862942,
620
620
"hits": [
621
621
{
622
- "_index": "twitter ",
622
+ "_index": "my-index-000001 ",
623
623
"_id": "0",
624
624
"_score": 1.3862942,
625
625
"_source": {
626
- "date": "2009-11-15T14:12:12",
627
- "likes": 0,
628
- "message": "trying out Elasticsearch",
629
- "user": "kimchy"
626
+ "@timestamp": "2099-11-15T14:12:12",
627
+ "http": {
628
+ "request": {
629
+ "method": "get"
630
+ },
631
+ "response": {
632
+ "status_code": 200,
633
+ "bytes": 1070000
634
+ },
635
+ "version": "1.1"
636
+ },
637
+ "source": {
638
+ "ip": "127.0.0.1"
639
+ },
640
+ "message": "GET /search HTTP/1.1 200 1070000",
641
+ "user": {
642
+ "id": "kimchy"
643
+ }
630
644
}
631
645
}
632
646
]
@@ -640,9 +654,10 @@ The API returns the following response:
640
654
641
655
[source,console]
642
656
----
643
- GET /kimchy,elasticsearch /_search?q=user:kimchy
657
+ GET /my-index-000001,my-index-000002 /_search?q=user.id :kimchy
644
658
----
645
- // TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
659
+ // TEST[setup:my_index]
660
+ // TEST[s/^/PUT my-index-000002\n/]
646
661
647
662
[[search-api-all-ex]]
648
663
===== Search a cluster using the `q` query parameter
@@ -652,47 +667,47 @@ omit the `<target>` parameter.
652
667
653
668
[source,console]
654
669
----
655
- GET /_search?q=user:kimchy
670
+ GET /_search?q=user.id :kimchy
656
671
----
657
- // TEST[continued ]
672
+ // TEST[setup:my_index ]
658
673
659
674
Alternatively,
660
675
you can use the `_all` or `*` value in the `<target>` parameter.
661
676
662
677
[source,console]
663
678
----
664
- GET /_all/_search?q=user:kimchy
679
+ GET /_all/_search?q=user.id :kimchy
665
680
----
666
- // TEST[continued ]
681
+ // TEST[setup:my_index ]
667
682
668
683
[source,console]
669
684
----
670
- GET /*/_search?q=user:kimchy
685
+ GET /*/_search?q=user.id :kimchy
671
686
----
672
- // TEST[continued ]
687
+ // TEST[setup:my_index ]
673
688
674
689
[[search-request-body-api-example]]
675
690
===== Search using the `query` request body parameter
676
691
677
692
[source,console]
678
- --------------------------------------------------
679
- GET /twitter /_search
693
+ ----
694
+ GET /my-index-000001 /_search
680
695
{
681
696
"query": {
682
697
"term": {
683
- "user": "kimchy"
698
+ "user.id ": "kimchy"
684
699
}
685
700
}
686
701
}
687
- --------------------------------------------------
688
- // TEST[setup:twitter ]
702
+ ----
703
+ // TEST[setup:my_index ]
689
704
690
705
The API returns the following response:
691
706
692
707
[source,console-result]
693
- --------------------------------------------------
708
+ ----
694
709
{
695
- "took": 1 ,
710
+ "took": 5 ,
696
711
"timed_out": false,
697
712
"_shards": {
698
713
"total": 1,
@@ -708,18 +723,32 @@ The API returns the following response:
708
723
"max_score": 1.3862942,
709
724
"hits": [
710
725
{
711
- "_index": "twitter ",
726
+ "_index": "my-index-000001 ",
712
727
"_id": "0",
713
728
"_score": 1.3862942,
714
729
"_source": {
715
- "user": "kimchy",
716
- "message": "trying out Elasticsearch",
717
- "date": "2009-11-15T14:12:12",
718
- "likes": 0
730
+ "@timestamp": "2099-11-15T14:12:12",
731
+ "http": {
732
+ "request": {
733
+ "method": "get"
734
+ },
735
+ "response": {
736
+ "status_code": 200,
737
+ "bytes": 1070000
738
+ },
739
+ "version": "1.1"
740
+ },
741
+ "source": {
742
+ "ip": "127.0.0.1"
743
+ },
744
+ "message": "GET /search HTTP/1.1 200 1070000",
745
+ "user": {
746
+ "id": "kimchy"
747
+ }
719
748
}
720
749
}
721
750
]
722
751
}
723
752
}
724
- --------------------------------------------------
725
- // TESTRESPONSE[s/"took": 1 /"took": $body.took/]
753
+ ----
754
+ // TESTRESPONSE[s/"took": 5 /"took": $body.took/]
0 commit comments