Skip to content

Commit a331b8a

Browse files
committed
[DOC-12282]: Feedback on Search Functions.
Add a link to the page explaining how to add a search index through the UI console. Integrated a reusable prerequisites section for setting up demonstration search indexes, ensuring consistent instructions across related documentation. Updated existing N1QL Search Function content to reference the new section and adjusted formatting for clarity.
1 parent 964a692 commit a331b8a

File tree

2 files changed

+205
-9
lines changed

2 files changed

+205
-9
lines changed

modules/n1ql/pages/n1ql-language-reference/searchfun.adoc

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,24 @@
88

99
Search functions enable you to use xref:search:search.adoc[Full Text Search (FTS)] queries directly within a {sqlpp} query.
1010

11-
[float]
12-
=== Prerequisites
11+
[#prerequisities, float]
12+
== Prerequisites
1313

1414
To use any of the search functions, the Search Service must be available on the cluster.
1515
It's recommended that you create a suitable Search index for the searches that you want to run.
1616
For more information, refer to xref:search:create-search-indexes.adoc[].
1717

18-
[NOTE]
19-
--
20-
The examples in this page all assume that demonstration Search indexes have been created, as described in xref:fts:fts-demonstration-indexes.adoc[Demonstration Indexes].
21-
--
18+
include::partial$demonstration-index-prerequisite-section.adoc[]
2219

2320
[float]
24-
=== Authorization
21+
== Authorization
2522

2623
You do not need credentials for the Search Service to be able to use the search functions in a query.
2724
The role *Data Admin* must be assigned to those who intend to create indexes; and the role *Data Reader* to those who intend to perform searches.
2825
For information on creating users and assigning roles, see xref:learn:security/authorization-overview.adoc[Authorization].
2926

3027
[float]
31-
=== When to Use Search Functions
28+
== When to Use Search Functions
3229

3330
The search functions are useful when you need to combine a Full Text Search with the power of a {sqlpp} query; for example, combining joins and natural-language search in the same query.
3431

@@ -381,7 +378,7 @@ WHERE t1.type = "hotel" AND SEARCH(t1.description, "amazing");
381378
----
382379
383380
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.
384-
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".
381+
The above query uses the xref:prerequisities[demonstration index], which has the custom type mapping "hotel".
385382
386383
For more information about defining custom type mappings within a Search index, refer to xref:search:create-type-mapping.adoc[Create a Type Mapping].
387384
Note that for {sqlpp} queries, only Search indexes with one type mapping are searchable.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
To run the examples on this page, you will need to create three indexes.
2+
3+
To create the indexes, you can use:
4+
5+
* The index editor built into the web console.
6+
* The REST API
7+
* The command line utility.
8+
9+
For this exercise, the easiest way is to use the web console to import the index definitions below.
10+
11+
If you need more information on creating search indexes using Couchbase Web UI, see xref:search:create-search-index-ui.adoc[]
12+
13+
14+
[tabs]
15+
====
16+
travel-sample-index-unstored::
17+
+
18+
--
19+
[source,json]
20+
----
21+
22+
{
23+
"name": "travel-sample-index-unstored",
24+
"type": "fulltext-index",
25+
"params": {
26+
"doc_config": {
27+
"docid_prefix_delim": "",
28+
"docid_regexp": "",
29+
"mode": "type_field",
30+
"type_field": "type"
31+
},
32+
"mapping": {
33+
"analysis": {
34+
"analyzers": {
35+
"singleAnalyzer": {
36+
"tokenizer": "single",
37+
"type": "custom"
38+
}
39+
}
40+
},
41+
"default_analyzer": "standard",
42+
"default_datetime_parser": "dateTimeOptional",
43+
"default_field": "_all",
44+
"default_mapping": {
45+
"dynamic": true,
46+
"enabled": true
47+
},
48+
"default_type": "_default",
49+
"docvalues_dynamic": false,
50+
"index_dynamic": true,
51+
"store_dynamic": false,
52+
"type_field": "_type"
53+
},
54+
"store": {
55+
"indexType": "scorch",
56+
"segmentVersion": 15
57+
}
58+
},
59+
"sourceType": "gocbcore",
60+
"sourceName": "travel-sample",
61+
"sourceUUID": "94387e8a4cefe4abeb51d92e28a696c6",
62+
"sourceParams": {},
63+
"planParams": {
64+
"maxPartitionsPerPIndex": 1024,
65+
"indexPartitions": 1,
66+
"numReplicas": 0
67+
},
68+
"uuid": "5e26bbd6c2c87069"
69+
}
70+
----
71+
--
72+
73+
travel-sample-index-stored::
74+
+
75+
--
76+
[source,json]
77+
----
78+
{
79+
"name": "travel-sample-index-stored",
80+
"type": "fulltext-index",
81+
"params": {
82+
"doc_config": {
83+
"docid_prefix_delim": "",
84+
"docid_regexp": "",
85+
"mode": "type_field",
86+
"type_field": "type"
87+
},
88+
"mapping": {
89+
"analysis": {
90+
"analyzers": {
91+
"letterAnalyzer": {
92+
"tokenizer": "letter",
93+
"type": "custom"
94+
}
95+
}
96+
},
97+
"default_analyzer": "standard",
98+
"default_datetime_parser": "dateTimeOptional",
99+
"default_field": "_all",
100+
"default_mapping": {
101+
"dynamic": true,
102+
"enabled": true
103+
},
104+
"default_type": "_default",
105+
"docvalues_dynamic": false,
106+
"index_dynamic": true,
107+
"store_dynamic": true,
108+
"type_field": "_type"
109+
},
110+
"store": {
111+
"indexType": "scorch",
112+
"segmentVersion": 15
113+
}
114+
},
115+
"sourceType": "gocbcore",
116+
"sourceName": "travel-sample",
117+
"sourceUUID": "94387e8a4cefe4abeb51d92e28a696c6",
118+
"sourceParams": {},
119+
"planParams": {
120+
"maxPartitionsPerPIndex": 1024,
121+
"indexPartitions": 1,
122+
"numReplicas": 0
123+
},
124+
"uuid": "16d6602d3193b526"
125+
}
126+
----
127+
128+
--
129+
130+
geoIndex::
131+
+
132+
--
133+
134+
[source,json]
135+
----
136+
137+
{
138+
"name": "geoIndex",
139+
"type": "fulltext-index",
140+
"params": {
141+
"doc_config": {
142+
"docid_prefix_delim": "",
143+
"docid_regexp": "",
144+
"mode": "type_field",
145+
"type_field": "type"
146+
},
147+
"mapping": {
148+
"default_analyzer": "standard",
149+
"default_datetime_parser": "dateTimeOptional",
150+
"default_field": "_all",
151+
"default_mapping": {
152+
"dynamic": true,
153+
"enabled": true,
154+
"properties": {
155+
"geo": {
156+
"enabled": true,
157+
"dynamic": false,
158+
"fields": [
159+
{
160+
"include_in_all": true,
161+
"index": true,
162+
"name": "geo",
163+
"store": true,
164+
"type": "geopoint"
165+
}
166+
]
167+
}
168+
}
169+
},
170+
"default_type": "_default",
171+
"docvalues_dynamic": false,
172+
"index_dynamic": true,
173+
"store_dynamic": false,
174+
"type_field": "_type"
175+
},
176+
"store": {
177+
"indexType": "scorch",
178+
"segmentVersion": 15,
179+
"spatialPlugin": "s2"
180+
}
181+
},
182+
"sourceType": "gocbcore",
183+
"sourceName": "travel-sample",
184+
"sourceUUID": "94387e8a4cefe4abeb51d92e28a696c6",
185+
"sourceParams": {},
186+
"planParams": {
187+
"maxPartitionsPerPIndex": 1024,
188+
"indexPartitions": 1,
189+
"numReplicas": 0
190+
},
191+
"uuid": "445bceb9301d0d74"
192+
}
193+
----
194+
195+
196+
--
197+
198+
199+
====

0 commit comments

Comments
 (0)