We are using cloudsearch mainly for autocompletion and to get the ids linked to them. To make this work for multiple markets and multiple languages/market (even synonyms) we only need 3 fields.
The first field we need is a context that defines market and language.
market:langage
E.g.: uk:en
The second field we need is a tagid. This is the id that references our tags in the graph database.
type:subtype.id
E.g.: geo:geonames:12345
The last field is the name we want to be able to search for.
E.g. Spain
- Let's say we want to make Spain searchable for the uk market in english:
{
"context": "uk:en",
"tagid": "geo:geonames:45edsfzs4",
"name": "Spain"
}
- Now we want to add the same thing, but for Denmark! So we create a new record in CloudSearch:
{
"context": "dk:da",
"tagid": "geo:geonames:45edsfzs4",
"name": "Spanien"
}
- What if they also call Spanien Espagnol ? So we need a new record for this synonym:
{
"context": "dk:da",
"tagid": "geo:geonames:45edsfzs4",
"name": "Espagnol"
}
This provides us with everything we need to transform a suggestion into the tagid that we need to perform our search in our graph database.
Example queries might look like this:
English: (and (prefix field=id "uk:en")(prefix field=name "Spa"))
Danish: (and (prefix field=id "dk:da")(prefix field=name "Spa"))
If we want to return a different text then what we provide in name you can always add a label field to allow this.
Add a boost field if we need it
Self explanatory