Skip to content

Commit ba736bb

Browse files
authored
[DOC-12253] Add Search Response Examples (#296)
* [DOC-12253] Add vector search response examples * [DOC-12253] Adding examples for regular search indexes and updating GeoSpatial/GeoJSON directions to include adding example data + example responses everywhere
1 parent 3809989 commit ba736bb

14 files changed

+479
-14
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"status": "ok",
3+
"name": "travel-sample.inventory.landmark-content-index",
4+
"uuid": "49563a96ea6d3686"
5+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"status": {
3+
"total": 1,
4+
"failed": 0,
5+
"successful": 1
6+
},
7+
"hits": [
8+
{
9+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
10+
"id": "landmark_40010",
11+
"score": 0.1332053777355554,
12+
"sort": [
13+
"_score"
14+
],
15+
"partial_match": true
16+
},
17+
{
18+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
19+
"id": "landmark_40011",
20+
"score": 0.1332053777355554,
21+
"sort": [
22+
"_score"
23+
],
24+
"partial_match": true
25+
},
26+
{
27+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
28+
"id": "landmark_554",
29+
"score": 0.016920542554627847,
30+
"sort": [
31+
"_score"
32+
],
33+
"partial_match": true
34+
},
35+
{
36+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
37+
"id": "landmark_11323",
38+
"score": 0.016920542554627847,
39+
"sort": [
40+
"_score"
41+
],
42+
"partial_match": true
43+
},
44+
{
45+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
46+
"id": "landmark_37316",
47+
"score": 0.016920542554627847,
48+
"sort": [
49+
"_score"
50+
],
51+
"partial_match": true
52+
},
53+
{
54+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
55+
"id": "landmark_581",
56+
"score": 0.016920542554627847,
57+
"sort": [
58+
"_score"
59+
],
60+
"partial_match": true
61+
},
62+
{
63+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
64+
"id": "landmark_15903",
65+
"score": 0.016920542554627847,
66+
"sort": [
67+
"_score"
68+
],
69+
"partial_match": true
70+
},
71+
{
72+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
73+
"id": "landmark_570",
74+
"score": 0.016920542554627847,
75+
"sort": [
76+
"_score"
77+
],
78+
"partial_match": true
79+
},
80+
{
81+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
82+
"id": "landmark_566",
83+
"score": 0.016920542554627847,
84+
"sort": [
85+
"_score"
86+
],
87+
"partial_match": true
88+
},
89+
{
90+
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
91+
"id": "landmark_22565",
92+
"score": 0.016920542554627847,
93+
"sort": [
94+
"_score"
95+
],
96+
"partial_match": true
97+
}
98+
],
99+
"total_hits": 257,
100+
"cost": 35339,
101+
"max_score": 0.1332053777355554,
102+
"took": 10019436,
103+
"facets": null
104+
}

