# Multiple Inner\_hit on knn

**URL:** <https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [January 26, 2024, 5:49pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893 "2024-01-26T17:49:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [January 26, 2024, 5:49pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/1 "2024-01-26T17:49:27Z")

</div>

here my index mapping:

```auto
{
  "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:

```auto

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?

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [January 26, 2024, 7:04pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/2 "2024-01-26T19:04:35Z")

</div>

@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](https://github.com/elastic/elasticsearch/pull/104006)

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

---

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [January 27, 2024, 12:09pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/3 "2024-01-27T12:09:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [February 8, 2024, 10:55am UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/4 "2024-02-08T10:55:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [February 8, 2024, 1:11pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/5 "2024-02-08T13:11:35Z")

</div>

@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).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 7, 2024, 1:11pm UTC](https://discuss.elastic.co/t/multiple-inner-hit-on-knn/351893/6 "2024-03-07T13:11:43Z")

</div>

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