Closed Sukesh-Alluri closed 7 years ago
Which version of elasticsearch are you using? As I remember starting from 2.x the fields not required any more as all data stored in source.
@taraslayshchuk I'm using ES 5.2.2 version. You're partly correct that ES no longer project source data through fields
section but still use fields
section whenever you use script fields: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-script-fields.html.
Below is a sample query and resultSet from ES Request:
{"query": {"bool": {"should": [], "must_not": [], "must": []}}, "script_fields": {"locationShown": {"script": {"inline": "def ams = params['_source'].assetMetadata; for (int i=0; i < ams.size(); i++) { if (ams[i].language == doc['primaryLanguage'].value) return ams[i]?.data?.locationShown; }"}}}}
Response
{"hits": {"hits": [{"_type": "asset", "_source": {"masterId": "592690008"}, "_score": 3.3410559, "_index": "asset_index", "fields": {"locationShown": [{"countryName": "", "city": "", "stateProvince": ""}]}, "_id": "592690008"}]}}
Corresponding es2csv command I used
es2csv -r -q @query.json -u http://localhost:8080 -i assets -f masterId locationShown
@taraslayshchuk any way we can get this closed or merged soon?
Sorry, I don't have time to test it ATM.
Helpful when we've script fields in the output result. Previous implementation just ignores that section altogether. This will write these results in
fields
section as well to tmp file and subsequently to resultant csv file