# No mapping found for \[lname.raw\] in order to sort on

**URL:** <https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238>\
**Category:** OpenSearch\
**Tags:** troubleshoot, configure\
**Created:** [May 7, 2024, 1:22pm UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238 "2024-05-07T13:22:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagsmode](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/bagsmode/32/7480_2.png) [@bagsmode](https://forum.opensearch.org/u/bagsmode)\
**Post date:** [May 7, 2024, 1:22pm UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238/1 "2024-05-07T13:22:50Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):

“opensearch-project/opensearch-php”: “^2.2”

**Describe the issue** :

We are converting from Elastic to OpenSearch in Azure, and am getting the following error  
(hoping someone might be able to shed some light on why it’s saying that the mapping is not found, when it is defined–see config below–and appears to be defined the way suggested by the documentation):  
{  
“type”:“query\_shard\_exception”,  
“reason”:“No mapping found for [lname.raw] in order to sort on”,  
…  
}

On the query:

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "familyRelationship": "Primary"
          }
        }
      ]
    }
  },
  "sort": {
    "lname.raw": "asc"
  }
}

```

**Configuration** :

```auto
{
  "mappings": {
    "properties": {
      "familyRelationship": {
        "type": "keyword"
      },
      "lname": {
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

```

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [May 8, 2024, 3:37am UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238/2 "2024-05-08T03:37:23Z")

</div>

Do you use index alias to search, if so could you check if all indices behind the alias contain the field `lname.raw`?

---

<div class="post-metadata">

**Author:** ![bagsmode](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/bagsmode/32/7480_2.png) [@bagsmode](https://forum.opensearch.org/u/bagsmode)\
**Post date:** [May 8, 2024, 11:40am UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238/3 "2024-05-08T11:40:10Z")

</div>

> [@gaobinlong](#):
>
> index alias

Good morning!  
No, I am not using any aliases.

---

<div class="post-metadata">

**Author:** ![bagsmode](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/bagsmode/32/7480_2.png) [@bagsmode](https://forum.opensearch.org/u/bagsmode)\
**Post date:** [May 8, 2024, 4:49pm UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238/4 "2024-05-08T16:49:42Z")

</div>

OK, found that if I update the “lname.raw” to “lname.keyword”, it works, and seems to still sort correctly.

However, if I try the same with “aggs”:

```auto
"aggs": {
  "total_families": {
    "terms": {
      "field": "fid.keyword",
      "size": 2000000
    }
  }
}

```

I’m not getting a total, coming back with 0 (zero), although I know there are values returned in fid (“fid” is the foreign key id for the family relationship). Apologies, this is a tangential issue.

---

<div class="post-metadata">

**Author:** ![bagsmode](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/bagsmode/32/7480_2.png) [@bagsmode](https://forum.opensearch.org/u/bagsmode)\
**Post date:** [May 8, 2024, 5:12pm UTC](https://forum.opensearch.org/t/no-mapping-found-for-lname-raw-in-order-to-sort-on/19238/5 "2024-05-08T17:12:38Z")

</div>

Think I got it all figured out now. Basically a case of RTFM. 😁

From the manual, found out that the “size” is now (or at least for our purposes, should be) “precision\_threshold”. Once I updated, it’s working.

```auto
"aggs": {
  "total_families": {
    "cardinality": {
      "field": "fid.keyword",
      "precision_threshold": 10000
    }
  }
}

```
