# How to enable "numeric detection string"?

**URL:** <https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292>\
**Category:** OpenSearch\
**Tags:** releases, install\
**Created:** [May 7, 2025, 2:51pm UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292 "2025-05-07T14:51:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![911432](https://avatars.discourse-cdn.com/v4/letter/9/eb9ed0/32.png) [@911432](https://forum.opensearch.org/u/911432)\
**Post date:** [May 7, 2025, 2:51pm UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292/1 "2025-05-07T14:51:36Z")

</div>

How to [enable](https://docs.opensearch.org/docs/3.0/field-types/) “numerical detection string”?

---

<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 9, 2025, 5:48am UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292/2 "2025-05-09T05:48:12Z")

</div>

By setting `numeric_detection` to true:

```auto
PUT my-index
{
  "mappings": {
    "numeric_detection": true
  }
}

```

, the following fields field1 and field2 will be mapped as float type and long type, rather than text type:

```auto
PUT my-index/_doc/1
{
  "field1": "1.0",
  "field2": "1"
}

```

---

<div class="post-metadata">

**Author:** ![911432](https://avatars.discourse-cdn.com/v4/letter/9/eb9ed0/32.png) [@911432](https://forum.opensearch.org/u/911432)\
**Post date:** [May 12, 2025, 1:29pm UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292/6 "2025-05-12T13:29:27Z")

</div>

1. Can you recognize certain parts as correct letters and approximate numbers?

```auto
PUT my-index
{
  "mappings": {
    "properties": {
      "year": { "type" : "text" },
      "age": { "type" : "text", "numeric_detection": true },
      "director":{ "type" : "text", "numeric_detection": true }
    }
  }
}

```

RESPONSE

```auto
{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "my-index"
}

```

1. If you put in a large number, the correct value is text, and is it recognized as a number recognized as an approximate double or scale float value?

```auto
PUT /my-index_doc/1 
{
  "year": "99999999999999999999",
  "age": "99999999999999999999.99999999999999999999",
  "director": "ABC"
}

```

```auto
GET /my-index/_search
{
  "took": 14,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "my-index",
        "_id": "1",
        "_score": 1,
        "_ignored": [,
        ],
        "_source": {
          "year": "99999999999999999999",
          "age": "99999999999999999999.99999999999999999999",
          "director": "ABC"
        }
      }
    ]
  }
}

```

---

<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 13, 2025, 2:54am UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292/7 "2025-05-13T02:54:26Z")

</div>

numeric\_detection is used for dynamic mapping, so set mapping explicitly when creating index is not needed. The usage is:

```auto
PUT my-index
{
  "mappings": {
    "numeric_detection": true
  }
}

POST /my-index/_doc/1
{
  "year": "99999999999999999999",
  "age": "99999999999999999999.99999999999999999999",
  "director": "ABC"
}

```

, then check the mapping:

```auto
GET my-index/_mapping
{
  "my-index": {
    "mappings": {
      "numeric_detection": true,
      "properties": {
        "age": {
          "type": "float"
        },
        "director": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "year": {
          "type": "float"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![911432](https://avatars.discourse-cdn.com/v4/letter/9/eb9ed0/32.png) [@911432](https://forum.opensearch.org/u/911432)\
**Post date:** [May 21, 2025, 5:47am UTC](https://forum.opensearch.org/t/how-to-enable-numeric-detection-string/24292/10 "2025-05-21T05:47:17Z")

</div>

1. What happens when you do ‘GET /my-index/\_search’?

```auto
GET /my-index/_search

```

1. Can I search for the exact value 9999999999.9999999999 in OpenSearch even though I calculate it as an approximate value in OpenSearch DashBoard?
