Search code examples
elasticsearchkibana

how to change elasticsearch type keyword to array?


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.


Solution

  • 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;
            """
          }
        }
      }
    }