You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
The above query would filter out all documents that do not have a key`special` with a value`True` or (have a key`user_id` equal to 1 and a key`user_score` less than 100).
644
+
645
+
##**Re-ranking**
646
+
647
+
Vector search results can be reranked in the same query they are retrieved in. To enable this, provide the`rerank` key.
648
+
649
+
{% tabs %}
650
+
{% tab title="JavaScript" %}
651
+
```javascript
652
+
constresults=awaitcollection.vector_search(
653
+
{
654
+
query: {
655
+
fields: {
656
+
body: {
657
+
query:"What is the best database?", parameters: {
658
+
prompt:
659
+
"Represent this sentence for searching relevant passages:",
660
+
}
661
+
},
662
+
},
663
+
},
664
+
rerank: {
665
+
model:"mixedbread-ai/mxbai-rerank-base-v1",
666
+
query:"What is the best database?",
667
+
num_documents_to_rerank:100,
668
+
},
669
+
limit:5,
670
+
},
671
+
pipeline,
672
+
);
673
+
```
674
+
{% endtab %}
675
+
676
+
{% tab title="Python" %}
677
+
```python
678
+
results=await collection.vector_search(
679
+
{
680
+
"query": {
681
+
"fields": {
682
+
"body": {
683
+
"query":"What is the best database?",
684
+
"parameters": {
685
+
"prompt":"Represent this sentence for searching relevant passages:",
686
+
},
687
+
},
688
+
},
689
+
},
690
+
"rerank": {
691
+
"model":"mixedbread-ai/mxbai-rerank-base-v1",
692
+
"query":"What is the best database",
693
+
"num_documents_to_rerank":100,
694
+
},
695
+
"limit":5,
696
+
},
697
+
pipeline,
698
+
)
699
+
```
700
+
{% endtab %}
701
+
702
+
{% tab title="Rust" %}
703
+
```rust
704
+
letresults=collection
705
+
.vector_search(
706
+
serde_json::json!({
707
+
"query": {
708
+
"fields": {
709
+
"body": {
710
+
"query":"What is the best database?",
711
+
"parameters": {
712
+
"prompt":"Represent this sentence for searching relevant passages:",
This query will first get the top 100 documents from the initial vector search and then rerank them using the`mixedbread-ai/mxbai-rerank-base-v1` cross-encoder.
758
+
759
+
You can specify the number of documents to rerank with the`num_documents_to_rerank` parameter. The query returns the top`limit` results after re-ranking.