Skip to content

Commit 4a0ed5f

Browse files
abhinavdangetiRayOffiah
authored andcommitted
DOC-9450: Update SEARCH_META(..) instructions and examples (#2468)
* DOC-9450: Update SEARCH_META(..) instructions and examples * Remove references to fts-demonstration-indexes * Fix reference to fts-supported-queries
1 parent 0cfb966 commit 4a0ed5f

File tree

4 files changed

+281
-46
lines changed

4 files changed

+281
-46
lines changed

modules/fts/pages/fts-quickstart-guide.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ Refer to xref:n1ql:n1ql-language-reference/searchfun.adoc[Search Functions] for
4343
[#establishing-demonstration-indexes]
4444
== Accessing the Search service via the Java SDK
4545

46-
The Java SDK code-example provided in xref:java-sdk:howtos:full-text-searching-with-sdk.adoc[Searching from the Java SDK] contains multiple demonstration calls — each featuring a different query-combination — and makes use of three different index-definitions, related to the `travel-sample` bucket: for the code example to run successfully, the three indexes must be appropriately pre-established.
47-
//The definitions are provided in xref:fts-demonstration-indexes.adoc[Demonstration Indexes].
48-
Instructions on how to use the Couchbase REST API to establish the definitions refer to xref:fts-creating-index-with-rest-api.adoc[Index Creation with REST API].
46+
The Java SDK code-example provided in xref:java-sdk:howtos:full-text-searching-with-sdk.adoc[Searching from the SDK] contains multiple demonstration calls — each featuring a different query-combination — and makes use of three different index-definitions, related to the `travel-sample` bucket: for the code example to run successfully, the three indexes must be appropriately pre-established.
47+
Instructions on how to use the Couchbase REST API to establish the definitions refer to xref:fts-creating-index-with-rest-api.adoc[Creating Index with REST API].

modules/fts/pages/fts-searching-from-N1QL.adoc

Lines changed: 112 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,57 @@ Search functions enable you to use full text search queries directly within a N1
55
== Prerequisites
66

77
To use any of the search functions, the Search service must be available on the cluster.
8-
It is also recommended, but not required, that you should create suitable full text indexes for the searches that you need to perform.
8+
It is required for you to create suitable full text indexes for the searches that you want to perform.
99

1010
[NOTE]
1111
--
12-
The examples in this page all assume that demonstration full text indexes have been created.
12+
The examples in this page assume that you have a full text search index created with this definition, unless specified otherwise ..
13+
[source,json]
14+
----
15+
{
16+
"name": "travel-sample-inventory-hotels",
17+
"type": "fulltext-index",
18+
"params": {
19+
"doc_config": {
20+
"mode": "scope.collection.type_field",
21+
"type_field": "type"
22+
},
23+
"mapping": {
24+
"default_analyzer": "standard",
25+
"default_datetime_parser": "dateTimeOptional",
26+
"default_field": "_all",
27+
"default_mapping": {
28+
"dynamic": true,
29+
"enabled": false
30+
},
31+
"default_type": "_default",
32+
"docvalues_dynamic": false,
33+
"index_dynamic": true,
34+
"store_dynamic": false,
35+
"type_field": "_type",
36+
"types": {
37+
"inventory.hotel": {
38+
"dynamic": true,
39+
"enabled": true
40+
}
41+
}
42+
},
43+
"store": {
44+
"indexType": "scorch",
45+
"segmentVersion": 15
46+
}
47+
},
48+
"sourceType": "gocbcore",
49+
"sourceName": "travel-sample",
50+
"sourceUUID": "",
51+
"sourceParams": {},
52+
"planParams": {
53+
"indexPartitions": 1
54+
},
55+
"uuid": ""
56+
}
57+
----
58+
1359
--
1460

1561
=== Authorization
@@ -203,33 +249,29 @@ The following queries are equivalent:
203249
[source,n1ql]
204250
----
205251
SELECT META(t1).id
206-
FROM `travel-sample`.inventory.airline AS t1
252+
FROM `travel-sample`.inventory.hotel AS t1
207253
WHERE SEARCH(t1.country, "+United +States");
208254
----
209255
210256
[source,n1ql]
211257
----
212258
SELECT META(t1).id
213-
FROM `travel-sample`.inventory.airline AS t1
259+
FROM `travel-sample`.inventory.hotel AS t1
214260
WHERE SEARCH(t1, "country:\"United States\"");
215261
----
216262
217263
.Results
218264
[source,json]
219265
----
220266
[
221-
222267
{
223-
"id": "airline_10"
268+
"id": "hotel_26215"
224269
},
225270
{
226-
"id": "airline_10123"
271+
"id": "hotel_7396"
227272
},
228273
{
229-
"id": "airline_10226"
230-
},
231-
{
232-
"id": "airline_10748"
274+
"id": "hotel_32177"
233275
},
234276
...
235277
]
@@ -350,8 +392,51 @@ WHERE t1.type = "hotel" AND SEARCH(t1.description, "amazing");
350392
----
351393
352394
If the full text search index being queried has its default mapping disabled and has a custom type mapping defined, the query needs to specify the type explicitly.
353-
354-
//The above query uses the demonstration index xref:fts:fts-demonstration-indexes.adoc#travel-sample-index-hotel-description[travel-sample-index-hotel-description], which has the custom type mapping "hotel".
395+
The above query uses the following index definition ..
396+
[source,json]
397+
----
398+
{
399+
"name": "travel-sample-hotels",
400+
"type": "fulltext-index",
401+
"params": {
402+
"doc_config": {
403+
"mode": "type_field",
404+
"type_field": "type"
405+
},
406+
"mapping": {
407+
"default_analyzer": "standard",
408+
"default_datetime_parser": "dateTimeOptional",
409+
"default_field": "_all",
410+
"default_mapping": {
411+
"dynamic": true,
412+
"enabled": false
413+
},
414+
"default_type": "_default",
415+
"index_dynamic": true,
416+
"store_dynamic": true,
417+
"type_field": "type",
418+
"types": {
419+
"hotel": {
420+
"dynamic": true,
421+
"enabled": true
422+
}
423+
}
424+
},
425+
"store": {
426+
"indexType": "scorch",
427+
"segmentVersion": 15
428+
}
429+
},
430+
"sourceType": "gocbcore",
431+
"sourceName": "travel-sample",
432+
"sourceUUID": "",
433+
"sourceParams": {},
434+
"planParams": {
435+
"indexPartitions": 1
436+
},
437+
"uuid": ""
438+
}
439+
----
355440
356441
For more information on defining custom type mappings within the full text search index, refer to xref:fts:fts-type-mappings.adoc[Type Mappings].
357442
Note that for N1QL queries, only full text search indexes with one type mapping are searchable.
@@ -506,6 +591,10 @@ AND SEARCH(t1, {
506591
----
507592
[
508593
{
594+
"meta": {
595+
"id": "hotel_17598",
596+
"score": 2.1256278997816835
597+
},
509598
"name": "Marina del Rey Marriott"
510599
}
511600
]
@@ -569,16 +658,19 @@ LIMIT 3;
569658
----
570659
[
571660
{
572-
"description": "3 Star Hotel next to the Mountain Railway terminus and set in 30 acres of grounds which include Dolbadarn Castle",
573-
"name": "The Royal Victoria Hotel"
661+
"description": "370 guest rooms offering both water and mountain view.",
662+
"name": "Marina del Rey Marriott",
663+
"score": 2.1256278997816835
574664
},
575665
{
576-
"description": "370 guest rooms offering both water and mountain view.",
577-
"name": "Marina del Rey Marriott"
666+
"description": "Log cabin glamping in a rural setting with panoramic views toward the Clwydian Mountain Range.",
667+
"name": "Clwydian Holidays",
668+
"score": 1.6956645086702617
578669
},
579670
{
580-
"description": "This small family run hotel captures the spirit of Mull and is a perfect rural holiday retreat. The mountain and sea blend together to give fantastic, panoramic views from the hotel which is in an elevated position on the shoreline. Panoramic views are also available from the bar and restaurant which serves local produce 7 days a week.",
581-
"name": "The Glenforsa Hotel"
671+
"description": "3 Star Hotel next to the Mountain Railway terminus and set in 30 acres of grounds which include Dolbadarn Castle",
672+
"name": "The Royal Victoria Hotel",
673+
"score": 1.5030458987111712
582674
}
583675
]
584676
----
@@ -682,4 +774,4 @@ WHERE reviews.content LIKE "%travel%";
682774
SELECT META().id
683775
FROM `travel-sample`.`inventory`.`hotel` t USE INDEX(USING FTS)
684776
WHERE content LIKE "%travel%";
685-
----
777+
----

modules/fts/pages/fts-supported-queries-geopoint-spatial.adoc

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,61 @@ Detailed instructions for setting up indexes, and specifying type mappings, are
232232

233233
For initial experimentation with geospatial geopoint querying (based on the type geopoint), the `geo` field of documents within the `travel-sample` bucket can be specified as a child field of the `default` type mapping (keyspace `travel-sample._default._default` as follows:
234234

235-
include::partial$fts-creating-geopoint-common.adoc[]
235+
The following query examples in this page will require the following index definition ..
236236

237-
The index once created can also be accessed by means of the Search REST API
238-
see xref:fts-searching-with-curl-http-requests.adoc[Searching with the REST API]. Furthermore the index could have been created in the first place via the Search REST API see xref:fts-creating-index-with-rest-api.adoc[Index Creation with REST API] for more information on using the Search REST API syntax.
237+
[source,json]
238+
----
239+
{
240+
"type": "fulltext-index",
241+
"name": "geoIndex",
242+
"uuid": "",
243+
"sourceType": "gocbcore",
244+
"sourceName": "travel-sample",
245+
"sourceUUID": "",
246+
"planParams": {
247+
"indexPartitions": 1
248+
},
249+
"params": {
250+
"doc_config": {
251+
"mode": "type_field",
252+
"type_field": "type"
253+
},
254+
"mapping": {
255+
"default_analyzer": "standard",
256+
"default_datetime_parser": "dateTimeOptional",
257+
"default_field": "_all",
258+
"default_mapping": {
259+
"dynamic": true,
260+
"enabled": true,
261+
"properties": {
262+
"geo": {
263+
"dynamic": false,
264+
"enabled": true,
265+
"fields": [
266+
{
267+
"include_in_all": true,
268+
"include_term_vectors": true,
269+
"index": true,
270+
"name": "geo",
271+
"store": true,
272+
"type": "geopoint"
273+
}
274+
]
275+
}
276+
}
277+
},
278+
"default_type": "_default",
279+
"index_dynamic": true,
280+
"store_dynamic": false
281+
},
282+
"store": {
283+
"indexType": "scorch",
284+
"segmentVersion": 15
285+
}
286+
},
287+
"sourceParams": {}
288+
}
289+
----
239290

240291
[#creating_geospatial_rest_query_radius_based]
241292
[#creating_geopoint_rest_query_radius_based]

0 commit comments

Comments
 (0)