Skip to content

Instantly share code, notes, and snippets.

@jruts
Last active May 3, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jruts/8d3ba937970a61c30c993647ae7199ab to your computer and use it in GitHub Desktop.
Save jruts/8d3ba937970a61c30c993647ae7199ab to your computer and use it in GitHub Desktop.

SUGGESTION: CloudSearch (taggy-ci)

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.

Fields

context

The first field we need is a context that defines market and language.

market:langage E.g.: uk:en

tagid

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

name

The last field is the name we want to be able to search for. E.g. Spain

Examples

  1. Let's say we want to make Spain searchable for the uk market in english:
{
  "context": "uk:en",
  "tagid": "geo:geonames:45edsfzs4",
  "name": "Spain"
}
  1. 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"
}
  1. 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"))

Extra fields

label

If we want to return a different text then what we provide in name you can always add a label field to allow this.

boost

Add a boost field if we need it

active

Self explanatory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment