# Searching non-indexed fields throwing error

**URL:** <https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404>\
**Category:** Elasticsearch\
**Created:** [July 19, 2024, 7:58am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404 "2024-07-19T07:58:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sibasish.palo](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sibasish.palo](https://discuss.elastic.co/u/sibasish.palo)\
**Post date:** [July 19, 2024, 7:58am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/1 "2024-07-19T07:58:49Z")

</div>

we have some fields which are marked as below  
old version

```auto
"field1": {
            "type": "string",
            "index": "no"
          }

```

v8

```auto
"field1": {
          "type": "text",
          "index": false
        }

```

earlier in older version it used to send empty response without any exception but now when we search in the new ES version its throwing one exception `Cannot search on field [field1] since it is not indexed`

is there any recommendations to handle this scenario or is there any config available to suppress this behaviour(something similar to `ignore_unmapped `)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 19, 2024, 9:31am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/2 "2024-07-19T09:31:19Z")

</div>

What is the query?

---

<div class="post-metadata">

**Author:** ![sibasish.palo](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sibasish.palo](https://discuss.elastic.co/u/sibasish.palo)\
**Post date:** [July 22, 2024, 5:17am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/3 "2024-07-22T05:17:35Z")

</div>

@dadoonet

```auto
{
    "bool": {
        "must": [
            {
                "bool": {
                    "must": [
                        {
                            "dis_max": {
                                "queries": [
                                    {
                                        "bool": {
                                            "must": {
                                                "match": {
                                                    "field1": {
                                                        "query": "test",
                                                        "operator": "OR",
                                                        "boost": 2.0,
                                                        "max_expansions": 10
                                                    }
                                                }
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ]
    }
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 22, 2024, 8:09am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/4 "2024-07-22T08:09:34Z")

</div>

Why do you want to search within a field that you made non searchable?

---

<div class="post-metadata">

**Author:** ![sibasish.palo](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sibasish.palo](https://discuss.elastic.co/u/sibasish.palo)\
**Post date:** [July 24, 2024, 11:59am UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/5 "2024-07-24T11:59:34Z")

</div>

@dadoonet we have dynamic templates to have mappings to the fields which are not recognised and we mark them as non-indexed fields, even though these fields are not indexed users can still go ahead and search on these dynamic fields.

this is the reason why i am ending up in this situation.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 24, 2024, 9:17pm UTC](https://discuss.elastic.co/t/searching-non-indexed-fields-throwing-error/363404/6 "2024-07-24T21:17:17Z")

</div>

Your best chance is to mark them as searchable I guess.
