{{announcement.body}}
{{announcement.title}}

Couchbase: FTS Indexing Best Practices by Use Case

DZone 's Guide to

Couchbase: FTS Indexing Best Practices by Use Case

In this article, take a look at FTS indexing best practices by use case.

· Database Zone ·
Free Resource

Introduction

Full text search (FTS) indexing can be challenging for those who are not familiar with search in general.  In this post, we’ll take some common search use cases and work through the creation of appropriate indexes following best practices for Couchbase FTS indexing.

Use Cases

The following common use cases will be explored: 

  • Simple search 
  • Field independent search
  • Finding the Nearest Neighbor
  • Search documents with a model that is changing all the time

Travel Sample Data Model

Throughout this document, we’ll be referencing the Travel Sample dataset available to install in any Couchbase Server instance. The travel-sample bucket has several distinct document types: airline, route, airport, landmark, and hotel.  The document model for each kind of document contains:

  • A key that acts as a primary key
  • An id field that identifies the document
  • A type field that identifies the kind of document

The following figure illustrates the relationship between the different kinds of documents in the travel-sample bucket. It shows the primary key, ID, and type fields that each document has, plus a few representative fields in each type of document. (Landmark documents are not pictured.)

Documents in the travel-sample data model

Figure 0. Documents in the travel-sample data model


Example Use Cases

Simple Search

Use case summary: a user will find hotels by searching the hotel description field for a keyword and see a list of matching hotels. 

Index creation steps: 

  1. On the Full Text Search UI, click “Add Index”.

  2. Specify an index name, e.g. “hotel_desc”, and select the travel-sample bucket. 

  3. Since each document in the travel-sample bucket has a “type” field indicating the type of document, leave “JSON type field” set to “type”.

  4. Under type mappings:  

    1. Click “+ Add Type Mapping”, and specify “hotel” as the type name, since the requirement is to search all hotel documents.  

    2. A list of available analyzers can be accessed by means of the pull-down menu to the right of the type name field.  For this use case, leave “inherit” selected so that the type mapping inherits the default analyzer from the index.

    3. Since the requirement is to search only the hotel description field, check “only index specified fields”.  With this checked, only user-specified fields from the document are included in the index for the hotel type mapping (the mapping will not be dynamic, meaning that all fields are considered available for indexing). 

    4. Click OK.  

    5. Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the description field to be individually included in the index.  Specify the following: 

      1. field: Enter the name of the field to be indexed, “description”.

      2. type: Leave this set to text for the description field.

      3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

      4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

      5. index checkbox: Leave this checked, so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

      6. store checkbox: This setting includes the field content in the values returned from the search and permits highlighting of matched expressions in the results, but it also increases the size of the index and the build time. Leave this unchecked since there’s no requirement to highlight the results for this use case. 

      7. “include in _all field” checkbox: Uncheck this since the use case is to specifically search the description field. 

      8. “include term vectors” checkbox: Certain kinds of functionality (such as highlighting, and phrase search) require term vectors, but this increases the size of the index and the build time. Uncheck this box since the use case is a keyword search without highlighting.  

      9. Click OK

    6. Finally, uncheck the checkbox next to the “default” type mapping.  If the default mapping is left enabled, all documents in the bucket are included in the index, regardless of whether the user actively specifies type mappings. Only the hotel documents are required, and they are included by the hotel type mapping added previously. 

  5. The default values suffice for the remaining collapsed panels (Analyzers, Custom Filters, Date/Time Parsers, and Advanced). 

  6. Index Replicas can be set to 1, 2 or 3, provided that the cluster is running the Search service on n+1 nodes. With a single node development cluster, maintain the default value of 0. 

  7. For Index Type, the default value of “Version 6.0 (Scorch)” is appropriate for any newly created indexes. Scorch reduces the size of the index on disk, and provides enhanced performance for indexing and mutation-handling.

  8. At this point, the create index page should look like the last frame captured in Figure 1.  Click “Create Index” to complete the process. 

Index Creation “hotel_desc”

Figure 1 - Index Creation “hotel_desc”


