Add _timestamp on already inserted document

Hi all,

I try to add _timestamp field into my documents.
For example, let assume that I have document tweet :
curl-XGET http://localhost:9200/twitter/tweet/_mapping

{

"tweet" : {
"properties" : {
"author" : {
"type" : "string",
"store" : "yes"
},
"text" : {
"type" : "string",
"store": "yes"
}
}

}

curl -XPUT http://localhost:9200/twitter/tweet/2 -d '
{
"author" : "test",
"text" : "Toto"
}'

Now, I want to add _timestamp to this document so I modify the mapping like
this :
curl -XPUT "$baseUrl/transactions/_mapping?pretty=true" -d '
{
"transactions" : {
"properties" : {
"author" : {

          "type" : "string",
          "store" : "yes"
        },
       "text" : {
          "type" : "string"
       },
       "_timestamp" : {"enabled" : true}

   }
 }

}

The question is : Is there a way to add _timestamp field on documents that
are already inserted ? In this case, in my tweet.
I saw the update in the API but I don't know which script should I use to
do. Do you have example to do a such thing ?

Regards

--

You cannot enable timestamp for the types that are already created. You
will have to delete the type and reindex all records into it again.

By the way, when you will create the new type, move the _mapping definition
to the same level as properties (not inside properties) so it looks like
this:

{
"tweet" : {
"properties" : {
"author" : {
"type" : "string",
"store" : "yes"
},
"text" : {
"type" : "string"
}
},
"_timestamp" : {"enabled" : true}
}
}

On Tuesday, December 11, 2012 4:11:44 AM UTC-5, Alexandre Gindre wrote:

Hi all,

I try to add _timestamp field into my documents.
For example, let assume that I have document tweet :
curl-XGET http://localhost:9200/twitter/tweet/_mapping

{

"tweet" : {
"properties" : {
"author" : {
"type" : "string",
"store" : "yes"
},
"text" : {
"type" : "string",
"store": "yes"
}
}

}

curl -XPUT http://localhost:9200/twitter/tweet/2 -d '
{
"author" : "test",
"text" : "Toto"
}'

Now, I want to add _timestamp to this document so I modify the mapping
like this :
curl -XPUT "$baseUrl/transactions/_mapping?pretty=true" -d '
{
"transactions" : {
"properties" : {
"author" : {

          "type" : "string",
          "store" : "yes"
        },
       "text" : {
          "type" : "string"
       },
       "_timestamp" : {"enabled" : true}

   }
 }

}

The question is : Is there a way to add _timestamp field on documents
that are already inserted ? In this case, in my tweet.
I saw the update in the API but I don't know which script should I use to
do. Do you have example to do a such thing ?

Regards

--

Thank you for the tip.

2012/12/13 Igor Motov imotov@gmail.com

You cannot enable timestamp for the types that are already created. You
will have to delete the type and reindex all records into it again.

By the way, when you will create the new type, move the _mapping
definition to the same level as properties (not inside properties) so it
looks like this:

{
"tweet" : {
"properties" : {
"author" : {
"type" : "string",
"store" : "yes"
},
"text" : {
"type" : "string"
}
},
"_timestamp" : {"enabled" : true}
}
}

On Tuesday, December 11, 2012 4:11:44 AM UTC-5, Alexandre Gindre wrote:

Hi all,

I try to add _timestamp field into my documents.
For example, let assume that I have document tweet :
curl-XGET http://localhost:9200/twitter/**tweet/_mapping

{

"tweet" : {

"properties" : {
  "author" : {

    "type" : "string",

    "store" : "yes"
  },

  "text" : {
    "type" : "string",

    "store": "yes"
  }

}

}

curl -XPUT http://localhost:9200/twitter/**tweet/2 -d '
{
"author" : "test",
"text" : "Toto"
}'

Now, I want to add timestamp to this document so I modify the mapping
like this :
curl -XPUT "$baseUrl/transactions/
**mapping?pretty=true" -d '
{
"transactions" : {
"properties" : {
"author" : {

          "type" : "string",

          "store" : "yes"

        },
       "text" : {

          "type" : "string"

       },
       "_timestamp" : {"enabled" : true}

   }
 }

}

The question is : Is there a way to add _timestamp field on documents
that are already inserted ? In this case, in my tweet.
I saw the update in the API but I don't know which script should I use to
do. Do you have example to do a such thing ?

Regards

--

--
Alexandre Gindre

--