# NearText Queries returning NULL on Distance

**URL:** <https://forum.weaviate.io/t/neartext-queries-returning-null-on-distance/1967>\
**Category:** Support\
**Tags:** bug, wcs\
**Created:** [April 10, 2024, 7:12am UTC](https://forum.weaviate.io/t/neartext-queries-returning-null-on-distance/1967 "2024-04-10T07:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SomebodySysop](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/somebodysysop/32/70_2.png) [@SomebodySysop](https://forum.weaviate.io/u/SomebodySysop)\
**Post date:** [April 10, 2024, 7:12am UTC](https://forum.weaviate.io/t/neartext-queries-returning-null-on-distance/1967/1 "2024-04-10T07:12:36Z")

</div>

### Description

My NearText queries where I request the “distance” are returning NULL for distance. Here is a sample query:

`{ Get { SolrCopy ( limit: 10 hybrid: { query: "Key concerns surrounding genocide and its impact on social justice" alpha: 0.8 } where: { operator: And, operands: [{ path: ["site"], operator: Equal, valueText:"https://bible.booksai.org/"},{ operator: Or, operands: [{ path: ["groups"], operator: Equal, valueText: "Tanakh" }, { path: ["groups"], operator: Equal, valueText: "Talmud" }, { path: ["groups"], operator: Equal, valueText: "Jewish Thought" } ] } ] } ){ _additional { distance } docId site title nid type public url content taxonomy groups date summary questions sourceUrl } } }`

And this is what is returned:

```auto
{
  "data": {
    "Get": {
      "SolrCopy": [
        {
          "_additional": null,
          "content": "blah, blah...­",
          "date": "",
          "docId": "demo9-13891-01-fid-147876-6",
          "groups": [
            "Public",
            "Jewish Thought",
            "Theology",
            "Abraham Joshua Heschel"
          ],
          "nid": 13891,
          "public": "N",
          "questions": "",
          "site": "https://bible.booksai.org/",
          "sourceUrl": "https://archive.org/details/manisnotalonephi0000abra/page/179/mode/2up",
          "summary": "",
          "taxonomy": [],
          "title": "Heschel | Man is Not Alone | 18. The Problem of Needs",
          "type": "file",
          "url": "https://bible.booksai.org/system/files/[Man is Not Alone]_18 The Problem of Needs.pdf"
        },

```

and so on…

### Server Setup Information

- Weaviate Server Version: 1.24.6
- Deployment Method: 

### Any additional Information

This query does return the distance property:

```auto
Get {
    SolrCopy (
      limit: 10
      nearText: {
        concepts: ["show only content with nid equal to 3041"],
      }
      where: {
        operator: Equal
        valueInt: 3041 
        path: ["nid"]
      }
    ){
      _additional{
        distance
      }
      docId
      site
      title
      nid
      public
      url
      content
    }
  }
}

```

```auto
{
  "data": {
    "Get": {
      "SolrCopy": [
        {
          "_additional": {
            "distance": 0.22641623
          },
          "content": "t control",
          "docId": "realestatebooksai-3041-03-pid-3745-1",
          "nid": 3041,
          "public": "Y",
          "site": "https://ca.realestatebooksai.com/",
          "title": "Do a city’s annual rental inspections violate tenants’ rights to privacy or state law?",
          "url": "https://ca.realestatebooksai.com/node/3041"
        },

```

I also noticed that if I query for both id and distance:

`_additional { id distance }`

I get:

```auto
{
  "data": {
    "Get": {
      "SolrCopy": [
        {
          "_additional": {
            "distance": null,
            "id": "2da32b6a-6899-445b-5f4b-a7dcb4be4e3e"
          },
          "content": "pecial attention paid to some object. But do we pay

```

Confused. Is this a bug? How do I address this?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [April 11, 2024, 7:02pm UTC](https://forum.weaviate.io/t/neartext-queries-returning-null-on-distance/1967/2 "2024-04-11T19:02:52Z")

</div>

Hi!

As discussed in our support ticket, the issue here is that while the near text will return you a distance, hybrid (as well as bm25) will return a score.

So for example, take this code as an example:

```auto
result = collection.query.near_text(
    "Searching for a near text", limit=10,
    return_metadata=wvc.query.MetadataQuery(distance=True, score=True)
)
 
for e in result.objects:
    print(e.properties.get("title"), e.metadata.score, e.metadata.distance)

```

you will end up with something like:

> Universal Reinforcement Learning 0.0 0.19682461023330688  
> The Role of Time in the Creation of Knowledge 0.0 0.2159237265586853  
> …

notice that score will be 0, but the distance will be difference (lowest == closest)

```auto
now, for a hybrid search:
result = collection.query.hybrid(
    "reinforcement learning", limit=10,
    return_metadata=wvc.query.MetadataQuery(distance=True, score=True)
)
 
for e in result.objects:
    print(e.properties.get("title"), e.metadata.score, e.metadata.distance)

```

> Statistical Mechanics of Nonlinear On-line Learning for Ensemble Teachers 0.48838376998901367 None  
> Evolving Classifiers: Methods for Incremental Learning 0.44732069969177246 None

---

<div class="post-metadata">

**Author:** ![SomebodySysop](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/somebodysysop/32/70_2.png) [@SomebodySysop](https://forum.weaviate.io/u/SomebodySysop)\
**Post date:** [April 11, 2024, 8:46pm UTC](https://forum.weaviate.io/t/neartext-queries-returning-null-on-distance/1967/3 "2024-04-11T20:46:21Z")

</div>

Yes, I think I’ve got this part. I’m now using **certainty** for nearText and **score** for hybrid.

 ![whre does minchat discuss the 3 principles of isaiah (nearText certainty) 2024-04-10_23-51-50](https://canada1.discourse-cdn.com/flex027/uploads/weaviate/original/2X/c/c88ce7d013400edb6c1eac332ef0bb1a5bc8c541.jpeg)  
 ![whre does minchat discuss the 3 principles of isaiah (hybrid) 2024-04-10_23-51-50](https://canada1.discourse-cdn.com/flex027/uploads/weaviate/original/2X/a/a4686337d8623fdd2f466647379d410e1390fe9c.jpeg)

They obviously have very little in common, except being from 0 to 1 and higher value being closest to query.
