> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/sdk-user-guide/search/scoring.md).

# Scoring

A **full search** consists of three steps:

1. **Scoring** – compute similarity scores in ciphertext
2. **Decryption** – decrypt the score vector locally on the client
3. **Metadata retrieval** – request the top-k metadata entries mapped to the scores

The `scoring` API corresponds to the **first step** in this process. Instead of performing the entire full search pipeline, you can call `scoring()` directly to obtain the encrypted similarity scores only.

The query can be:

* A **plaintext query** (if `query_encryption="plain"` in the index configuration), or
* A **ciphertext query** (manually encrypted, or automatically if `query_encryption="cipher"`). Not currently supported.

***

#### Scoring with Plaintext Query

**Example**

```python
import pyenvector as ev
import numpy as np

# Prepare normalized data
vecs = np.random.rand(100, 512)
vecs = vecs / np.linalg.norm(vecs, axis=1, keepdims=True)

# Initialize with plaintext query option
ev.init(
    address="localhost:50050",
    key_path="keys",
    key_id="example",
)

# Create index and insert vectors
index = ev.create_index("example_index", dim=512)
metadata = [f"metadata_{i}" for i in range(100)]
index.insert(vecs, metadata)

# Perform scoring with a plaintext query
search_index = ev.Index("example_index")
query = vecs[0]
scores = search_index.scoring(query)[0]

print(scores)
# Output:
# <pyenvector.crypto.block.CipherBlock object at 0x7fac8052d6d0>
```

***

📌 **Summary**

* `scoring()` returns an **encrypted vector of similarity scores** (one encrypted score for each vector stored in the index).
* With `query_encryption="plain"`, you can pass a **plaintext query**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.4.x/sdk-user-guide/search/scoring.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
