Skip to main content
This page documents an earlier version of the API client. For the latest version, see Search for synonyms.
Required ACL: settings

Examples

// Searching for "street" in synonyms and one-way synonyms;
// fetch the second page with 10 hits per page

var result = index.SearchSynonyms(
  new SynonymQuery ("street")
  {
    Type = "synonym, oneWaySynonym"
    Page = 1,
    HitsPerPage = 10
  }
);

Parameters

query
string
required
The search query to find synonyms. Use an empty query to browse all the synonyms of an index.
hitsPerPage
string
default:20
The number of synonyms to return for each call.
page
integer
default:0
The page to fetch when browsing through several pages of results. This value is zero-based.
type
string | string[]
Restrict the search to a specific type of synonym. Use an empty string to search all types (default behavior). Multiple types can be specified using a comma-separated list or an array. The allowed types are:
  • synonym
  • oneWaySynonym
  • altCorrection1 or altCorrection2
  • placeholder

Response

hits
list
A list of matching synonyms. Each hit contains the synonym object and a _highlightResult attribute with the highlighted synonym.
nbHits
integer
Number of hits.

Response as JSON

This section shows the JSON response returned by the API. Each API client wraps this response in language-specific objects, so the structure may vary. To view the response, use the getLogs method. Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON
{
  "hits":[
    {
      "type":"synonym",
      "synonyms": [
        "car",
        "vehicle"
      ],
      "objectID":"1513249039298",
      "_highlightResult":{
        "type":{
          "value":"synonym",
          "matchLevel":"none",
          "matchedWords": []
        },
        "synonyms":[
          {
            "value":"<b>c<\/b>ar",
            "matchLevel":"full",
            "fullyHighlighted":false,
            "matchedWords": [
              "c"
            ]
          },
          {
            "value":"vehicle",
            "matchLevel":"none",
            "matchedWords": []
          }
        ]
      }
    }
  ],
  "nbHits":1
}
I