Advanced Retrieval
Advanced retrieval techniques can help you improve the relevance of your search results. This guide covers query rewriting and using metadata to enhance retrieval performance. By adding any of the following features to your retrieval pipeline, you will use an Advanced Retrieval which is a seperate quota from the standard retrieval quota. A single advanced retrieval request will only consume one advanced retrieval quota regardless of the number of features used in the request.

Reranking
Reranking is a technique that reorders search results to improve relevance. When you enable reranking, the system uses a cohere to re-rank the top search results based on the context of the conversation. This can help you provide more relevant answers to user queries.
Request Format
To enable reranking, include the rerank parameter and set to true  in the request body. Here's an example request:
--data '{
  "question": "What advanced features does the retrieve endpoint support?",
  "numResults": 3,
  "rerank": true
}'
- rerankis an optional boolean parameter in the request
- Set reranktotrueto enable reranking
- Set reranktofalseor omit it to disable reranking
Query Rewriting
Query rewriting uses conversation history to improve retrieval relevance. Before retrieving relevant documents, the system reformulates the user query based on the context of the conversation. This can help you provide more accurate answers to user queries. When making a request to the retrieval endpoint, you can include previous messages to help the system understand context and reformulate queries appropriately.
Tip: Query rewriting is particularly helpful in chat applications.
Request Format
Include previous context in the request body to help the system understand the conversation history. Here's an example request:
--data '{
  "question": "What advanced features does the retrieval endpoint support?",
  "numResults": 3,
  "rerank": true,
  "context": {
     "messages": [
        {
           "role": "user", 
           "content": "How do I retrieve data from the endpoint?"
        },
        {
           "role": "assistant",
           "content": "You can use the retrieval endpoint to get data from the database."
        }
     ]
  }
}'
- contextis an optional object in the request
- messagesmust be a non-empty array
- Each message must have a roleandcontent. Role can be any string, butuserandassistantare common values
- Messages should be in chronological order with the most recent message last
- Include both sides of the conversation for best results