Skip to content

Doc 12754 redux hakim test #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: release/8.0
Choose a base branch
from
Draft
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
151 changes: 151 additions & 0 deletions modules/search/examples/create-search-index-payload-filters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
curl -s -XPUT -H "Content-Type: application/json" \
-u ${CB_USERNAME}:${CB_PASSWORD} http://${CB_HOSTNAME}:8094/api/bucket/travel-sample/scope/inventory/index/travel-sample-filter-index
-d \
'{
"type": "fulltext-index",
"name": "travel-sample.inventory.travel-sample-filter",
"sourceType": "gocbcore",
"sourceName": "travel-sample",
"planParams": {
"maxPartitionsPerPIndex": 128,
"indexPartitions": 1
},
"params": {
"doc_config": {
"doc_filter": {
"cleanliness_AND_free_breakfast": {
"conjuncts": [
{
"field": "reviews.ratings.Cleanliness",
"inclusive_max": true,
"max": 5,
"min": 3
},
{
"bool": true,
"field": "free_breakfast"
}
],
"order": 1
}
},
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "scope.collection.custom",
"type_field": "type"
},
"mapping": {
"analysis": {},
"default_analyzer": "standard",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"dynamic": true,
"enabled": false
},
"default_type": "_default",
"docvalues_dynamic": false,
"index_dynamic": true,
"store_dynamic": false,
"type_field": "_type",
"types": {
"inventory.hotel.cleanliness_AND_free_breakfast": {
"dynamic": false,
"enabled": true,
"properties": {
"description": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "description",
"store": true,
"type": "text"
}
]
},
"free_breakfast": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"index": true,
"name": "free_breakfast",
"store": true,
"type": "boolean"
}
]
},
"name": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "name",
"store": true,
"type": "text"
}
]
},
"reviews": {
"dynamic": false,
"enabled": true,
"properties": {
"content": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "content",
"store": true,
"type": "text"
}
]
},
"ratings": {
"dynamic": false,
"enabled": true,
"properties": {
"Cleanliness": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"index": true,
"name": "Cleanliness",
"store": true,
"type": "number"
}
]
}
}
}
}
}
}
}
}
},
"store": {
"indexType": "scorch",
"segmentVersion": 16
}
},
"sourceParams": {}
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"status": "ok",
"name": "travel-sample.inventory.travel-sample-filter-index",
"uuid": "5454607bd6b4b3e1"
}
94 changes: 92 additions & 2 deletions modules/search/examples/simple-search-index-payload.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,78 @@
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "scope.collection.type_field",
"type_field": "type"
"mode": "scope.collection.custom",
"type_field": "type",
// tag::doc_filter[]
"doc_filter": {
// tag::boolean_filter[]
"free_breakfast_true": {
"bool": true,
"field": "free_breakfast",
"order": 1
},
// end::boolean_filter[]
// tag::date_range_filter[]
"review_date_range": {
"start": "2015-01-01",
"end": "2019-01-01",
"inclusive_end": true,
"inclusive_start": false,
"field": "reviews.date",
"order": 2,
"datetime_parser": "My_Date_Time_Parser"
},
// end::date_range_filter[]
// tag::numeric_range_filter[]
"cleanliness_range": {
"min": 3,
"max": 5,
"inclusive_min": true,
"inclusive_max": true,
"field": "reviews.ratings.Cleanliness",
"order": 3
},
// end::numeric_range_filter[]
// tag::conjunct_filter[]
"free_parking_AND_vacancy": {
"conjuncts": [
{
"bool": true,
"field": "vacancy"
},
{
"bool": true,
"field": "free_parking"
}
],
"order": 4
},
// end::conjunct_filter[]
// tag::disjunct_filter[]
"location_OR_service": {
"disjuncts": [
{
"min": 5,
"field": "reviews.ratings.Service"
},
{
"min": 5,
"field": "reviews.ratings.Location"
}
],
"order": 6
},
// end::disjunct_filter[]
// tag::term_filter[]
"name_hotel": {
"term": "Hotel",
"order": 5,
"field": "name"
}
// end::term_filter[]

}
// end::doc_filter[]
},
// end::doc_config[]
// tag::mapping[]
Expand Down Expand Up @@ -194,6 +264,26 @@
]
}
}
},
"inventory.hotel.free_breakfast_true": {
"dynamic": true,
"enabled": true,
"properties": {
"free_breakfast": {
"dynamic": false,
"enabled": true,
"fields": [
{
"docvalues": true,
"include_in_all": true,
"index": true,
"name": "free_breakfast",
"store": true,
"type": "boolean"
}
]
}
}
}
// end::scope_collection[]
}
Expand Down
29 changes: 28 additions & 1 deletion modules/search/pages/create-search-index-rest-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Do not include the xref:search-index-params.adoc#uuid[uuid] or xref:search-index
TIP: If you remove the xref:search-index-params.adoc#uuid[uuid] and xref:search-index-params.adoc#sourceuuid[sourceUUID] parameters, you can copy the Search index definition JSON payload from the Couchbase {page-ui-name} to use in your REST API call.
For more information about how to create an index with the UI, see xref:create-search-index-ui.adoc[].

