Our representation of Organization objects via the Search API currently returns an unsorted array of names - API clients should only really see the top ranked name as this is the display name they should use when referring to the organization. The clients currently have no need for the alternate names, though we can add them to the schema if need be in future.
Here I index a name field in Elasticsearch as the authoritative (top ranked) name for an Organization, and additionally index other names in an alternate_names array as is our convention in other search indices. I've adjusted the search query to search on all the names, but now the API only returns the name attribute.
Migration
We need to recreate the index as we are scrapping the names field and adding the name and alternate_names fields in its pace. ES doesn't support deleting existing fields in a live index so in a console we drop the old index and re-declare the mappings for the new one:
Organization.reload_index!
And then we can dispatch our indexing sidekiq workers to populate the new index:
Our representation of Organization objects via the Search API currently returns an unsorted array of names - API clients should only really see the top ranked name as this is the display name they should use when referring to the organization. The clients currently have no need for the alternate names, though we can add them to the schema if need be in future.
Here I index a
name
field in Elasticsearch as the authoritative (top ranked) name for an Organization, and additionally index other names in analternate_names
array as is our convention in other search indices. I've adjusted the search query to search on all the names, but now the API only returns thename
attribute.Migration
We need to recreate the index as we are scrapping the
names
field and adding thename
andalternate_names
fields in its pace. ES doesn't support deleting existing fields in a live index so in a console we drop the old index and re-declare the mappings for the new one:And then we can dispatch our indexing sidekiq workers to populate the new index: