Unable to retrieve the similarity scoring on retreived search result?

Description

Hello

i am trying to get the similarity score on the search result
below is the result fetching structure

~~~

result = collection.query.near_text(

query=query,

limit=3,  # number of results

return_properties=\["chunk", "page", "source"\],

distance=True

)

)

for obj in result.objects:

score = obj.metadata.score

print(score)

~~~

but the score return None

My need to get the score on result to determine if the score is good enough to feed into the LLM/Prompting

Any help?

Hi @Umesh_Narayanan ,

Good Day!

Welcome to Weaviate Community!

As you are using near_text or pure vector searching, the result will include a distance value, not a score. If you would like to obtain score as a result, this is available when using hybrid search or BM25

See related post here

Hope this helps.

Hi @maryannc

Thanks for your response
as i looked at the distance value
i can see the value is None

```
dist= obj.metadata.distance
print(dist)

metadata=MetadataReturn(creation_time=None, last_update_time=None, distance=None, certainty=None, score=None, explain_score=None, is_consistent=None, rerank_score=None)

```

Hi,

Here’s an example on how you can correctly configure distance and enable it:

from weaviate.classes.query import MetadataQuery

jeopardy = client.collections.use("JeopardyQuestion")
response = jeopardy.query.near_text(
    query="animals in movies",
    limit=2,
    return_metadata=MetadataQuery(distance=True)
)

for o in response.objects:
    print(o.properties)
    print(o.metadata.distance)

To set similarity threshold you can also refer into this example: Vector similarity search | Weaviate Documentation

Hope this helps!