Field Aliases
Field aliases let you expose consumer-friendly field names in the API while keeping your Elasticsearch mapping unchanged. Translation is automatic and bidirectional — aliases are converted to real field names before querying Elasticsearch, and real field names are converted back to aliases in the response.
Configuration
Section titled “Configuration”Define aliases using the field property in the fields config for each index:
indexes: collections: engine: elasticsearch host: https://elasticsearch.example.com indexName: museum_collections fields: country: field: placeCountry region: field: placeRegion coords: field: placeCoordinatesWith this config, API consumers use country and the API translates it to placeCountry for Elasticsearch.
Aliases can be combined with other field properties (weight, searchable):
fields: country: field: placeCountry weight: 5How translation works
Section titled “How translation works”Inbound (request)
Section titled “Inbound (request)”When a request comes in, alias field names in the following parameters are translated to Elasticsearch field names:
sortkeys —{"country":"asc"}→{"placeCountry":"asc"}facetsvalues —country,region→placeCountry,placeRegionfilterskeys —{"country":"Scotland"}→{"placeCountry":"Scotland"}boostskeys —{"country":5}→{"placeCountry":5}fieldsvalues —country,title→placeCountry,titlehistogramkeys —{"country":100}→{"placeCountry":100}geoGrid.field—coords→placeCoordinates- Facet endpoint
:fieldpath parameter —/facets/country→ queriesplaceCountry - Facet endpoint
filterskeys
Outbound (response)
Section titled “Outbound (response)”Elasticsearch field names are translated back to aliases in:
facetskeys —{"placeCountry":[...]}→{"country":[...]}histogramskeys_highlightskeys in each hit_highlightskeys in geo map sample hits
Passthrough behavior
Section titled “Passthrough behavior”- Fields that are not aliases pass through unchanged in both directions
- When no
fieldswithfieldare configured for an index, the alias map has zero overhead — no translation is performed - Real ES field names can still be used alongside aliases (they pass through as-is)
Examples
Section titled “Examples”Given the alias config above:
# Filter using an aliascurl "https://search-api-elysia-production.up.railway.app/collections/search?q=castle&filters=%7B%22country%22%3A%22Scotland%22%7D"
# Facets using aliasescurl "https://search-api-elysia-production.up.railway.app/collections/search?q=&facets=country,region"
# Facet search using an aliascurl "https://search-api-elysia-production.up.railway.app/collections/facets/country?q=sc"
# Sort using an aliascurl "https://search-api-elysia-production.up.railway.app/collections/search?q=&sort=%7B%22country%22%3A%22asc%22%7D"In all cases, the response uses the alias names (country, region) rather than the Elasticsearch names (placeCountry, placeRegion).