modules/search/examples/geospatial-search-query-geojson.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,45 @@ curl -s -XPUT -H "Content-Type: application/json" \
55
"field": "geojson",
66
"geometry": {
77
"shape": {
8-
"type": "Polygon",
98
"coordinates": [
9+
[
1010
[
11+
-3.272607322511618,
12+
53.94443025530833
13+
],
1114
[
12-
0.47482593026924746,
13-
51.31232878073189
15+
-3.369506040138134,
16+
53.2576036482846
1417
],
1518
[
16-
0.6143265647863245,
17-
51.31232878073189
19+
-1.531900030030954,
20+
53.352538254565076
1821
],
1922
[
20-
0.6143265647863245,
21-
51.384000374770466
23+
-0.08209172686298416,
24+
53.568703110993994
2225
],
2326
[
24-
0.47482593026924746,
25-
51.384000374770466
27+
-0.4648577685729265,
28+
53.86797332814126
2629
],
2730
[
28-
0.47482593026924746,
29-
51.31232878073189
30-
]
31+
-1.612712602375666,
32+
54.022352820673774
33+
],
34+
[
35+
-2.2803785770867933,
36+
54.05470383755585
37+
],
38+
[
39+
-3.272607322511618,
40+
53.94443025530833
3141
]
3242
]
43+
],
44+
"type": "Polygon"
3345
},
3446
"relation": "within"
3547
}
3648
}
37-
}
49+
}'
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"status": {
3+
"total": 1,
4+
"failed": 0,
5+
"successful": 1
6+
},
7+
"hits": [
8+
{
9+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
10+
"id": "landmark_17411",
11+
"score": 0.009274733001968816,
12+
"sort": [
13+
" \u0001?E#9\u003eN\u000c\"e"
14+
],
15+
"partial_match": true
16+
},
17+
{
18+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
19+
"id": "landmark_17409",
20+
"score": 0.009274733001968816,
21+
"sort": [
22+
" \u0001?O~i*(kD,"
23+
],
24+
"partial_match": true
25+
},
26+
{
27+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
28+
"id": "landmark_17403",
29+
"score": 0.009274733001968816,
30+
"sort": [
31+
" \u0001?Sg*|/t\u001f\u0002"
32+
],
33+
"partial_match": true
34+
},
35+
{
36+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
37+
"id": "landmark_17410",
38+
"score": 0.009274733001968816,
39+
"sort": [
40+
" \u0001?Z3T6 \u0010\u0019@"
41+
],
42+
"partial_match": true
43+
},
44+
{
45+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
46+
"id": "landmark_17412",
47+
"score": 0.009274733001968816,
48+
"sort": [
49+
" \u0001?]-\u000fm?\u000b\u0014#"
50+
],
51+
"partial_match": true
52+
},
53+
{
54+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
55+
"id": "landmark_17408",
56+
"score": 0.009274733001968816,
57+
"sort": [
58+
" \u0001?^DV7\u0014t:^"
59+
],
60+
"partial_match": true
61+
},
62+
{
63+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
64+
"id": "landmark_17406",
65+
"score": 0.009274733001968816,
66+
"sort": [
67+
" \u0001?_\u003c\u00009\u001eW\u0013\u0012"
68+
],
69+
"partial_match": true
70+
},
71+
{
72+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
73+
"id": "landmark_17397",
74+
"score": 0.009274733001968816,
75+
"sort": [
76+
" \u0001?c\u001cx\u0010n\u0016Wl"
77+
],
78+
"partial_match": true
79+
},
80+
{
81+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
82+
"id": "landmark_17407",
83+
"score": 0.009274733001968816,
84+
"sort": [
85+
" \u0001?c!7\u0001@SwS"
86+
],
87+
"partial_match": true
88+
},
89+
{
90+
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
91+
"id": "landmark_17391",
92+
"score": 0.009274733001968816,
93+
"sort": [
94+
" \u0001?dgzZ[\u0007;y"
95+
],
96+
"partial_match": true
97+
}
98+
],
99+
"total_hits": 640,
100+
"cost": 157249,
101+
"max_score": 0.17106779096990765,
102+
"took": 15349178,
103+
"facets": null
104+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
UPDATE `travel-sample`.inventory.landmark
2+
SET geojson = { "type": "Point", "coordinates": [geo.lon, geo.lat] }
3+
WHERE geo IS NOT null;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"status": {
3+
"total": 1,
4+
"failed": 0,
5+
"successful": 1
6+
},
7+
"hits": [
8+
{
9+
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
10+
"id": "landmark_4428",
11+
"score": 2.425509689250102,
12+
"sort": [
13+
"_score"
14+
],
15+
"fields": {
16+
"content": "serves fresh food at very reasonable prices - view of stoney beach with herons"
17+
}
18+
},
19+
{
20+
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
21+
"id": "landmark_26385",
22+
"score": 1.6270812956011347,
23+
"sort": [
24+
"_score"
25+
],
26+
"fields": {
27+
"content": "Burgers, seafood, and other simple but tasty meals right at the harbor. You can take your food around the corner to sit on the beach or the sea wall and enjoy the ocean view while you eat."
28+
}
29+
},
30+
{
31+
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
32+
"id": "landmark_38035",
33+
"score": 1.1962539437368078,
34+
"sort": [
35+
"_score"
36+
],
37+
"fields": {
38+
"content": "Famous for "the Blue Lady", a ghost rumored to haunt the premises, the Moss Beach distillery offers a full menu, Sunday brunch, drinks, and a tremendous ocean view with comfortable fire pits. Happy hour Mon-Fri from 5PM to 7PM offers half-priced drinks and a discounted food menu."
39+
}
40+
}
41+
],
42+
"total_hits": 3,
43+
"cost": 150479,
44+
"max_score": 2.425509689250102,
45+
"took": 1441203,
46+
"facets": null
47+
}

modules/search/pages/create-search-index-rest-api.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ IMPORTANT: XATTRs mappings are only available in Couchbase Server version 7.6.2
6969

7070
For more information about the available JSON properties for a Search index, see xref:search-index-params.adoc[].
7171

72+
If the REST API call is successful, the Search Service returns a `200 OK` and the following JSON response:
73+
74+
[source,json]
75+
----
76+
include::example$create-search-index-response.json[]
77+
----
78+
79+
The `"uuid"` is randomly generated for each Search index you create.
80+
Your own UUID might not match the value shown in the example.
81+
7282
== Next Steps
7383

7484
After you create a Search index, you can xref:simple-search-rest-api.adoc[] to test your Search index.

modules/search/pages/geo-search-rest-api.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,41 @@ For example, the following query searches a geospatial field, `geo`, for any loc
7575
include::example$geospatial-search-query.sh[]
7676
----
7777

78+
If the REST API call is successful, the Search Service returns a `200 OK`.
79+
Using the `landmark` collection, the query can return the following JSON response:
80+
81+
[source,json]
82+
----
83+
include::example$geospatial-search-response.json[]
84+
----
85+
7886
=== Example: GeoJSON Query
7987

88+
[TIP]
89+
====
90+
To run the following example against the `landmark` collection in the `travel-sample` dataset, run the following {sqlpp} query from the xref:tools:query-workbench.adoc[Query Workbench]:
91+
92+
[source,sqlpp]
93+
----
94+
include::example$geospatial-sqlpp-query.sqlpp[]
95+
----
96+
====
97+
8098
For example, the following query searches a geospatial field, `geojson`, for any locations within a defined shape with a xref:search-request-params.adoc#geojson-queries-polygon[Polygon GeoJSON Query]:
8199

82100
[source,console]
83101
----
84102
include::example$geospatial-search-query-geojson.sh[]
85103
----
86104

105+
If the REST API call is successful, the Search Service returns a `200 OK`.
106+
Using the `landmark` collection, the query can return the following JSON response:
107+
108+
[source,json]
109+
----
110+
include::example$geojson-search-response.json[]
111+
----
112+
87113
== Next Steps
88114

89115
You can xref:customize-index.adoc[customize your Search index] to improve search results and performance.

0 commit comments

Comments
 (0)