# Dynamic method \[org.opensearch.knn.index.KNNVectorScriptDocValues.KNNNativeVectorScriptDocValues, getValue/0\] not found

**URL:** <https://forum.opensearch.org/t/dynamic-method-org-opensearch-knn-index-knnvectorscriptdocvalues-knnnativevectorscriptdocvalues-getvalue-0-not-found/22581>\
**Category:** k-NN\
**Created:** [November 26, 2024, 11:54pm UTC](https://forum.opensearch.org/t/dynamic-method-org-opensearch-knn-index-knnvectorscriptdocvalues-knnnativevectorscriptdocvalues-getvalue-0-not-found/22581 "2024-11-26T23:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asolodin](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@asolodin](https://forum.opensearch.org/u/asolodin)\
**Post date:** [November 26, 2024, 11:54pm UTC](https://forum.opensearch.org/t/dynamic-method-org-opensearch-knn-index-knnvectorscriptdocvalues-knnnativevectorscriptdocvalues-getvalue-0-not-found/22581/1 "2024-11-26T23:54:40Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):

v 2.15.0

**Describe the issue** :

We have a knn\_vector field which has double values. I would like to convert them to floats for retrieval (we use the vector values for feature generation). I was hoping to do something like this (maybe also convert float to a list)

“script\_fields”: { “emb”: { “script”: {“lang”: “painless”,“source”: “doc[‘embedding’].getValue()” }}}

This fails with the title message. Looking at the code, I see getValue() method [here](https://github.com/opensearch-project/k-NN/blob/0bbeac37327d744e899241326a75b04653cbbb5c/src/main/java/org/opensearch/knn/index/KNNVectorScriptDocValues.java#L45). I see that the getValue() method is [allowed](https://github.com/opensearch-project/k-NN/blob/0bbeac37327d744e899241326a75b04653cbbb5c/src/main/resources/org/opensearch/knn/plugin/script/knn_allowlist.txt#L7) So I am confused why this doesn’t work.

This works and does what I want

“script\_fields”: { “emb”: { “script”: {“lang”: “painless”,“source”: “params.\_source[‘embedding’].stream().map(v → (float)v).collect(Collectors.toList())” }}}

but I read that accessing fields through \_source is slow. Is there any way to get the values directly from the fields.

**Configuration**

field mapping:

```
  "embedding": {
    "full_name": "embedding",
    "mapping": {
      "embedding": {
        "type": "knn_vector",
        "dimension": 768,
        "method": {
          "engine": "faiss",
          "space_type": "innerproduct",
          "name": "hnsw",
          "parameters": {
            "ef_construction": 512,
            "encoder": {
              "name": "sq",
              "parameters": {}
            },
            "m": 16
          }
        }
      }
    }
  }

```

---

<div class="post-metadata">

**Author:** ![asolodin](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@asolodin](https://forum.opensearch.org/u/asolodin)\
**Post date:** [December 13, 2024, 11:02pm UTC](https://forum.opensearch.org/t/dynamic-method-org-opensearch-knn-index-knnvectorscriptdocvalues-knnnativevectorscriptdocvalues-getvalue-0-not-found/22581/2 "2024-12-13T23:02:58Z")

</div>

I tested it with latest main and it actually works. So I guess I just need to wait till AWS upgrades.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [February 11, 2025, 11:03pm UTC](https://forum.opensearch.org/t/dynamic-method-org-opensearch-knn-index-knnvectorscriptdocvalues-knnnativevectorscriptdocvalues-getvalue-0-not-found/22581/3 "2025-02-11T23:03:10Z")

</div>

Closed on February 11, 2025, 11:03pm UTC

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