Trouva/elasto

How to get _timestamp value ?

msathis opened this issue · 4 comments

The query generated from fields api makes it impossible to get the _timestamp value.

True!
Although bad news is, changing this would break backwards compatibilty, as fields throws lot's of errors if you don't use it with a leaf field. To resolve this we can add a _source fn for the current behaviour (source filtering), depracate the current fields api and find a new name for the one that should be actually called fields. Suggestions?

Agree. Or there are only few meta fields like [_source, _timestamp, _routing, type] etc. We can send it in the "fields" parameter if the field name is one of these. Otherwise it should be sent in " source". Though it looks like a workaround, This fixes the issue in backward compatible way.

Cool! Will probably do the workaround pretty soon.
Btw in the meantime you can always just do:

var query = Elasto.query({
        index: config.esIndexName,
        type: this.type
    })
    .where('field', 'blabla')
    .raw();

// do whatever you want with the query output here, like rename _source to fields etc..

Elasto.client.search(query)
    .then(function(response){  
         // equivalent response to .exec()
    });

Thanks. I'm already using this :)