You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/fts/pages/fts-quickstart-guide.adoc
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,5 @@ Refer to xref:n1ql:n1ql-language-reference/searchfun.adoc[Search Functions] for
43
43
[#establishing-demonstration-indexes]
44
44
== Accessing the Search service via the Java SDK
45
45
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].
@@ -5,11 +5,57 @@ Search functions enable you to use full text search queries directly within a N1
5
5
== Prerequisites
6
6
7
7
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.
9
9
10
10
[NOTE]
11
11
--
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
+
13
59
--
14
60
15
61
=== Authorization
@@ -203,33 +249,29 @@ The following queries are equivalent:
203
249
[source,n1ql]
204
250
----
205
251
SELECT META(t1).id
206
-
FROM `travel-sample`.inventory.airline AS t1
252
+
FROM `travel-sample`.inventory.hotel AS t1
207
253
WHERE SEARCH(t1.country, "+United +States");
208
254
----
209
255
210
256
[source,n1ql]
211
257
----
212
258
SELECT META(t1).id
213
-
FROM `travel-sample`.inventory.airline AS t1
259
+
FROM `travel-sample`.inventory.hotel AS t1
214
260
WHERE SEARCH(t1, "country:\"United States\"");
215
261
----
216
262
217
263
.Results
218
264
[source,json]
219
265
----
220
266
[
221
-
222
267
{
223
-
"id": "airline_10"
268
+
"id": "hotel_26215"
224
269
},
225
270
{
226
-
"id": "airline_10123"
271
+
"id": "hotel_7396"
227
272
},
228
273
{
229
-
"id": "airline_10226"
230
-
},
231
-
{
232
-
"id": "airline_10748"
274
+
"id": "hotel_32177"
233
275
},
234
276
...
235
277
]
@@ -350,8 +392,51 @@ WHERE t1.type = "hotel" AND SEARCH(t1.description, "amazing");
350
392
----
351
393
352
394
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
+
----
355
440
356
441
For more information on defining custom type mappings within the full text search index, refer to xref:fts:fts-type-mappings.adoc[Type Mappings].
357
442
Note that for N1QL queries, only full text search indexes with one type mapping are searchable.
@@ -506,6 +591,10 @@ AND SEARCH(t1, {
506
591
----
507
592
[
508
593
{
594
+
"meta": {
595
+
"id": "hotel_17598",
596
+
"score": 2.1256278997816835
597
+
},
509
598
"name": "Marina del Rey Marriott"
510
599
}
511
600
]
@@ -569,16 +658,19 @@ LIMIT 3;
569
658
----
570
659
[
571
660
{
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
574
664
},
575
665
{
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
578
669
},
579
670
{
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
582
674
}
583
675
]
584
676
----
@@ -682,4 +774,4 @@ WHERE reviews.content LIKE "%travel%";
682
774
SELECT META().id
683
775
FROM `travel-sample`.`inventory`.`hotel` t USE INDEX(USING FTS)
Copy file name to clipboardExpand all lines: modules/fts/pages/fts-supported-queries-geopoint-spatial.adoc
+54-3Lines changed: 54 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -232,10 +232,61 @@ Detailed instructions for setting up indexes, and specifying type mappings, are
232
232
233
233
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:
The following query examples in this page will require the following index definition ..
236
236
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.
0 commit comments