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

KNN queries (that do not use a search index) are not adding any value if run along with AND queries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • 7.6.2
    • 7.6.2
    • fts
    • None
    • Untriaged
    • 0
    • Unknown

    Description

      Normal query 

      SELECT c.Car, c.ColorFROM store sJOIN car c ON c.Car = "Bentley"  and c.Color like "%blue%"  AND "Bentley" IN s.AvailableCars

      This shows all cars which are of blue color

      [  {    "Car": "Bentley",    "Color": "dull blue"  },  {    "Car": "Bentley",    "Color": "pastel blue"  },  {    "Car": "Bentley",    "Color": "very dark blue"  },  {    "Car": "Bentley",    "Color": "water blue"  }] 

       

      Now instead of  c.Color like "%blue%" I try out a vector query I am getting all sorts of color except the blue

       

      Query:

      SELECT c.Car, c.ColorFROM store sJOIN car c ON c.Car = "Bentley" AND "Bentley" IN s.AvailableCarsandSEARCH(c, {    "query": {        "match_none": {}    },    "knn": [{        "field": "color_rgb_vector",        "vector": [0,0,255],         "k": 3    }]}) 

      [  {    "Car": "Bentley",    "Color": "lighter green"  },  {    "Car": "Bentley",    "Color": "dusky rose"  },  {    "Car": "Bentley",    "Color": "dull blue"  },  {    "Car": "Bentley",    "Color": "dark plum"  },  {    "Car": "Bentley",    "Color": "deep lavender"  },  {    "Car": "Bentley",    "Color": "grey pink"  },  {    "Car": "Bentley",    "Color": "orange yellow"  }, 

      Now one reason could be that the embedding model could say that the closest color to blue are these returned colors but thats not the case because

      {    "query":{       "match_none":{        }    },    "explain":true,    "knn":[{       "field":"color_rgb_vector",       "k":2,       "vector":  [0,0,255] }] } 
       
      Returns 
       "Color": "rich blue"
        "Color": "vivid blue",
        "Color": "light royal blue",

       

      Attachments

        1. cars_demo.json
          12.69 MB
        2. colors_demo.json
          111 kB
        3. FtsIndex.json
          3 kB
        4. Screenshot 2024-04-18 at 1.06.19 PM.png
          Screenshot 2024-04-18 at 1.06.19 PM.png
          113 kB
        5. Screenshot 2024-04-18 at 1.15.36 PM.png
          Screenshot 2024-04-18 at 1.15.36 PM.png
          100 kB
        6. Screenshot 2024-04-19 at 4.04.35 PM.png
          Screenshot 2024-04-19 at 4.04.35 PM.png
          52 kB
        7. stores_demo.json
          4 kB

        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
              sarthak.dua Sarthak Dua
              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