I tried many different options/combinations to get a _timestamp of the
current time (like "now")
set for each document loaded but have no luck to manage this.
As far as I understood from the docs it should be possible with:
{
"mappings" : {
"docs" : {
"_timestamp" : { "enabled" : "yes", "store" : "yes" },
"properties" : {
"id" : { "type" : "string", "index" : "not_analyzed", "store" :
"yes" },
...
}
}
}
}
Is it true that I should get a _timestamp for each hit in the result?
I'm seeing nothing
Only _index, _type, _id, _score and _source.
In previous versions of ES, I noticed that when I wanted the _ttl field to
be returned (time to live), I needed to add _ttl to the list of fields. But
then, I also needed to explicitly add _source to the list of fields to
return.
Is this still the case? The documentation seems to imply that _source is
always returned by default even when other fields are asked for.
You have to explicitely request for the particular field "_timestamp" if
you store it in the index only, otherwise you can only do queries upon it
if it is enabled as you do
T.
On Wednesday, 2 October 2013 16:45:19 UTC+3, Bernd Fehling wrote:
I tried many different options/combinations to get a _timestamp of the
current time (like "now")
set for each document loaded but have no luck to manage this.
As far as I understood from the docs it should be possible with:
{
"mappings" : {
"docs" : {
"_timestamp" : { "enabled" : "yes", "store" : "yes" },
"properties" : {
"id" : { "type" : "string", "index" : "not_analyzed", "store" :
"yes" },
...
}
}
}
}
Is it true that I should get a _timestamp for each hit in the result?
I'm seeing nothing
Only _index, _type, _id, _score and _source.
OK, now I get/see the _timestamp field, but how to get a timestamp within
_source?
I tried:
{
"mappings" : {
"docs" : {
"properties" : {
"timestamp" : { "type" : "date", "format" : "date_time", "index" :
"not_analyzed", "store" : "true", "null_value" : "now" },
"id" : { "type" : "string", "index" : "not_analyzed", "store" :
"yes" },
...
}
}
}
}
My assumption is, that a field "timestamp" of type "date" with
default_value "now" will be generated?
And it should set the current timestamp (now) if input from "timestamp" is
""?
And I should see it in _source?
Or do I have to send "tmestamp" : "null" as default from my data?
Unfortunately, "now" works only at query time. Also, date is not a core
type which can carry a default value. So for external dates, they have to
be given explicitly in the _source. ES does not modify _source when
indexing. The auto timestamping is only available for the internal
_timestamp field.
OK, now I get/see the _timestamp field, but how to get a timestamp within
_source?
I tried:
{
"mappings" : {
"docs" : {
"properties" : {
"timestamp" : { "type" : "date", "format" : "date_time", "index"
: "not_analyzed", "store" : "true", "null_value" : "now" },
"id" : { "type" : "string", "index" : "not_analyzed", "store" :
"yes" },
...
}
}
}
}
My assumption is, that a field "timestamp" of type "date" with
default_value "now" will be generated?
And it should set the current timestamp (now) if input from "timestamp" is
""?
And I should see it in _source?
Or do I have to send "tmestamp" : "null" as default from my data?
Thats bad. So I have to stick with SOLR
Everything else could be converted (including Thesaurus). Only one self
written ES-plugin required.
Why is ES not having a "type" : "date" field with "default_value" : "now"?
Can't belief that I'm the only one using timestamps to delete old records
from the index after updating.
Is it possible to enhance ES with a new field type via plugin?
Bernd
Am Dienstag, 8. Oktober 2013 13:10:33 UTC+2 schrieb Jörg Prante:
Unfortunately, "now" works only at query time. Also, date is not a core
type which can carry a default value. So for external dates, they have to
be given explicitly in the _source. ES does not modify _source when
indexing. The auto timestamping is only available for the internal
_timestamp field.
Thats bad. So I have to stick with SOLR
Everything else could be converted (including Thesaurus). Only one self
written ES-plugin required.
Why is ES not having a "type" : "date" field with "default_value" : "now"?
Can't belief that I'm the only one using timestamps to delete old records
from the index after updating.
Is it possible to enhance ES with a new field type via plugin?
Bernd
Am Dienstag, 8. Oktober 2013 13:10:33 UTC+2 schrieb Jörg Prante:
Unfortunately, "now" works only at query time. Also, date is not a core
type which can carry a default value. So for external dates, they have to
be given explicitly in the _source. ES does not modify _source when
indexing. The auto timestamping is only available for the internal
_timestamp field.
Yes, but first it is not in _source.
Second, my query is: ... "fields": [ "_timestamp", "_source" ] , but I get
_index: base,
_type: docs,
_id: myid1,
_score: 1,
_source: {...},
fields: { _timestamp: 1381226793870 }
And I assume if I query for "fields": [ "_timestamp", "_source" ] to get
_index: base,
_type: docs,
_id: myid1,
_score: 1,
fields: { _timestamp: 1381226793870, _source: {...} }
This is inconsistent, _source is not within fields.
I have to reparse all this crap to get either _timestamp into _source or
_source into fields.
Any other idea for configuration?
Bernd
Am Dienstag, 8. Oktober 2013 13:45:12 UTC+2 schrieb Jörg Prante:
I do use timestamps, also for my (upcoming) OAI ES plugin.
Not sure about the challenge you are facing. You can use _timestamp field
if you want auto timestamping.
Yes, but first it is not in _source.
Second, my query is: ... "fields": [ "_timestamp", "_source" ] , but I get
_index: base,
_type: docs,
_id: myid1,
_score: 1,
_source: {...},
fields: { _timestamp: 1381226793870 }
And I assume if I query for "fields": [ "_timestamp", "_source" ] to get
_index: base,
_type: docs,
_id: myid1,
_score: 1,
fields: { _timestamp: 1381226793870, _source: {...} }
This is inconsistent, _source is not within fields.
I have to reparse all this crap to get either _timestamp into _source or
_source into fields.
Any other idea for configuration?
Bernd
Am Dienstag, 8. Oktober 2013 13:45:12 UTC+2 schrieb Jörg Prante:
I do use timestamps, also for my (upcoming) OAI ES plugin.
Not sure about the challenge you are facing. You can use _timestamp field
if you want auto timestamping.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.