Ommitting Attributes of Record

Hello,
I’m attempting to index records contain language translations for a given place. Now my experience with ElasticSearch is that for every record you must export all fields so that all the records look uniform. Now for a place, I may not have a language translation for french so I am asking do I need to export the field in the record to satisfy the indexing? I plan to specific multiple attributes to search in the api.

Example. I have a “Place” that only has an english name.
Example currently

{
“id”: 1,
“name_en”: “Place”,
“name_fr”:“Place”
}

could I change it to an omit the name_fr entry:

{
“id”: 1,
“name_en”: "Place
}

When I go to search for places on a french locale, I would specific the search attributes to be name_fr, name_en. I would still expect the place to return.

Thanks,
John

Hi @jgraham,

Welcome to the Algolia Community!

Your records do not have to be the same.

You can have different attributes on each record, however, some of the features and configuration will work better, in some cases, if the attributes are present on each record.

It really depends on your desired outcome.

In this case, I am assuming you are using the _geoloc attribute to find the place, and the name_en or name_fr to display the name.

You may need to display the name depending on which language you want to display.

If you are displaying french names, then you would need some way to fall back on the english name if the french name is missing.

This is something you would need to add to your code, because trying to display the ‘name_fr’ attribute, will not show if it is not present on the record.

This, of course, depends on your specific configuration and the code you are using to display these names.

Let us know how this works for you!
Best regards,

Hi Cindy,
Thank you for the answer. You are correct in that I will need to have some fallback to the english name. For now, I plan to provide an separate map of lang to name for display purposes but for search I was hoping to minimize the amount of duplicated data that would need to be searchable.
Thanks,
John