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

FlexIndex: FlexQuery not returning right results when the query has field which is not indexed with OR operator

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      Build: 7.0.0-2016

      • Load dataset attached
      • Create fts index with below, with only name field with keyword analyzer:

        {
          "type": "fulltext-index",
          "name": "custom_index",
          "uuid": "76f7ca8314e41ed3",
          "sourceType": "gocbcore",
          "sourceName": "default",
          "sourceUUID": "291409e36b93f9299a862249ba874a90",
          "planParams": {
            "maxPartitionsPerPIndex": 171
          },
          "params": {
            "doc_config": {
              "docid_prefix_delim": "",
              "docid_regexp": "",
              "mode": "type_field",
              "type_field": "type"
            },
            "mapping": {
              "analysis": {},
              "default_analyzer": "standard",
              "default_datetime_parser": "dateTimeOptional",
              "default_field": "_all",
              "default_mapping": {
                "dynamic": true,
                "enabled": false
              },
              "default_type": "_default",
              "docvalues_dynamic": true,
              "index_dynamic": true,
              "store_dynamic": false,
              "type_field": "type",
              "types": {
                "emp": {
                  "dynamic": false,
                  "enabled": true,
                  "properties": {
                    "name": {
                      "dynamic": false,
                      "enabled": true,
                      "fields": [
                        {
                          "analyzer": "keyword",
                          "include_in_all": true,
                          "include_term_vectors": true,
                          "index": true,
                          "name": "name",
                          "type": "text"
                        }
                      ]
                    }
                  }
                }
              }
            },
            "store": {
              "indexType": "scorch",
              "mossStoreOptions": {}
            }
          },
          "sourceParams": {}
        }
        

      • For the below Flex query, Number of results returned is 14, but expecting all the docs resturned as all the docs are with mutated = 0 and type "emp"

        select meta().id from default USE INDEX (USING FTS, USING GSI) where type = "emp" and  ( ( name like "Kagami%") OR (mutated = 0)) ORDER BY meta().id ASC
        

      • Explain plan

        {
            "#operator": "Sequence",
            "~children": [
                {
                    "#operator": "Sequence",
                    "~children": [
                        {
                            "#operator": "IndexFtsSearch",
                            "index": "custom_index",
                            "index_id": "76f7ca8314e41ed3",
                            "keyspace": "default",
                            "namespace": "default",
                            "search_info": {
                                "field": "\"\"",
                                "options": "{\"index\": \"custom_index\"}",
                                "outname": "out",
                                "query": "{\"query\": {\"field\": \"name\", \"inclusive_max\": false, \"inclusive_min\": true, \"max\": \"Kagamj\", \"min\": \"Kagami\"}, \"score\": \"none\"}"
                            },
                            "using": "fts"
                        },
                        {
                            "#operator": "Fetch",
                            "keyspace": "default",
                            "namespace": "default"
                        },
                        {
                            "#operator": "Parallel",
                            "~child": {
                                "#operator": "Sequence",
                                "~children": [
                                    {
                                        "#operator": "Filter",
                                        "condition": "(((`default`.`type`) = \"emp\") and (((`default`.`name`) like \"Kagami%\") or ((`default`.`mutated`) = 0)))"
                                    },
                                    {
                                        "#operator": "InitialProject",
                                        "result_terms": [
                                            {
                                                "expr": "(meta(`default`).`id`)"
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    ]
                },
                {
                    "#operator": "Order",
                    "sort_terms": [
                        {
                            "expr": "(meta(`default`).`id`)"
                        }
                    ]
                }
            ]
        }
        

      Attachments

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

        Activity

          People

            abhinav Abhi Dangeti
            girish.benakappa Girish Benakappa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty