Skip to content

Commit

Permalink
fix: allow for alias index name to return mapping (#93)
Browse files Browse the repository at this point in the history
* 92: Allow for alias index name to return mapping

* remove redundant comment

Co-authored-by: Pablo Damnhorns <[email protected]>
  • Loading branch information
pcasa and nodkz authored Feb 18, 2020
1 parent f6bc025 commit 7021b40
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ export async function fetchElasticMapping(
);
}

const elasticMapping = (
await opts.elasticClient.indices.getMapping({
index: opts.elasticIndex,
type: opts.elasticType,
})
)[opts.elasticIndex].mappings[opts.elasticType];
const elasticMapping = await opts.elasticClient.indices.getMapping({
index: opts.elasticIndex,
type: opts.elasticType,
});

// Try index name, else resort to Value in case Index name is an alias
const baseIndex = elasticMapping[opts.elasticIndex] || Object.values(elasticMapping)[0];

return elasticMapping;
return baseIndex.mappings[opts.elasticType];
}

0 comments on commit 7021b40

Please sign in to comment.