Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/search/examples/create-search-index-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"status": "ok",
"name": "travel-sample.inventory.landmark-content-index",
"uuid": "49563a96ea6d3686"
}
104 changes: 104 additions & 0 deletions modules/search/examples/geojson-search-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"status": {
"total": 1,
"failed": 0,
"successful": 1
},
"hits": [
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_40010",
"score": 0.1332053777355554,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_40011",
"score": 0.1332053777355554,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_554",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_11323",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_37316",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_581",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_15903",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_570",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_566",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_642c3761fc0a2c73_4c1c5584",
"id": "landmark_22565",
"score": 0.016920542554627847,
"sort": [
"_score"
],
"partial_match": true
}
],
"total_hits": 257,
"cost": 35339,
"max_score": 0.1332053777355554,
"took": 10019436,
"facets": null
}
38 changes: 25 additions & 13 deletions modules/search/examples/geospatial-search-query-geojson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,45 @@ curl -s -XPUT -H "Content-Type: application/json" \
"field": "geojson",
"geometry": {
"shape": {
"type": "Polygon",
"coordinates": [
[
[
-3.272607322511618,
53.94443025530833
],
[
0.47482593026924746,
51.31232878073189
-3.369506040138134,
53.2576036482846
],
[
0.6143265647863245,
51.31232878073189
-1.531900030030954,
53.352538254565076
],
[
0.6143265647863245,
51.384000374770466
-0.08209172686298416,
53.568703110993994
],
[
0.47482593026924746,
51.384000374770466
-0.4648577685729265,
53.86797332814126
],
[
0.47482593026924746,
51.31232878073189
]
-1.612712602375666,
54.022352820673774
],
[
-2.2803785770867933,
54.05470383755585
],
[
-3.272607322511618,
53.94443025530833
]
]
],
"type": "Polygon"
},
"relation": "within"
}
}
}
}'
104 changes: 104 additions & 0 deletions modules/search/examples/geospatial-search-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"status": {
"total": 1,
"failed": 0,
"successful": 1
},
"hits": [
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17411",
"score": 0.009274733001968816,
"sort": [
" \u0001?E#9\u003eN\u000c\"e"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17409",
"score": 0.009274733001968816,
"sort": [
" \u0001?O~i*(kD,"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17403",
"score": 0.009274733001968816,
"sort": [
" \u0001?Sg*|/t\u001f\u0002"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17410",
"score": 0.009274733001968816,
"sort": [
" \u0001?Z3T6 \u0010\u0019@"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17412",
"score": 0.009274733001968816,
"sort": [
" \u0001?]-\u000fm?\u000b\u0014#"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17408",
"score": 0.009274733001968816,
"sort": [
" \u0001?^DV7\u0014t:^"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17406",
"score": 0.009274733001968816,
"sort": [
" \u0001?_\u003c\u00009\u001eW\u0013\u0012"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17397",
"score": 0.009274733001968816,
"sort": [
" \u0001?c\u001cx\u0010n\u0016Wl"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17407",
"score": 0.009274733001968816,
"sort": [
" \u0001?c!7\u0001@SwS"
],
"partial_match": true
},
{
"index": "travel-sample.inventory.geo-index_78125822b3de7be3_4c1c5584",
"id": "landmark_17391",
"score": 0.009274733001968816,
"sort": [
" \u0001?dgzZ[\u0007;y"
],
"partial_match": true
}
],
"total_hits": 640,
"cost": 157249,
"max_score": 0.17106779096990765,
"took": 15349178,
"facets": null
}
3 changes: 3 additions & 0 deletions modules/search/examples/geospatial-sqlpp-query.sqlpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE `travel-sample`.inventory.landmark
SET geojson = { "type": "Point", "coordinates": [geo.lon, geo.lat] }
WHERE geo IS NOT null;
47 changes: 47 additions & 0 deletions modules/search/examples/run-search-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"status": {
"total": 1,
"failed": 0,
"successful": 1
},
"hits": [
{
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
"id": "landmark_4428",
"score": 2.425509689250102,
"sort": [
"_score"
],
"fields": {
"content": "serves fresh food at very reasonable prices - view of stoney beach with herons"
}
},
{
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
"id": "landmark_26385",
"score": 1.6270812956011347,
"sort": [
"_score"
],
"fields": {
"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."
}
},
{
"index": "travel-sample.inventory.landmark-content-index_49563a96ea6d3686_4c1c5584",
"id": "landmark_38035",
"score": 1.1962539437368078,
"sort": [
"_score"
],
"fields": {
"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."
}
}
],
"total_hits": 3,
"cost": 150479,
"max_score": 2.425509689250102,
"took": 1441203,
"facets": null
}
10 changes: 10 additions & 0 deletions modules/search/pages/create-search-index-rest-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ IMPORTANT: XATTRs mappings are only available in Couchbase Server version 7.6.2

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

If the REST API call is successful, the Search Service returns a `200 OK` and the following JSON response:

[source,json]
----
include::example$create-search-index-response.json[]
----

The `"uuid"` is randomly generated for each Search index you create.
Your own UUID might not match the value shown in the example.

== Next Steps

After you create a Search index, you can xref:simple-search-rest-api.adoc[] to test your Search index.
Expand Down
26 changes: 26 additions & 0 deletions modules/search/pages/geo-search-rest-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,41 @@ For example, the following query searches a geospatial field, `geo`, for any loc
include::example$geospatial-search-query.sh[]
----

If the REST API call is successful, the Search Service returns a `200 OK`.
Using the `landmark` collection, the query can return the following JSON response:

[source,json]
----
include::example$geospatial-search-response.json[]
----

=== Example: GeoJSON Query

[TIP]
====
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]:

[source,sqlpp]
----
include::example$geospatial-sqlpp-query.sqlpp[]
----
====

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]:

[source,console]
----
include::example$geospatial-search-query-geojson.sh[]
----

If the REST API call is successful, the Search Service returns a `200 OK`.
Using the `landmark` collection, the query can return the following JSON response:

[source,json]
----
include::example$geojson-search-response.json[]
----

== Next Steps

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