=== Example
=== Example: Simple Search Index with XATTRs

In the following example, the JSON payload creates a simple index named `landmark-content-index` on the `travel-sample` bucket.
It creates a type mapping for the `inventory.landmark` collection, with a child field, `content`, and adds a dynamic Extended Attributes (XATTRs) mapping for any available document metadata fields in the collection:
Expand All @@ -79,6 +79,33 @@ 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.

=== Example: Search Index with Custom Document Filter

[.status]#Couchbase Server 8.0#

In the following example, the JSON payload creates a Search index named `travel-sample-filter` on the `travel-sample` bucket.
It has a custom document filter, `cleanliness_AND_free_breakfast`, which uses a xref:search-index-params.adoc#conjunct_filter[conjunct filter] to restrict the documents in the index.
Only documents with a cleanliness rating between 3 and 5 and `free_breakfast` set to `true` are included from the `inventory.hotel` collection.

For documents that pass the filter, the index includes the `description`, `free_breakfast`, `name`, `reviews.content`, and `reviews.ratings.Cleanliness` fields:

[source,console]
----
include::example$create-search-index-payload-filters.sh[]
----

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-filters.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
5 changes: 3 additions & 2 deletions modules/search/pages/create-type-mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ To create a type mapping with the Couchbase {page-ui-name}:
. Do one of the following:
.. If you selected *Use non-default scope/collection(s)*, in the *Collection* list, select the collection where you want to create the type mapping.
.. If you cleared *Use non-default scope/collection(s)*, in the *#* field, enter the name of a type field where you want to create a type mapping.
. (Optional) To only include documents of a specific type from a collection, add the document type to the end of the collection in the *#* field.
. (Optional) To only include documents from a collection based on a specific filter, add the name of the filter or the filter value to the end of the collection in the *#* field.
+
For example, `inventory.hotel.free_breakfast_true` or `inventory.hotel.hotel`.
+
For example, `scope.collection.document_type`.
For more information, see xref:set-type-identifier.adoc[].
. (Optional) To use a specific analyzer for documents in the type mapping, in the *Analyzer* list, select an analyzer.
+
Expand Down
11 changes: 9 additions & 2 deletions modules/search/pages/customize-index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ You can add the following components and configure the following options for a S
|[[type-identifiers]]Type Identifier
|
|✓
a|Set a type identifier to add a filter to the documents added to your Search index:
a|Set a type identifier to add a filter to the documents added to your Search index through a <<type-mapping,type mapping>>:

* JSON Type Field: Selects only documents that contain a specific field with a specified string value.
* Doc ID up to Separator: Selects only documents with an ID or key up to a specific substring.
* Doc ID with Regex: Selects only documents with an ID or key that matches a regular expression.
* [.status]#Couchbase Server 8.0# Custom: As of Couchbase Server version 8.0, custom document filters select only documents that match a custom filter, based on the values of specific fields.

Type identifiers add a more granular filter to the documents in a type mapping.
If a type mapping has a type identifier, only documents that match the type identifier can be included in the Search index.

For more information about how to configure a type identifier, see xref:set-type-identifier.adoc[].

Expand All @@ -32,7 +36,7 @@ For more information about how to configure a type identifier, see xref:set-type
|&check;
a|Use a type mapping to include or exclude specific documents in a collection from an index.

Type mappings can also set a field's data type and other settings.
Type mappings can also set a document field's data type and other settings.

You can create two types of type mappings with the Search Service:

Expand All @@ -52,6 +56,9 @@ Type mappings start at the collection level.
Create additional mappings for child fields or xref:create-child-mapping.adoc[JSON objects] under a collection's type mapping to restrict the documents added to your index.
This can improve Search index performance over indexing entire collections.

For a type mapping defined on a scope and collection, you can add an additional filter known as a <<type-identifiers,type identifier>>, to restrict the documents included from a type mapping.
Only documents from your specified scope and collection that also pass the type identifier's filter can be included in your Search index, and potentially returned in search results.

If your cluster is running Couchbase Server version 7.6.2 and later, you can also choose to include document metadata inside your Search index by xref:create-xattrs-mapping.adoc[creating an XATTRs mapping].

For more information about how to configure settings for mappings and type mappings in the Quick Editor, see xref:quick-index-field-options.adoc[].
Expand Down
Loading