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

Hybrid SQL++ Vector queries have differing results if there is a GSI index.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.6.4
    • 7.6.0, 7.6.2, 7.6.1
    • fts, query
    • Untriaged
    • 0
    • Unknown

    Description

      The following query works as expected (it provides a filter for high selectivity) in other words I am forcing the brightness to be < 20. 

      SELECT id, color, verbs, brightness
      FROM `vector-sample`.color.rgb AS t1
      WHERE 
          brightness < 20
      AND SEARCH(t1, {
        "query": {  "match_none": {} },
        "knn_operator": "and",
        "knn": [
          {
              "field": "colorvect_l2",
              "vector": [0.0, 0.0, 127.7],
              "k": 3 
          }, {
              "field": "colorvect_dot",
              "vector": [0.0, 0.0, 1.0],
              "k": 3 
          }
        ]
      })

      But If I add an index here I just use the index advisor

      CREATE INDEX adv_brightness ON `default`:`vector-sample`.`color`.`rgb`(`brightness`)

      And re-run the same query I get a different result.

       

      The FTS index definition:

       

      { "type": "fulltext-index", "name": "vector-sample.color.color_vector_index", "sourceType": "gocbcore", "sourceName": "vector-sample", "planParams": \{ "maxPartitionsPerPIndex": 512, "indexPartitions": 2 }
      ,
      "params": {
      "doc_config":
      { "docid_prefix_delim": "", "docid_regexp": "", "mode": "scope.collection.type_field", "type_field": "type" }
      ,
      "mapping": {
      "analysis": {},
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
      "dynamic": false,
      "enabled": false
      },
      "default_type": "_default",
      "docvalues_dynamic": false,
      "index_dynamic": false,
      "store_dynamic": false,
      "type_field": "_type",
      "types": {
      "color.rgb": {
      "dynamic": false,
      "enabled": true,
      "properties": {
      "brightness": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "index": true, "name": "brightness", "store": true, "type": "number" }
      ]
      },
      "color": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "analyzer": "en", "index": true, "name": "color", "store": true, "type": "text" }
      ]
      },
      "colorvect_dot": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "dims": 3, "index": true, "name": "colorvect_dot", "similarity": "dot_product", "type": "vector" }
      ]
      },
      "colorvect_l2": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "dims": 3, "index": true, "name": "colorvect_l2", "similarity": "l2_norm", "type": "vector" }
      ]
      },
      "embedding_vector_dot": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "dims": 1536, "index": true, "name": "embedding_vector_dot", "similarity": "dot_product", "type": "vector" }
      ]
      },
      "wheel_pos": {
      "dynamic": false,
      "enabled": true,
      "fields": [
      { "analyzer": "en", "index": true, "name": "wheel_pos", "store": true, "type": "text" }
      ]
      }
      }
      }
      }
      },
      "store": {
      "indexType": "scorch",
      "segmentVersion": 16
      }
      },
      "sourceParams": {}
      }
      

      The fts data is attached as "rgb.json"

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              sarthak.dua Sarthak Dua
              jon.strabala Jon Strabala
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty