Documentation Center

GraphQL sample for search suggestions

Use search suggestions to suggest values while the visitor is typing. Fuzzy search is supported for this feature.

The following is a basic query for a search suggestion (the label property is set to whatever the visitor types):
{
  suggest(connectorId: "cocktails", label: "d", language: "english", fuzzy: true, first: 10, after: "MQ==") {
    edges {
      cursor
      node {
        connectorId
        id
        label
        alternativeLabels
        highlight
      }
    }
  }
}
To get an idea of the kind of response you'll see, let's look at a very basic query that searches across all Concept Schemes:
{
  suggest(label: "fr", language: "english") {
    edges {
      cursor
      node {
        id
        label
        alternativeLabels
        parentsConceptGraph
        connectorId
        highlight
        count
      }
    }
  }
}
Here's what part of the response might look like. Note how the query finds matching facets in two different Concept Schemes (cocktails and ingredients), and highlights the word that matches the label entered.
{
  "cursor": "Mw==",
  "node": {
    "id": "e-learning-poolparty-biz_cocktails_780c7429-30b7-4144-b32a-f28c99dcb9cf",
    "label": "French Martini"
    "alternativeLabels": null,
    "parentsConceptGraph": [
      "IBA official cocktails/New Era Drinks"
    ],
    "connectorId": "cocktails",
    "highlight": [
      "<em>French</em> Martini"
    ],
    "count": 0
  }
},
{
  "cursor": "NA==",
  "node": {
    "id": "e-learning-poolparty-biz_cocktails_cb8933aa-bf64-0009-cddc-f5e44dd75",
    "label": "Fruit"
    "alternativeLabels": [
      "Bacca",
      "Fruit",
      "Fruiting",
      "Fruiting Shrubs",
      "Fruits",
      "Fruity",
      "Prutas",
      "Simple fruit"
    ],
    "parentsConceptGraph": null,
    "connectorId": "ingredients",
    "highlight": [
      "<em>Fruit</em>"
    ]
    "count": 0
  }
}