Note: See “Index: hotel_desc” in Appendix A for the JSON payload used to create this index with the REST API.  

Testing queries against the index: 

  1. On the Full Text Search UI, wait for indexing progress to show 100%, then click on the index name “hotel_desc”. 

  2. To search for any hotels with the keyword “farm” in the description, in the “search this index…” text box, enter “description:farm” and click Search.  This field-scoping of the search is required because the “include in _all field” checkbox was left unchecked.

  3. The results are shown (similar to Figure 2) with the key of each matching document.

Index “hotel_desc” search for “description:farm”

Figure 2 - Index “hotel_desc” search for “description:farm”


  1. The same search can be run through the REST API using curl: 

JSON
 




xxxxxxxxxx
1
13


 
1
curl -u username:password -XPOST -H "Content-Type: application/json" \
2
http://localhost:8094/api/index/hotel_mult_fields/query \
3
-d '{
4
  "explain": true,
5
  "fields": [
6
    "*"
7
  ],
8
  "highlight": {},
9
  "query": {
10
    "query": "farm"
11
  }
12
}'
13
 
          


Field-Independent Search

Use case summary: a user will find hotels by searching the hotel name, alias, description, address, and reviews fields for a keyword and see a list of matching hotels that includes the highlighted matches.

Index creation steps: 

  1. On the Full Text Search UI, click “Add Index”.

  2. Specify an index name, e.g. “hotel_mult_fields”, and select the travel-sample bucket. 

  3. Since each document in the travel-sample bucket has a “type” field indicating the type of document, leave “JSON type field” set to “type”.

  4. Under type mappings:  

    1. Click “+ Add Type Mapping”, and specify “hotel” as the type name, since the requirement is to search all hotel documents.  

    2. A list of available analyzers can be accessed by means of the pull-down menu to the right of the type name field.  For this use case, leave “inherit” selected so that the type mapping inherits the default analyzer from the index.

    3. Since the requirement is to search hotel name, alias, description, address, and reviews fields, check “only index specified fields”.  With this checked, only user-specified fields from the document are included in the index for the hotel type mapping (the mapping will not be dynamic, meaning that all fields are considered available for indexing). 

    4. Click OK.  

    5. Add each of the 5 fields to the hotel type mapping:

      1. Name: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “name”.

        2. type: Leave this set to text for the name field.

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

        6. store checkbox: Check this setting to include the field content in the search results which permits highlighting of matched expressions in the results. 

        7. “include in _all field” checkbox: Leave this checked since the use case requirement is to search multiple fields. 

        8. “include term vectors” checkbox: Leave this checked since the use case requires highlighting of results.  

        9. Click OK

      2. Alias: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “alias”.

        2. type: Leave this set to text for the name field.

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

        6. store checkbox: Check this setting to include the field content in the search results which permits highlighting of matched expressions in the results. 

        7. “include in _all field” checkbox: Leave this checked since the use case requirement is to search multiple fields. 

        8. “include term vectors” checkbox: Leave this checked since the use case requires highlighting of results.  

        9. Click OK

      3. Description: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “description”.

        2. type: Leave this set to text for the name field.

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

        6. store checkbox: Check this setting to include the field content in the search results which permits highlighting of matched expressions in the results. 

        7. “include in _all field” checkbox: Leave this checked since the use case requirement is to search multiple fields. 

        8. “include term vectors” checkbox: Leave this checked since the use case requires highlighting of results.  

        9. Click OK

      4. Address: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “address”.

        2. type: Leave this set to text for the name field.

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

        6. store checkbox: Check this setting to include the field content in the search results which permits highlighting of matched expressions in the results. 

        7. “include in _all field” checkbox: Leave this checked since the use case requirement is to search multiple fields. 

        8. “include term vectors” checkbox: Leave this checked since the use case requires highlighting of results.  

        9. Click OK

      5. Reviews: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “reviews”.

        2. type: Leave this set to text for the name field.

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name. 

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer.

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index.

        6. store checkbox: Check this setting to include the field content in the search results which permits highlighting of matched expressions in the results. 

        7. “include in _all field” checkbox: Leave this checked since the use case requirement is to search multiple fields. 

        8. “include term vectors” checkbox: Leave this checked since the use case requires highlighting of results.  

        9. Click OK

    6. Finally, uncheck the checkbox next to the “default” type mapping.  If the default mapping is left enabled, all documents in the bucket are included in the index, regardless of whether the user actively specifies type mappings. Only the hotel documents are required, and they are included by the hotel type mapping added previously. 

  5. The default values suffice for the remaining collapsed panels (Analyzers, Custom Filters, Date/Time Parsers, and Advanced). 

  6. Index Replicas can be set to 1, 2 or 3, provided that the cluster is running the Search service on n+1 nodes. With a single node development cluster, maintain the default value of 0. 

  7. For Index Type, the default value of “Version 6.0 (Scorch)” is appropriate for any newly created indexes. Scorch reduces the size of the index on disk, and provides enhanced performance for indexing and mutation-handling.

  8. At this point, the create index page should look like the last frame captured in Figure 3.  Click “Create Index” to complete the process. 

Index Creation “hotel_mult_fields”

Figure 3 - Index Creation “hotel_mult_fields”


Note: See “Index: hotel_mult_fields” in Appendix A for the JSON payload used to create this index through the REST API.  

Testing queries against the index: 

  1. On the Full Text Search UI, wait for indexing progress to show 100%, then click on the index name “hotel_mult_fields”. 
  2. To search for any hotels with the keyword “farm” in the name, alias, description, address, or reviews fields, in the “search this index…” text box, enter “farm” and click Search.  Field-scoping of the search is not required because the “include in _all field” checkbox was checked for each field indexed in the hotel type mapping.
  3. The results are shown (similar to Figure 4) with the key of each matching document and the highlighted matches in each matching document.

Index “hotel_mult_fields” search results for “farm”

Figure 4 - Index “hotel_mult_fields” search results for “farm”


  1. The same search can be run through the REST API using curl: 

JSON
 




xxxxxxxxxx
1
13


 
1
curl -u username:password -XPOST -H "Content-Type: application/json" \
2
http://localhost:8094/api/index/hotel_mult_fields/query \
3
-d '{
4
  "explain": true,
5
  "fields": [
6
    "*"
7
  ],
8
  "highlight": {},
9
  "query": {
10
    "query": "farm"
11
  }
12
}'
13
 
          


Finding the Nearest Neighbor

Use case summary: a user will find hotels within a certain distance from a specified location and see a list of matching hotel names ordered by distance from the specified location.

Index creation steps: 

  1. On the Full Text Search UI, click “Add Index”

  2. Specify an index name, e.g. “hotel_geo”, and select the travel-sample bucket.

  3. Since each document in the travel-sample bucket has a “type” field indicating the type of document, leave “JSON type field” set to “type”

  4. Under type mappings:  

    1. Click “+ Add Type Mapping”, and specify “hotel” as the type name, since the requirement is to search all hotel documents. 

    2. A list of available analyzers can be accessed by means of the pull-down menu to the right of the type name field.  For this use case, leave “inherit” selected so that the type mapping inherits the default analyzer from the index

    3. Since the requirement is to search for the hotel location only, check “only index specified fields”.  With this checked, only user-specified fields from the document are included in the index for the hotel type mapping (the mapping will not be dynamic, meaning that all fields are considered available for indexing).

    4. Click OK. 

    5. Add the geo and name fields to the hotel type mapping:

      1. Geo: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel geo field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “geo”

        2. type: Set this to geopoint

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name

        4. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index

        5. store checkbox: Check this setting to include the field content in the search results

        6. “include in _all field” checkbox: Leave this checked since the use case requirement is to search the geo field

        7. Click OK

      2. Name: Mouse over the row with the hotel type mapping, click the + button, and then click “insert child field”.  This will allow the hotel name field to be individually included in the index.  Specify the following: 

        1. field: Enter the name of the field to be indexed, “name”

        2. type: Leave this set to text for the name field

        3. searchable as: Leave this the same as the field name for the current use case.  It can be used to indicate an alternate field name

        4. analyzer: As was done for the type mapping, for this use case, leave “inherit” selected so that the type mapping inherits the default analyzer

        5. index checkbox: Leave this checked so that the field is included in the index.  Unchecking the box would explicitly remove the field from the index

        6. store checkbox: Check this setting to include the field content in the search results

        7. “include in _all field” checkbox: Uncheck this since the use case requirement is to search only by location but to display the name in the search results

        8. “include term vectors” checkbox: Certain kinds of functionality (such as highlighting, and phrase search) require term vectors, but this increases the size of the index and the build time. Uncheck this box since the use case is to search by geo location only

        9. Click OK

    6. Finally, uncheck the checkbox next to the “default” type mapping.  If the default mapping is left enabled, all documents in the bucket are included in the index, regardless of whether the user actively specifies type mappings. Only the hotel documents are required, and they are included by the hotel type mapping added previously

  5. The default values suffice for the remaining collapsed panels (Analyzers, Custom Filters, Date/Time Parsers, and Advanced)

  6. Index Replicas can be set to 1, 2 or 3, provided that the cluster is running the Search service on n+1 nodes. With a single node development cluster, maintain the default value of 0

  7. For Index Type, the default value of “Version 6.0 (Scorch)” is appropriate for any newly created indexes. Scorch reduces the size of the index on disk, and provides enhanced performance for indexing and mutation-handling

  8. At this point, the create index page should look like Figure 5.  Click “Create Index” to complete the process

Index Creation “hotel_geo”

Figure 5 - Index Creation “hotel_geo”


Note: See “Index: hotel_geo” in Appendix A for the JSON payload used to create this index through the REST API.  

Testing queries against the index: 

  1. On the Full Text Search UI, wait for indexing progress to show 100%. 

  2. Only “query string” queries can be tested through the Search UI in the Couchbase web console, so this geospatial search will be tested through the REST API using curl.  Search for the 2 nearest hotels within a mile of a location in San Francisco, returning the hotel name and coordinates ordered by distance using the following JSON query body:

JSON
 




xxxxxxxxxx
1
29


 
1
curl -u username:password -XPOST -H "Content-Type: application/json" \
2
http://localhost:8094/api/index/hotel_geo/query \
3
-d '{
4
  "from": 0,
5
  "size": 2,
6
  "fields": [
7
    "name", "geo"
8
  ],
9
  "query": {
10
    "location": {
11
      "lon": -122.4194,
12
      "lat": 37.7749
13
     },
14
    "distance": "1mi",
15
    "field": "geo"
16
  },
17
  "sort": [
18
    {
19
      "by": "geo_distance",
20
      "field": "geo",
21
      "unit": "mi",
22
      "location": {
23
        "lon": -122.4194,
24
        "lat": 37.7749
25
      }
26
    }
27
  ]
28
}'
29
 
          



  1. Query result JSON: 

JSON
 




xxxxxxxxxx
1
75


 
1
{
2
  "status": {
3
    "total": 6,
4
    "failed": 0,
5
    "successful": 6
6
  },
7
  "request": {
8
    "query": {
9
      "location": [
10
        -122.4194,
11
        37.7749
12
      ],
13
      "distance": "1mi",
14
      "field": "geo"
15
    },
16
    "size": 2,
17
    "from": 0,
18
    "highlight": null,
19
    "fields": [
20
      "name",
21
      "geo"
22
    ],
23
    "facets": null,
24
    "explain": false,
25
    "sort": [
26
      {
27
        "by": "geo_distance",
28
        "field": "geo",
29
        "location": {
30
          "lat": 37.7749,
31
          "lon": -122.4194
32
        },
33
        "unit": "mi"
34
      }
35
    ],
36
    "includeLocations": false
37
  },
38
  "hits": [
39
    {
40
      "index": "hotel_geo_72ca6700aea9283d_aa574717",
41
      "id": "hotel_25593",
42
      "score": 0.09668939164302555,
43
      "sort": [
44
        " \u0001?XA7]\u0003\u0010\u0002"
45
      ],
46
      "fields": {
47
        "geo": [
48
          -122.42000007592608,
49
          37.7739999880488
50
        ],
51
        "name": "Civic Center Hotel"
52
      }
53
    },
54
    {
55
      "index": "hotel_geo_72ca6700aea9283d_aa574717",
56
      "id": "hotel_26263",
57
      "score": 0.09668939164302555,
58
      "sort": [
59
        " \u0001?h.>\u001dOJ\"7"
60
      ],
61
      "fields": {
62
        "geo": [
63
          -122.42320003510062,
64
          37.77719998913285
65
        ],
66
        "name": "Hayes Valley Inn"
67
      }
68
    }
69
  ],
70
  "total_hits": 37,
71
  "max_score": 0.1169539736791776,
72
  "took": 720591,
73
  "facets": null
74
}
75
 
          



Dynamic Search

Use case summary: a user will find hotels by searching for a keyword that appears in any attribute of the hotel document and see a list of matching hotels.

In this case, we want to search data that is changing all the time: fields are going to be added or removed, or fields may change from a simple string to an object, and our search should find the matching landmarks at all times.  To meet this requirement, we will create a dynamic index.

Index creation steps: 

  1. On the Full Text Search UI, click “Add Index”

  2. Specify an index name, e.g. “hotel_dynamic”, and select the travel-sample bucket

  3. Since each document in the travel-sample bucket has a “type” field indicating the type of document, leave “JSON type field” set to “type”

  4. Under type mappings:  

    1. Click “+ Add Type Mapping”, and specify “hotel” as the type name, since the requirement is to search all hotel documents

    2. A list of available analyzers can be accessed by means of the pull-down menu to the right of the type name field.  For this use case, leave “inherit” selected so that the type mapping inherits the default analyzer from the index

    3. Since the requirement is to search all hotel document fields, leave “only index specified fields” unchecked.  With this unchecked, the mapping will be dynamic, meaning that all fields are considered available for indexing

    4. Click OK

    5. Finally, uncheck the checkbox next to the “default” type mapping.  If the default mapping is left enabled, all documents in the bucket are included in the index, regardless of whether the user actively specifies type mappings. Only the hotel documents are required, and they are included by the hotel type mapping added previously.

  5. The default values suffice for the remaining collapsed panels (Analyzers, Custom Filters, Date/Time Parsers, and Advanced) 

  6. Index Replicas can be set to 1, 2 or 3, provided that the cluster is running the Search service on n+1 nodes. With a single node development cluster, maintain the default value of 0. 

  7. For Index Type, the default value of “Version 6.0 (Scorch)” is appropriate for any newly created indexes. Scorch reduces the size of the index on disk, and provides enhanced performance for indexing and mutation-handling.

  8. At this point, the create index page should look like Figure 5.  Click “Create Index” to complete the process. 


Index Creation “hotel_dynamic”

Figure 6 - Index Creation “hotel_dynamic”


Note: See “Index: hotel_dynamic” in Appendix A for the JSON payload used to create this index through the REST API.  

Testing queries against the index: 

  1. On the Full Text Search UI, wait for indexing progress to show 100%, then click on the index name “hotel_dynamic”. 
  2. To search for any hotels with the keyword “farm” in any fields of the hotel documents, in the “search this index…” text box, enter “farm” and click Search.  Field-scoping of the search is not required because all fields are included in the dynamic index.
  3. The results are shown (similar to Figure 7) with the key of each matching document.

Index ““hotel_dynamic”” search results for “farm”

Figure 7 - Index ““hotel_dynamic”” search results for “farm”


  1. The same search can be run through the REST API using curl: 

JSON
 




xxxxxxxxxx
1
11


 
1
curl -u username:password -XPOST -H "Content-Type: application/json" \
2
http://localhost:8094/api/index/hotel_dynamic/query \
3
-d '{
4
  "fields": [
5
    "*"
6
  ],
7
  "query": {
8
    "query": "farm"
9
  }
10
}'
11
 
          



Appendix A — Index Definition JSON

Index: hotel_desc


JSON
 




