How to store current date

If I have mapping as below
{
"name" : { "type" : "string"},
"location" : { "type" : "string" },
"created_date" : { "type" : "date"}
}

Is it possible to put current date to "created_date" field automatically?
If yes, How to do?

Thanks
Hiko

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You can use the _timestamp field to generate a date.
If you really need to copy the value in another field, you could use copy_to.

None will update _source though.

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 févr. 2015 à 09:23, tao hiko taohiko@gmail.com a écrit :

If I have mapping as below
{
"name" : { "type" : "string"},
"location" : { "type" : "string" },
"created_date" : { "type" : "date"}
}

Is it possible to put current date to "created_date" field automatically? If yes, How to do?

Thanks
Hiko

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/E3532D4C-9E7C-4AF9-ACD7-40B25B7B653C%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Hi David

Could you please provide some example for this case?

Thank you
Hiko

On Monday, February 23, 2015 at 4:07:52 PM UTC+7, David Pilato wrote:

You can use the _timestamp field to generate a date.
If you really need to copy the value in another field, you could use
copy_to.

None will update _source though.

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 févr. 2015 à 09:23, tao hiko <tao...@gmail.com <javascript:>> a
écrit :

If I have mapping as below
{
"name" : { "type" : "string"},
"location" : { "type" : "string" },
"created_date" : { "type" : "date"}
}

Is it possible to put current date to "created_date" field automatically?
If yes, How to do?

Thanks
Hiko

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/89567448-94b6-4edf-8a7f-f7f361c57747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Timestamp doc
Elasticsearch Platform — Find real-time answers at scale | Elastic http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-timestamp-field.html#mapping-timestamp-field

Copy To doc:
Elasticsearch Platform — Find real-time answers at scale | Elastic http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#copy-to

HTH.

If you don’t succeed, please GIST a full example of what you did so far so we can reproduce and help.
See Elasticsearch Platform — Find real-time answers at scale | Elastic http://www.elasticsearch.org/help/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfr https://twitter.com/elasticsearchfr | @scrutmydocs https://twitter.com/scrutmydocs

Le 23 févr. 2015 à 10:41, tao hiko taohiko@gmail.com a écrit :

Hi David

Could you please provide some example for this case?

Thank you
Hiko

On Monday, February 23, 2015 at 4:07:52 PM UTC+7, David Pilato wrote:
You can use the _timestamp field to generate a date.
If you really need to copy the value in another field, you could use copy_to.

None will update _source though.

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 févr. 2015 à 09:23, tao hiko <tao...@gmail.com <javascript:>> a écrit :

If I have mapping as below
{
"name" : { "type" : "string"},
"location" : { "type" : "string" },
"created_date" : { "type" : "date"}
}

Is it possible to put current date to "created_date" field automatically? If yes, How to do?

Thanks
Hiko

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com https://groups.google.com/d/msgid/elasticsearch/6a649dd3-ed25-4065-b142-e9bbc382de56%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com mailto:elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/89567448-94b6-4edf-8a7f-f7f361c57747%40googlegroups.com https://groups.google.com/d/msgid/elasticsearch/89567448-94b6-4edf-8a7f-f7f361c57747%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/60CF60D5-3E3F-4738-B8D7-088AB79B0A6E%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

I have tried like below this

POST index_test
{
"mapping" : {
"type_test" : {
"_timestamp" : {
"enabled" : true,
"copy_to" : "created_date"
},
"properties" : {
"name" : { "type" : "string"},
"location" : { "type" : "string"},
"created_date" : { "type" : "date" }
}
}
}
}

POST index_test/type_test/123
{
"name" : "Full Test",
"location" : "local"
}

But the result that doesn't have "created_date" field. What did I do wrong
or missing?

GET index_test/_search

The result

{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "index_test",
"_type": "type_test",
"_id": "123",
"_score": 1,
"_source": {
"name": "Full Test",
"location": "local"
}
}
]
}
}

On Monday, February 23, 2015 at 11:22:56 PM UTC+7, David Pilato wrote:

Timestamp doc

Elasticsearch Platform — Find real-time answers at scale | Elastic

Copy To doc:

Elasticsearch Platform — Find real-time answers at scale | Elastic

HTH.

If you don’t succeed, please GIST a full example of what you did so far so
we can reproduce and help.
See Elasticsearch Platform — Find real-time answers at scale | Elastic

--
David Pilato | Technical Advocate | Elasticsearch.com
http://Elasticsearch.com

@dadoonet https://twitter.com/dadoonet | @elasticsearchfr
https://twitter.com/elasticsearchfr | @scrutmydocs
https://twitter.com/scrutmydocs

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8d006d81-28a8-48ab-a571-688e8fabb5e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.