0

I am trying to convert an array of strings to regular string.but with my spec file,it comes back as array always

Sample input (from ES)

{
    ...
    "hits": {
        "total": 1,
        "max_score": 1.4818809,
        "hits": [
            {
                "_index": "twitter",
                "_type": "tweet",
                "_id": "1",
                "_score": 1.4818809,
                "_source": {
                    "user": "test",
                    "message": "some message with the number 1",
                    "date": "2009-11-15T14:12:12",
                    "likes": 1
                },
                "highlight": {
                    "message": [
                        "some message with the <em>number</em> <em>1</em>"
                    ]
                }
            }
        ]
    }
}

Spec file

[
  {
    "operation": "shift",
    "spec": {
      "took": "took",
      "hits": {
        "total": "total_hits",
        "hits": {
          "*": {
            "_source": {
              "user": "Response[&2].firstName"
            },
            "highlight": {
              "message": ["Response[&2].h_message"]
            }
          }
        }
      }
    }
}
]

Output:

{
  "Response" : [ {
    "firstName" : "test",
    "h_message" : [ "some message with the <em>number</em> <em>1</em>" ]
  } ],
  "total_hits" : 1
}

As you could see,"h_message" is coming out as an array.I am trying to get is a string/value

 "h_message" : [ "some message with the <em>number</em> <em>1</em>" ]
user2297083
  • 168
  • 11

1 Answers1

0

Solved it

[
  {
    "operation": "shift",
    "spec": {
      "took": "took",
      "hits": {
        "total": "total_hits",
        "hits": {
          "*": {
            "_source": {
              "user": "Response[&2].firstName"
            },
            "highlight": {
              "message": {
                "*": "Response[&0].h_message"
              }
            }
          }
        }
      }
    }
}
]
user2297083
  • 168
  • 11