Search application mustache template issue when passing floats vs integers

I am using a search_application, mustache template to execute a KNN search. The following is the relevant section of the template:

 "knn": [
          {
            "field": "content_embedding_external.predicted_value",
            "k": {{knn_size}},
            "num_candidates": {{knn_num_of_candidates}},
            "boost": {{vector_content_boost}},
            "similarity": "{{{knn_minimum_similarity}}}",
            "query_vector": {{{query_string_embeddings}}}
            ]
          }

The endpoint is:

/_application/search_application/template_search-arroway-v1/_render_query

Here's the thing, when I pass in (abbreviated for the purpose of this post):

{
  "params": {
    "query_string_embeddings": "[0,1,2]"
  }
}

Everything works as expected. That is the KNN query_vector displays with the array value of: [0,1,2] as one would expect.

BUT, if I pass the parameter as it needs to be (ADA embedding), like:

"query_string_embeddings": "[-0.021204991,-0.013258362,0.011000876]",

I get the error:

{
    "error": {
        "root_cause": [
            {
                "type": "null_pointer_exception",
                "reason": "Cannot invoke \"com.fasterxml.jackson.core.JsonLocation.getLineNr()\" because \"loc\" is null"
            }
        ],
        "type": "null_pointer_exception",
        "reason": "Cannot invoke \"com.fasterxml.jackson.core.JsonLocation.getLineNr()\" because \"loc\" is null"
    },
    "status": 500
}

I would appear that underlying search template/jackson json parsing, has a bug related to floats. Then again, I might need to encode passing of the parameters differently.

Suggestions?

Hi @David_Lowe thanks for reaching out about this. This is a known bug with search applications, you can track it here: Search Application Template: use decimal value as param triggers error · Issue #116246 · elastic/elasticsearch · GitHub

Unfortunately it looks like right now the workaround is to use search templates in Elasticsearch rather than the templates provided in search applications.

Well that's far from ideal. At least I won't beat my head against the wall trying to figure out why it isn't working as expected. So thank you.

Anyways, is this defect on an actual roadmap to be fixed? Or is just sitting pending prioritization. If the former, are you able to share the anticipated release?

Hi @David_Lowe - it hasn't been prioritized yet, we're still planning out how we'd like to progress with Search Applications. As @Kathleen_DeRusso mentioned, I'd encourage you to see if search templates works for you!