Add Custom Synonyms to Google Custom Search Engine (CSE)

Google has added a new feature to the Custom Search Engine (CSE) platform called “custom synonyms” that help by finding documents with relevant related terms and ranking them higher. Synonyms can help to alleviate the mismatch that often occurs between the queries that users type, and the actual words, phrases and concepts used in the documents […]

Google has added a new feature to the Custom Search Engine (CSE) platform called “custom synonyms” that help by finding documents with relevant related terms and ranking them higher. Synonyms can help to alleviate the mismatch that often occurs between the queries that users type, and the actual words, phrases and concepts used in the documents being searched.

To add synonyms to your CSE, all you’ve to do is upload a synonym dictionary that is specific to the domain and website. The synonym dictionary can include alternate words or phrases for common search queries. The following steps show how to add the synonyms for the Palo Alto Medical Foundation CSE.

  1. Download the existing CSE context file through "Control panel"->Advanced->"Download context"
  2. Add custom synonyms to your search engine. The synonym dictionary is uploaded as part of the context XML file. Here are the synonyms we added for the above examples:
    <customsearchengine>
    <title>...</title>
    <description>...</description>
    <context>
    <backgroundlabels>...</backgroundlabels>

    <synonyms>
    <synonymentry word="hearing doctor">
    <synonym>audiologist</synonym>
    </synonymentry>
    <synonymentry word="hayfever">
    <synonym>allergic rhinitis</synonym>
    </synonymentry>
    <synonymentry word="somnambulism">
    <synonym>sleepwalking</synonym>
    </synonymentry>
    <synonymentry word="pamf">
    <synonym>Palo Alto Medical Foundation</synonym>
    </synonymentry>
    </synonyms>

    </context>
    </customsearchengine>
  3. Upload the context file through "Control panel"->Advanced->"Upload context"

A few notes:
  • CSE synonyms are unidirectional, not bidirectional. Thus, a context file with
    <synonymentry word="migraine"><synonym>headache</synonym></synonymentry>
    defines "headache" to be a synonym for "migraine". However, if you also want "migraine" to be considered as a synonym for "headache", you need to add a separate SynonymEntry to the XML, as follows:
    <synonymentry word="migraine"><synonym>headache</synonym></synonymentry>
    <synonymentry word="headache"><synonym>migraine</synonym></synonymentry>
  • In the current version, the synonym dictionary can only be uploaded/downloaded as a part of the context XML file.
  • We allow up to 500 individual synonyms for a given CSE.
  • Each word can have no more than 10 synonyms. If there multiple synonyms, the query will be expanded to include all synonyms uniformly.