xxxxxxxxxx
1
59


 
1
{
2
  "type": "fulltext-index",
3
  "name": "hotel_desc",
4
  "uuid": "",
5
  "sourceType": "couchbase",
6
  "sourceName": "travel-sample",
7
  "sourceUUID": "",
8
  "planParams": {
9
    "maxPartitionsPerPIndex": 171
10
  },
11
  "params": {
12
    "doc_config": {
13
      "docid_prefix_delim": "",
14
      "docid_regexp": "",
15
      "mode": "type_field",
16
      "type_field": "type"
17
    },
18
    "mapping": {
19
      "analysis": {},
20
      "default_analyzer": "standard",
21
      "default_datetime_parser": "dateTimeOptional",
22
      "default_field": "_all",
23
      "default_mapping": {
24
        "dynamic": true,
25
        "enabled": false
26
      },
27
      "default_type": "_default",
28
      "docvalues_dynamic": true,
29
      "index_dynamic": true,
30
      "store_dynamic": false,
31
      "type_field": "_type",
32
      "types": {
33
        "hotel": {
34
          "dynamic": false,
35
          "enabled": true,
36
          "properties": {
37
            "description": {
38
              "dynamic": false,
39
              "enabled": true,
40
              "fields": [
41
                {
42
                  "index": true,
43
                  "name": "description",
44
                  "type": "text"
45
                }
46
              ]
47
            }
48
          }
49
        }
50
      }
51
    },
52
    "store": {
53
      "indexType": "scorch",
54
      "kvStoreName": ""
55
    }
56
  },
57
  "sourceParams": {}
58
}
59
 
          



Index: hotel_mult_fields

JSON
 




xxxxxxxxxx
1
118


 
1
{
2
  "type": "fulltext-index",
3
  "name": "hotel_mult_fields",
4
  "uuid": "",
5
  "sourceType": "couchbase",
6
  "sourceName": "travel-sample",
7
  "sourceUUID": "",
8
  "planParams": {
9
    "maxPartitionsPerPIndex": 171
10
  },
11
  "params": {
12
    "doc_config": {
13
      "docid_prefix_delim": "",
14
      "docid_regexp": "",
15
      "mode": "type_field",
16
      "type_field": "type"
17
    },
18
    "mapping": {
19
      "analysis": {},
20
      "default_analyzer": "standard",
21
      "default_datetime_parser": "dateTimeOptional",
22
      "default_field": "_all",
23
      "default_mapping": {
24
        "dynamic": true,
25
        "enabled": false
26
      },
27
      "default_type": "_default",
28
      "docvalues_dynamic": true,
29
      "index_dynamic": true,
30
      "store_dynamic": false,
31
      "type_field": "_type",
32
      "types": {
33
        "hotel": {
34
          "dynamic": false,
35
          "enabled": true,
36
          "properties": {
37
            "address": {
38
              "dynamic": false,
39
              "enabled": true,
40
              "fields": [
41
                {
42
                  "include_in_all": true,
43
                  "include_term_vectors": true,
44
                  "index": true,
45
                  "name": "address",
46
                  "store": true,
47
                  "type": "text"
48
                }
49
              ]
50
            },
51
            "alias": {
52
              "dynamic": false,
53
              "enabled": true,
54
              "fields": [
55
                {
56
                  "include_in_all": true,
57
                  "include_term_vectors": true,
58
                  "index": true,
59
                  "name": "alias",
60
                  "store": true,
61
                  "type": "text"
62
                }
63
              ]
64
            },
65
            "description": {
66
              "dynamic": false,
67
              "enabled": true,
68
              "fields": [
69
                {
70
                  "include_in_all": true,
71
                  "include_term_vectors": true,
72
                  "index": true,
73
                  "name": "description",
74
                  "store": true,
75
                  "type": "text"
76
                }
77
              ]
78
            },
79
            "name": {
80
              "dynamic": false,
81
              "enabled": true,
82
              "fields": [
83
                {
84
                  "include_in_all": true,
85
                  "include_term_vectors": true,
86
                  "index": true,
87
                  "name": "name",
88
                  "store": true,
89
                  "type": "text"
90
                }
91
              ]
92
            },
93
            "reviews": {
94
              "dynamic": false,
95
              "enabled": true,
96
              "fields": [
97
                {
98
                  "include_in_all": true,
99
                  "include_term_vectors": true,
100
                  "index": true,
101
                  "name": "reviews",
102
                  "store": true,
103
                  "type": "text"
104
                }
105
              ]
106
            }
107
          }
108
        }
109
      }
110
    },
111
    "store": {
112
      "indexType": "scorch",
113
      "kvStoreName": ""
114
    }
115
  },
116
  "sourceParams": {}
117
}
118
 
          



