Synonyms API

Note
These endpoints have been deprecated since Fusion 2.4. Use the Synonyms Editor API instead.

The Synonyms API manages the set of synonyms defined in Solr for a collection:

  • a string of terms that will expand on the terms the user entered, like Television, TV.

  • a term that should be mapped to another term, like i-pod⇒ipod.

When updating the synonyms, note that only PUT requests are supported, and any new data sent will overwrite the previous synonyms. As such, PUT requests can be seen as replacement requests.

It is only possible to have a single set of stop words when using this REST API. If you need different sets of stop words for different field types (perhaps for different languages), you will need to edit the schema.xml and manually manage the stop word files.

Examples

Note
Use port 8765 in local development environments only. In production, use port 8764.

Update the synonym list with a new list of synonyms for a collection named 'docs':

REQUEST

curl -u user:pass -X PUT -H 'Content-type: application/json' -d '[{"match":[ "GB","gib","gigabyte","gigabytes" ]}, {"match": ["MB","mib","megabyte","megabytes"]}, {"match" : ["Television","Televisions","TV","TVs"]},{"match":["foo"],"replace":["bar"]}]' http://localhost:8764/api/apollo/synonyms/docs

RESPONSE

None.

List the current synonyms list:

REQUEST

curl -u user:pass http://localhost:8764/api/apollo/synonyms/docs

RESPONSE

[ {
  "match" : [ "GB", "gib", "gigabyte", "gigabytes" ]
}, {
  "match" : [ "MB", "mib", "megabyte", "megabytes" ]
}, {
  "match" : [ "Television", "Televisions", "TV", "TVs" ]
}, {
  "match" : [ "foo" ],
  "replace" : [ "bar" ]
}, {
  "match" : [ "i-pod" ],
  "replace" : [ "ipod" ]
} ]

Upload a synonyms list:

REQUEST

curl -u user:pass -X PUT --form file=@synonyms.txt http://localhost:8764/api/apollo/synonyms/docs

RESPONSE

None.

Download a synonyms list, and save it as a file named "synonyms.txt":

REQUEST

curl -u user:pass -H "Accept: application/octet-stream" http://localhost:8764/api/apollo/synonyms/docs > synonyms.txt

RESPONSE

None.