KNN search no result

ES 8.8
When I write data for a period of time, using knn search results can not be found, but can use term search results; At this time, I put this part of the data to update_by_query, and then use the same knn search, there are results, do not know what is the cause;
knn search

GET my_index/_search?routing=xxxx
{
  "knn": {
    "field": "text_vector",
    "query_vector": [xxxxx],
    "k": 10,
    "num_candidates": 100,
    "filter": {
      "terms": {
        "code": [
          "xxxx"
        ]
      }
    }
  },
  "_source": {
    "excludes": "text_vector"
  }
}

term search

{
  "query": {
    "term": {
      "code": {
        "value": "xxx"
      }
    }
  }
}

update_by_query

POST my_index/_update_by_query?routing=xxx&refresh=true
{
  "query": {
    "term": {
      "code": {
        "value": "xxx"
      }
    }
  }
}

Given that vector search is an area moving quite quickly I would recommend upgrading to the latest version and see if you still see the same issue.

In addition to @Christian_Dahlqvist 's suggestion, I'd try without the routing key to see if this makes any difference.

And once you have upgraded, if you can reproduce this with a minimal sample script, that'd be helpful to understand what's going on here.

1 Like