Index: hotel_geo

JSON
 




xxxxxxxxxx
1
74


 
1
{
2
 "name": "hotel_geo",
3
 "type": "fulltext-index",
4
 "params": {
5
  "mapping": {
6
   "types": {
7
    "hotel": {
8
     "enabled": true,
9
     "dynamic": false,
10
     "properties": {
11
      "name": {
12
       "enabled": true,
13
       "dynamic": false,
14
       "fields": [
15
        {
16
         "name": "name",
17
         "type": "text",
18
         "store": true,
19
         "index": true,
20
         "include_term_vectors": false,
21
         "include_in_all": false
22
        }
23
       ]
24
      },
25
      "geo": {
26
       "enabled": true,
27
       "dynamic": false,
28
       "fields": [
29
        {
30
         "name": "geo",
31
         "type": "geopoint",
32
         "store": true,
33
         "index": true,
34
         "include_term_vectors": true,
35
         "include_in_all": true
36
        }
37
       ]
38
      }
39
     }
40
    }
41
   },
42
   "default_mapping": {
43
    "enabled": false,
44
    "dynamic": true
45
   },
46
   "default_type": "_default",
47
   "default_analyzer": "standard",
48
   "default_datetime_parser": "dateTimeOptional",
49
   "default_field": "_all",
50
   "store_dynamic": false,
51
   "index_dynamic": true
52
  },
53
  "store": {
54
   "indexType": "scorch",
55
   "kvStoreName": ""
56
  },
57
  "doc_config": {
58
   "mode": "type_field",
59
   "type_field": "type",
60
   "docid_prefix_delim": "",
61
   "docid_regexp": ""
62
  }
63
 },
64
 "sourceType": "couchbase",
65
 "sourceName": "travel-sample",
66
 "sourceUUID": "",
67
 "sourceParams": {},
68
 "planParams": {
69
  "maxPartitionsPerPIndex": 171,
70
  "numReplicas": 0
71
 },
72
 "uuid": ""
73
}
74
 
          



Index: hotel_dynamic

JSON
 




xxxxxxxxxx
1
44


1
{
2
 "name": "hotel_dynamic",
3
 "type": "fulltext-index",
4
 "params": {
5
  "mapping": {
6
   "types": {
7
    "hotel": {
8
     "enabled": true,
9
     "dynamic": true
10
    }
11
   },
12
   "default_mapping": {
13
    "enabled": false,
14
    "dynamic": true
15
   },
16
   "default_type": "_default",
17
   "default_analyzer": "standard",
18
   "default_datetime_parser": "dateTimeOptional",
19
   "default_field": "_all",
20
   "store_dynamic": false,
21
   "index_dynamic": true
22
  },
23
  "store": {
24
   "indexType": "scorch",
25
   "kvStoreName": ""
26
  },
27
  "doc_config": {
28
   "mode": "type_field",
29
   "type_field": "type",
30
   "docid_prefix_delim": "",
31
   "docid_regexp": ""
32
  }
33
 },
34
 "sourceType": "couchbase",
35
 "sourceName": "travel-sample",
36
 "sourceUUID": "",
37
 "sourceParams": {},
38
 "planParams": {
39
  "maxPartitionsPerPIndex": 171,
40
  "numReplicas": 0
41
 },
42
 "uuid": ""
43
}
44
 
          



Thanks for reading!

Topics:
couchbase, database, fts indexing, full text search, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}