Using suggestions

Suggestions are tips you can use to guide you on the following queries.

The following sections show some examples of suggestion use cases.

Getting a keyphrase suggestion

The following code is a request for a keyphrase suggestion. In this example, you request five suggestions from the original query keyphrase shirt.

RequestResponse
{
  "query": {
    "keyphrase": ["shirt"]
  },
  "suggestion": {
    "keyphrase": {
      "max": 3
    }
  }
}

The following code shows the corresponding response:

RequestResponse
{
    "ts": 1480997544,
    "rid": "response_id_S1",
    "query2id": {
        "keyphrase": "keyphrase_id_shirt"
    },
    "suggestion": {
        "keyphrase": {
            "value": [
                {
                    "id": "keyphrase_id_shirt",
                    "text": "Shirt",
                    "in_content": "product"
                },
                {
                    "id": "keyphrase_id_short",
                    "text": "Short",
                    "in_content": "product"
                },
                {
                    "id": "keyphrase_id_mens_shirt",
                    "text": "Men's Shirt",
                    "in_content": "product"
                }
            ]
        }
    }
}

Keyphrase suggestions return a mix of, but not all, suggestion types. You cannot identify the specific type used in the response. The above sample uses the following suggestions types:

  • Shirt is an autocomplete suggestion.

  • Short is a type_correction.

  • Men's Shirt and Shirt Style Guide are related_search or query_expansion suggestions.

  • Shirt on sale is a recent search history suggestion.

The following code is a request for a trending category suggestion. In this example, you request three trending categories.

RequestResponse
{
  "suggestion": {
    "trending_category": {
      "max": 3
    }
  }
}

The following code shows the corresponding response:

RequestResponse
{
  "ts": 1480997544,
  "rid": "response_id_S2",
  "suggestion": {
    "trending_category": {
      "value": [
        {"id": "category_id_men", "text": "Men", "url": "/cat/men"},
        {"id": "category_id_shirt", "text": "Shirt", "url": "/cat/shirt"},
        {"id": "category_id_backpack", "text": "Backpack", "url": "/cat/backpack"}
      ]
    }
  }
}

Getting an autocomplete suggestion from a specific content

The following code is a request for a autocomplete suggestion. In this example, you request three suggestions for the keyphrase mov.

Request:

RequestResponse
{
  "query": {
    "keyphrase": ["mov"]
  },
  "suggestion": {
    "autocomplete": {
      "max": 3,
      "in_content": {
        "value": [{"article": {}}]
      }
    }
  }
}

The following code shows the corresponding response:

RequestResponse
{
  "ts": 1480997544,
  "rid": "response_id_S3",
  "query2id": {
    "keyphrase": "keyphrase_id_mov"
  },
  "autocomplete": "movie",
  "suggestion": {
    "autocomplete": {
      "value": [
        {"id": "keyphrase_id_movie", "text": "Movie", "in_content": "article"},
        {"id": "keyphrase_id_move", "text": "Move", "in_content": "article"},
        {"id": "keyphrase_id_movember", "text": "Movember", "in_content": "article"}
      ]
    }
  }

Do you have some feedback for us?

If you have suggestions for improving this article,