What im trying to do is to get only the source from the elastic search query in order to skip the processing on the javascript, so i could squize some more performance gains.Is it possible to do so?
So here is what i currenly do, i just get the data from the elastic search and iterate every one of those objects in order to construct an array that only contains the what’s inside of _source:
const { body } = await this.elsticSearchService.search<any>({
index: this.configService.get('ELASTICSEARCH_INDEX'),
body: {
query: {
match_all: {},
},
size: 10000,
},
});
const hits = body.hits.hits;
return hits.map((item: any) => item._source);
So my question is, is there a way to only get the _source from the elastic search, in order
to skip the processing on the JavaScript?
So the object returned from the elastic search would look like this
[
0:{ "key": "value"}, // key,value from _source object
1:{ "key": "value"}, // key,value from _source object
2:{ "key": "value"}, // key,value from _source object
]
so without all of the other fields like hits, took etc…