ElasticSearch parsing_exception [knn]中START_ARRAY的未知键

vof42yt1  于 2023-06-29  发布在  ElasticSearch
关注(0)|答案(1)|浏览(258)

使用ElasticSearch 8.7,尝试运行以下查询,基于文档搜索多个knn字段,但得到错误标题(https://www.elastic.co/guide/en/elasticsearch/reference/8.7/knn-search.html#_search_multiple_knn_fields)
有人知道为什么吗?

q = {
  "query": {
    "match": {
      "context": {
        "query": "mountain lake",
        "boost": 0.5
      }
    }
  },
  "knn": [{
    "field": "sb_emb",
    "query_vector": vector_1,
    "k": 5,
    "num_candidates": 50,
    "boost": 0.3
  },
  {
    "field": "ins_emb",
    "query_vector":  vector_2,
    "k": 10,
    "num_candidates": 10,
    "boost": 0.5
  }],
  "size": 10
}

es_client = Elasticsearch(
                        "https://localhost:9200",
                        verify_certs=False,
                        basic_auth=(ELASTICSEARCH_USER_LOCAL, 
                        ELASTICSEARCH_PASSWORD_LOCAL)

es_client.search(body=knn_query_sb, index=INDEX_NAME)

我的Map:

{
    "properties": {
        "context": {
            "type": "text",
            "analyzer": "standard",
            "fields": {
                "keyword_field": {
                    "type": "keyword"
                }
            }
        },

        "sb_emb": {
            "type": "dense_vector",
            "dims": dim_sbert,
            "index": True,
            "similarity": "cosine",
            "index_options": {"type": "hnsw", "m": 32, "ef_construction": 128 }
        },

        "ins_emb": {
            "type": "dense_vector",
            "dims": dim_instruct,
            "index": True,
            "similarity": "cosine",
            "index_options": {"type": "hnsw", "m": 32, "ef_construction": 128 }
        },

        "doc_location": {
            "type": "text"
        }

    }
}

我尝试了Python客户端,得到了同样的错误。

yfjy0ee7

yfjy0ee71#

这是elasticsearch-py的一个问题,python包(8.8发布)不支持这个。更新到8.10(使用github主分支)解决了这个问题。

相关问题