Closed deanpeterson closed 10 years ago
There is no "correct" way to handle the results, it is completely up to you. Both elastic.js and the official client do not process the response before passing it to the callback. In elasticsearch, accessing the field via the _source
is the most common (and recommended) way. You could also use the fields
parameter to specify what fields you want returned if needed.
_source property is a default return data parameter, and u need use this. We can expect return,if have a data in your search, have a _source return, and u can expect this response ever :) If no have _source response, your search have no resulta at this time. Hands up! and foreach javascript!!!
The Examples link (https://github.com/fullscale/elastic.js/tree/master/examples) on http://docs.fullscale.co/elasticjs/ is still broken
Is _source the only member available? How about _id?
Hi, I am able to run a query and get results. However, I am not able to find examples of the "correct" way to parse the results. I notice the link to examples is broken: https://github.com/fullscale/elastic.js/tree/master/examples. I can access a resp.hits.hits object but the column information I want is stored in a "_source" property. Am I really supposed to rely on getting values from the _source property or is there a better way?
Here is an example of what I am doing:
TypeAheadService.search({ index: 'occupationindex', type: 'occupations', body: ejs.Request().query(ejs.MatchQuery('title', queryParams.data.q)) }).then(function(resp) { if(resp && resp.hits && resp.hits.hits && resp.hits.hits.length > 0) { var i; for(i = 0; i < resp.hits.hits.length; i++) { var item = resp.hits.hits[i]; item._source;