Home > Enterprise >  how to change elasticsearch type keyword to array?
how to change elasticsearch type keyword to array?

Time:11-25

POST /jobs/_doc/1/
{
  "test": [["A", "B"], ["C", "A"]]
}
GET /jobs/_search/
{
  "_source": false,
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      },
      "script": {
        "source": """
          Debug.explain(doc['test.keyword']);
          return 1;
        """
      }
    }
  }
}

kibana print to string is "[A, B, C]", how can i get like [["A", "B"], ["B", "C"]] in painless script?

i try to change mapping but it cant work always.

CodePudding user response:

Tldr;

You can't via indexed fields. BUT it is possible is you access the source

Solution

GET 74557564/_search
{
  "_source": false,
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      }, 
      "script": {
        "source": """
          Debug.explain(params._source['data']);
          return 1;
        """
      }
    }
  }
}
  • Related