---
title: "Searching with context"
slug: "searching-with-context"
abstract: "Advanced example that shows you how to use the Discover Search and Recommendation API to search with context."
---
# Searching with context

Use the `context` object to give Sitecore Discover as much information as possible. Your search results are more relevant to the query when you apply specific [context object types](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/integrate-using-discover-rest-apis/integrate-using-the-search-and-recommendation-api/examples-of-advanced-search-and-recommendation-use-cases/the-context-request-object.md "The context request object").

The following is an example search query with user context.

<details>
<summary><h2>Searching for products with a user context</h2></summary>

In this example, you search for three products using the keyphrase *red* and apply a user context for gender.

Here is the request:

```JSON
{
  "query": {
    "keyphrase": [["red"]]
  },
  "n_item": 3,
  "content": {},
  "context": {
    "user": {
      "gender": "female"
    }
  }
}
```

Here is the response:

```JSON
{
  "ts": 1480977544,
  "rid": "response_id_17",
  "url": "/searchpage?keyphrase=red&keyphrase=shorts&context=Q1fcsl087pn",
  "query2id": {
    "keyphrase": "keyphrase_id_red__shorts"
  },
  "content": {
    "product": {
      "value": [
        {"name": "stylish bags", "color": "red", "price": 50, "category_names": ["women clothing"]},
        {"name": "red dresses", "price": 80, "gender": "female"},
        {"name": "women's beach shorts", "color": "red", "price": 45}
      ]
    }
  },
  "n_item": 3,
  "total_item": 45,
  "page_number": 1,
  "total_page": 15
}
```

The response returns the top three products related to the *female* gender.

</details>