Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ES7 Update new completion with context field based on indexed values for every document using Update by query endpoint

I am trying to update a value from an ES index that is mapped as a completion field with a context for filtering.

I want to insert values based on the values that I already have in a document.

I tried this, which doesn’t work as as expected because it just takes the string, not the value, which was expected, but I tried it anyhow:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
    "script": {
        "inline": "ctx._source.suggest_test = params.newProp",
        "params": {
            "newProp": {
                "input": "ctx._source.search_text",
                "contexts": {
                    "type": ["ctx._source.type"]
                }
            }
        }
    }
}

and this, multiple versions of it, all of them returning errors

{
    "script": "ctx._source.search_text_completion = {\"input\":[ctx._source.search_text],\"contexts\":{\"type\": [ctx._source.type]}}"
}

Is there a way to do this or do I have to reindex everything?

>Solution :

You have to do it like this (with square brackets):

"script": "ctx._source.search_text_completion = ['input':[ctx._source.search_text],'contexts':['type': [ctx._source.type]]]"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading