Demonstration Indexes

Demonstration indexes are provided, to exemplify the running of Full Text Searches.

Using Demonstration Indexes

An extensive code-example, which uses the Couchbase Java SDK, is provided in java-sdk::full-text-searching-with-sdk.adoc. This relies on three index definitions, respectively named travel-sample-index-unstored, travel-sample-index-stored, and travel-sample-index-hotel-definition. Therefore, for the code-example to be successfully run, the three indexes must be established on Couchbase Server.

Optionally, the indexes can each be set up by means of the Couchbase Web Console, based on the descriptions provided in java-sdk::full-text-searching-with-sdk.adoc. Information on this process is provided in Creating Indexes. However, each index can also be established by means of a single REST command, which specifies all required index-details as a JSON document. Information on doing so can be found in the section Index-Creation with the REST API, on the Creating Indexes page. The three definitions are provided below.

This page also provides a definition for the geoIndex definition, used in the section Geospatial Queries.

Index Definition: travel-sample-index-unstored

{
  "name": "travel-sample-index-unstored",
  "type": "fulltext-index",
  "params": {
    "doc_config": {
      "mode": "type_field",
      "type_field": "type"
    },
    "mapping": {
      "analysis": {
        "analyzers": {
          "singleAnalyzer": {
            "tokenizer": "single",
            "type": "custom"
          }
        }
      },
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": true
      },
      "default_type": "_default",
      "index_dynamic": true,
      "store_dynamic": false,
      "type_field": "type"
    },
    "store": {
      "kvStoreName": "mossStore"
    }
  },
  "sourceType": "couchbase",
  "sourceName": "travel-sample",
  "sourceUUID": "",
  "sourceParams": {},
  "planParams": {
    "maxPartitionsPerPIndex": 171,
    "numReplicas": 0
  },
  "uuid": ""
}

Index Definition: travel-sample-index-stored

{
  "name": "travel-sample-index-stored",
  "type": "fulltext-index",
  "params": {
    "doc_config": {
      "mode": "type_field",
      "type_field": "type"
    },
    "mapping": {
      "analysis": {
        "analyzers": {
          "letterAnalyzer": {
            "tokenizer": "letter",
            "type": "custom"
          }
        }
      },
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": true
      },
      "default_type": "_default",
      "index_dynamic": true,
      "store_dynamic": true,
      "type_field": "type"
    },
    "store": {
      "kvStoreName": "mossStore"
    }
  },
  "sourceType": "couchbase",
  "sourceName": "travel-sample",
  "sourceUUID": "",
  "sourceParams": {},
  "planParams": {
    "maxPartitionsPerPIndex": 171,
    "numReplicas": 0
  },
  "uuid": ""
}

Index Definition: travel-sample-index-hotel-description

{
  "name": "travel-sample-index-hotel-description",
  "type": "fulltext-index",
  "params": {
    "doc_config": {
      "mode": "type_field",
      "type_field": "type"
    },
    "mapping": {
      "analysis": {
        "analyzers": {
          "myUnicodeAnalyzer": {
            "tokenizer": "unicode",
            "type": "custom"
          }
        }
      },
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": false
      },
      "default_type": "_default",
      "index_dynamic": true,
      "store_dynamic": true,
      "type_field": "type",
      "types": {
        "hotel": {
          "dynamic": false,
          "enabled": true,
          "properties": {
            "description": {
              "enabled": true,
              "dynamic": false,
              "fields": [
                {
                  "include_in_all": true,
                  "include_term_vectors": true,
                  "index": true,
                  "name": "description",
                  "store": true,
                  "type": "text"
                }
              ]
            }
          }
        }
      }
    },
    "store": {
      "kvStoreName": "mossStore"
    }
  },
  "sourceType": "couchbase",
  "sourceName": "travel-sample",
  "sourceUUID": "",
  "sourceParams": {},
  "planParams": {
    "maxPartitionsPerPIndex": 171,
    "numReplicas": 0
  },
    "uuid": ""
}

Index Definition: geoIndex

The following index is used to support the geospatial queries described in Geospatial Queries.

{
  "type": "fulltext-index",
  "name": "geoIndex",
  "uuid": "",
  "sourceType": "couchbase",
  "sourceName": "travel-sample",
  "sourceUUID": "",
  "planParams": {
    "maxPartitionsPerPIndex": 171
  },
  "params": {
    "doc_config": {
      "mode": "type_field",
      "type_field": "type"
    },
    "mapping": {
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": true,
        "properties": {
          "geo": {
            "dynamic": false,
            "enabled": true,
            "fields": [
              {
                "analyzer": "",
                "include_in_all": true,
                "include_term_vectors": true,
                "index": true,
                "name": "geo",
                "store": true,
                "type": "geopoint"
              }
            ]
          }
        }
      },
      "default_type": "_default",
      "index_dynamic": true,
      "store_dynamic": false
    },
    "store": {
      "kvStoreName": "mossStore"
    }
  },
  "sourceParams": {}
}