This works for me. I thought I was actually going crazy. XD Thanks a bunch 
Jordan!

--Josh

On Wednesday, October 15, 2014 8:07:31 PM UTC-4, Jordan Sissel wrote:
>
>
>
> On Tuesday, October 14, 2014 5:46:10 PM UTC-7, Joshua Holbrook wrote:
>>
>> Hello,
>>
>> I'm working on an irc bot that indexes in-channel image links, and so far 
>> so good---except I can't seem to get automatic timestamps working! I did my 
>> best to follow the docs at 
>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-timestamp-field.html
>>  
>> but I don't see any change in what my search docs look like, even after 
>> deleting the entire index and reconfiguring first.
>>
>> Right now my mapping looks like this:
>>
>> $ curl http://localhost:9200/archivist/_mapping?pretty
>> {
>>   "archivist" : {
>>     "mappings" : {
>>       "image" : {
>>         "_timestamp" : {
>>           "enabled" : true,
>>           "store" : true
>>         },
>>         "properties" : {
>>           "channel" : {
>>             "type" : "string"
>>           },
>>           "image" : {
>>             "type" : "string"
>>           },
>>           "message" : {
>>             "type" : "string"
>>           },
>>           "user" : {
>>             "type" : "string"
>>           }
>>         }
>>       }
>>     }
>>   }
>> }
>>
>> and after indexing something (code doing this at 
>> https://github.com/jesusabdullah/archivist/blob/master/src/main/java/com/jesusabdullah/archivist/Indexer.java#L71-L82
>>  
>> first java project ever) my search results look like:
>>
>> $ curl http://localhost:9200/archivist/image/_search?pretty
>> {
>>   "took" : 0,
>>   "timed_out" : false,
>>   "_shards" : {
>>     "total" : 5,
>>     "successful" : 5,
>>     "failed" : 0
>>   },
>>   "hits" : {
>>     "total" : 1,
>>     "max_score" : 1.0,
>>     "hits" : [ {
>>       "_index" : "archivist",
>>       "_type" : "image",
>>       "_id" : "jK8dY6oKTRifbUU4o406pw",
>>       "_score" : 1.0,
>>       
>> "_source":{"channel":"#nodebombrange","user":"jesusabdullah","message":"snoop!
>>  
>> http://i.imgur.com/iktO9TK.gif","image":"http://i.imgur.com/iktO9TK.gif"}
>>     } ]
>>   }
>> }
>>
>> Am I doing something wrong?
>>
>
> This was also confusing to me at first. I asked my coworkers who gave me a 
> good answer and also was pointed at a useful answer on the mailing list - 
> so between you and me and some other folks asking questions, you aren't 
> alone in your confusion! :)
>
> The short answer is that you must request _timestamp being returned to you:
>
> # Here, I ask for _source and _timestamp to be shown to me:
> % curl 'localhost:9200/archivist/_search?pretty&fields=_timestamp,_source'
> {
>   "took" : 1,
>   "timed_out" : false,
>   "_shards" : {
>     "total" : 5,
>     "successful" : 5,
>     "failed" : 0
>   },
>   "hits" : {
>     "total" : 1,
>     "max_score" : 1.0,
>     "hits" : [ {
>       "_index" : "archivist",
>       "_type" : "image",
>       "_id" : "jUWknMq1RmusrlU6hP2BGw",
>       "_score" : 1.0,
>       "_source": { "fancy": "pants whoa"},
>       "fields" : {
>         "_timestamp" : 1413417808235
>       }
>     } ]
>   }
> }
>
> This post has the more detailed answer:
>
> https://groups.google.com/forum/#!msg/elasticsearch/pebxC9ezowg/XCXH-POYvuQJ 
>
> -Jordan
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/aed34486-e7ea-4304-8889-ce5b40839d58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to