FTS index creation programmatically does not work


After creating an FTS index programmatically for a specific scope, collection, and field as shown in the SearchIndex JSON below. CB creates the “default” index and does not honor scope, collection, or field mappings.

I am using the 7.0.0-3739 CB server with Java SDK. Btw, when creating manually through Web Console same JSON works.

// SearchIndex JSON
  "name": "fts_TestSheet_sheetStore_v1",
  "sourceName": "TestDb",
  "type": "fulltext-index",
  "params": {
    "doc_config": {
      "docid_prefix_delim": "",
      "docid_regexp": "",
      "mode": "scope.collection.type_field",
      "type_field": "type"
    "mapping": {
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": false,
        "enabled": false
      "default_type": "",
      "docvalues_dynamic": false,
      "index_dynamic": false,
      "store_dynamic": false,
      "type_field": "_type",
      "types": {
        "TestSheet.sheetStore": {
          "dynamic": false,
          "enabled": true,
          "properties": {
            "t9": {
              "dynamic": false,
              "enabled": true,
              "fields": [
                  "name": "t9",
                  "type": "text",
                  "index": true,
                  "include_in_all": true,
                  "docvalues": true,
                  "include_term_vectors": true
    "store": {
      "indexType": "scorch",
      "segmentVersion": 15
  "sourceParams": {},
  "sourceType": "gocbcore",
  "planParams": {
    "maxPartitionsPerPIndex": 64,
    "indexPartitions": 1,
    "numReplicas": 0

Neome Web

I am having this problem as well.

The AsyncSearchIndexManager serializes the SearchIndex instance using the SearchIndex#toJson method.
The SearchIndex#toJson however seems to only include uuid, name, sourceName, type and sourceType fields in the JSON output. Is this on purpose?

Calling the REST API directly may bypass the SearchIndex#toJson method. Please let me know if you figure this out.

Would have to hardcode the REST port and going through SDK is better…

The index definition looks fine … you’re trying to set up an index for bucket: TestDb, scope: TestSheet, collection: sheetScore. So if you send a HTTP request directly via rest request - I’d expect things to work.

CB creates the “default” index and does not honor scope, collection, or field mappings.

@Neome_Web Do you mean to say - that a default mapped index is being set up here when you use the SDK with the above definition? Could you be a little more specific here?

I’ll also ping @daschl here - does the SDK validate doc_config settings? I didn’t think it did.

Like @Mico_Piira says the problem is in Java SDK. Please look at the CB code below,

package com.couchbase.client.java.manager.search;

public class SearchIndex

  public String toJson() {
    Map<String, Object> output = new HashMap<>();
    // A UUID is server-assigned.  It must be specified on an update, and must not be specified on a create.
    if (uuid != null) {
      output.put("uuid", uuid);
    output.put("name", name);
    output.put("sourceName", sourceName);
    output.put("type", type == null ? "fulltext-index" : type);
    output.put("sourceType", sourceType == null ? "couchbase" : sourceType);
    return Mapper.encodeAsString(output);

toJson() method does not form the correct JSON.

In Java SDK, when I use the json above to create SearchIndex and use ReactiveSearchIndexManager to upsertIndex(SearchIndex index). The method drops the scope, collection, and field mappings most probably because toJson() method is not including the information.

@Neome_Web Thanks for pointing this out.

I’ll ping @ingenthr and @daschl for this.

Please let me know when this is fixed. It is a show stopper for us.

@Neome_Web we addressed this bug very recently and it will be fixed in the next release.