Multiple Inner_hit on knn

here my index mapping:

{
  "chunker2": {
    "aliases": {},
    "mappings": {
      "properties": {
        "creation_time": {
          "type": "date"
        },
        "full_text": {
          "type": "text"
        },
        "paragraph": {
          "type": "nested",
          "properties": {
            "paragraph_id": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "text": {
              "type": "text",
              "index": false
            },
            "vector": {
              "type": "dense_vector",
              "dims": 2,
              "index": true,
              "similarity": "cosine"
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "chunker2",
        "creation_date": "1706287328649",
        "number_of_replicas": "1",
        "uuid": "yStzE38xTx2EgZnGswDslg",
        "version": {
          "created": "8500003"
        }
      }
    }
  }
}

I need to perform a KNN on it but receiving back multiple inner_hit.
So if have 2 document with 2 vector inside both (total of 4 vector)
i want to receive back 4 vector similar to this:


POST chunker2/_search
{
    "fields": [
        "creation_time",
        "full_text"
    ],
    "_source": false,
    "knn": {
        "query_vector": [
            0.45,
            45
        ],
        "field": "paragraph.vector",
        "k": 4,
        "num_candidates": 6,
        "inner_hits": {
**A WAY HERE TO RETURN MULTIPLE HIT?**
            "fields": [
                "paragraph.text"
            ]
        }
    }
}

is it possible to retrive for each sub/nested field the KNN score?

@Tommaso_FAVARON

It will be available in a future release: Add support for more than one inner_hit when searching nested vectors by benwtrent · Pull Request #104006 · elastic/elasticsearch · GitHub

The current release of Elasticsearch (<= 8.12) doesn't support it.

Thank you very much for the reply @BenTrent .
Do you know if there is any ETA for this features to be released?

Hi @BenTrent I think from the release 8.12.1 this features is avalable?
Can you confirm this?
Thanks,
Tommaso.

@Tommaso_FAVARON ,

Sorry to disappoint, but it will be in 8.13 :(. We try our best to not add features in bugFix releases to ensure stability and ease of upgrade for folks in the previous bugfix release.

So, new features are generally released in minor versions (8.13 in this case).

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.