Concatenate a value of three fields in the a new filed


(marxper) #1

Hello every one,
I want to replace 3 fields that contains string(date) , string(time) and string(tz) by a new field with date type that contains (date+time+tz) converted.

{
"query":{
"bool":{
"must_not":{
"exists":{
"field":"new_date"
}
}
}
},
"script":{
"inline":"ctx._source.new_date = ctx._source.date + ctx._source.time + ctx._source.tz",
"lang":"groovy"
}
}

But before that how can i concatenate them because like this whay i have a scrpt exception?

This is what i have :

GET myindex/_search
{
  "query": {
  "match_all": {}
  }
}


"hits": {
"total": 148563278,
"max_score": 1,
"hits": [
  {
    "_index": "myindex",
    "_type": "mytype",
    "_id": "1",
    "_score": 1,
    "_source": {
      "date": "2016-06-30",
      "tz": "UTC",
      "time": "10:21:16",

I want to :
add 2 other fields:

  • field1 = date_time_tz_str ( string : concatenation of 3 fields )
  • field2 = date_time_tz ( timestamp ) conversion of field ( date_time_tz_str)

Thank you for your help


(Simon Willnauer) #2

do you want to create a new field at index time or do you want to build a value for an existing doc at query time that you are querying?


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.