Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-50706

n1fty: SEARCH(t,{ "match_all": {} }) on non-dynamic typed index - n1fty: not sargable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.1.0
    • 7.1.0
    • fts
    • Untriaged
    • 1
    • Unknown

    Description

      Build: 7.1.0-2197

      Index:

      {
        "type": "fulltext-index",
        "name": "test1",
        "uuid": "184bb1f3dec60953",
        "sourceType": "gocbcore",
        "sourceName": "default",
        "sourceUUID": "f0f5eff3881e810707ecb2732fbe7d25",
        "planParams": {
          "maxPartitionsPerPIndex": 1024,
          "indexPartitions": 1
        },
        "params": {
          "doc_config": {
            "docid_prefix_delim": "",
            "docid_regexp": "",
            "mode": "type_field",
            "type_field": "type"
          },
          "mapping": {
            "analysis": {},
            "default_analyzer": "keyword",
            "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": {
              "hotel": {
                "dynamic": false,
                "enabled": true,
                "properties": {
                  "company": {
                    "dynamic": false,
                    "enabled": true,
                    "fields": [
                      {
                        "index": true,
                        "name": "company",
                        "type": "text"
                      }
                    ]
                  }
                }
              }
            }
          },
          "store": {
            "indexType": "scorch",
            "segmentVersion": 15
          }
        },
        "sourceParams": {}
      }
      

      INSERT INTO default VALUES("f01",{"type":"hotel", "company":"999"});
      INSERT INTO default VALUES("f02",{"type":"airport", "company":"999"});
      SELECT META(t).id 
      FROM `default` AS t USE INDEX (USING FTS) 
      WHERE t.type="hotel"  AND SEARCH(t,{ "match_all": {} });
      

      Above query errors like below:

      [
        {
          "code": 5000,
          "msg": "n1fty: not sargable",
          "query": "SELECT META(t).id \nFROM `default` AS t USE INDEX (USING FTS) \nWHERE t.type=\"hotel\"  AND SEARCH(t,{ \"match_all\": {} });"
        }
      ]
      

      Explain of the above query works fine:

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "IndexFtsSearch",
                  "as": "t",
                  "index": "test1",
                  "index_id": "184bb1f3dec60953",
                  "keyspace": "default",
                  "namespace": "default",
                  "search_info": {
                      "field": "\"\"",
                      "options": "{\"index\": \"test1\"}",
                      "outname": "out",
                      "query": "{\"query\": {\"boost\": null, \"match_all\": {}}, \"score\": \"none\"}"
                  },
                  "using": "fts"
              },
              {
                  "#operator": "Fetch",
                  "as": "t",
                  "keyspace": "default",
                  "namespace": "default"
              },
              {
                  "#operator": "Parallel",
                  "~child": {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "Filter",
                              "condition": "(((`t`.`type`) = \"hotel\") and search(`t`, {\"match_all\": {}}))"
                          },
                          {
                              "#operator": "InitialProject",
                              "result_terms": [
                                  {
                                      "expr": "(meta(`t`).`id`)"
                                  }
                              ]
                          }
                      ]
                  }
              }
          ]
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: MB-50706
          # Subject Branch Project Status CR V

          Activity

            People

              girish.benakappa Girish Benakappa
              girish.benakappa Girish Benakappa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty