# Search for non indexed fields is not working Please help

**URL:** <https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996>\
**Category:** Elasticsearch\
**Created:** [January 22, 2020, 6:50am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996 "2020-01-22T06:50:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![srivatsalya](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srivatsalya](https://discuss.elastic.co/u/srivatsalya)\
**Post date:** [January 22, 2020, 6:50am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996/1 "2020-01-22T06:50:28Z")

</div>

Hello,

I want to filter the search results using non indexed field.

{  
"\_index" : "shipmentdata\_v1",  
"\_type" : "\_doc",  
"\_id" : "128Q711U",  
"\_score" : 1.0,  
"\_source" : {  
"bundleId" : 13663,  
"customerId" : 101456  
}  
}  
for example customer Id.

I used below and it gives me an exception:  
{

> "query": { "match": { "customerId": 129759 } }  
> }  
> '

{  
"error" : {  
"root\_cause" : [  
{  
"type" : "query\_shard\_exception",  
"reason" : "failed to create query: {\n "match" : {\n "customerId" : {\n "query" : 129759,\n "operator" : "OR",\n "prefix\_length" : 0,\n "max\_expansions" : 50,\n "fuzzy\_transpositions" : true,\n "lenient" : false,\n "zero\_terms\_query" : "NONE",\n "auto\_generate\_synonyms\_phrase\_query" : true,\n "boost" : 1.0\n }\n }\n}",  
"index\_uuid" : "2lkJMMvNQju8HmwMvPeo3A",  
"index" : "shipmentdata\_v1"  
}  
],  
"type" : "search\_phase\_execution\_exception",  
"reason" : "all shards failed",  
"phase" : "query",  
"grouped" : true,  
"failed\_shards" : [  
{  
"shard" : 0,  
"index" : "shipmentdata\_v1",  
"node" : "uGsbj81VRGmgHjgG4bgkKA",  
"reason" : {  
"type" : "query\_shard\_exception",  
"reason" : "failed to create query: {\n "match" : {\n "customerId" : {\n "query" : 129759,\n "operator" : "OR",\n "prefix\_length" : 0,\n "max\_expansions" : 50,\n "fuzzy\_transpositions" : true,\n "lenient" : false,\n "zero\_terms\_query" : "NONE",\n "auto\_generate\_synonyms\_phrase\_query" : true,\n "boost" : 1.0\n }\n }\n}",  
"index\_uuid" : "2lkJMMvNQju8HmwMvPeo3A",  
"index" : "shipmentdata\_v1",  
"caused\_by" : {  
"type" : "illegal\_argument\_exception",  
"reason" : "Cannot search on field [customerId] since it is not indexed."  
}  
}  
}  
]  
},  
"status" : 400  
}

I also tried to use

{

> "filter": {  
> "script": {  
> "script": "\_source['customerId'].value == 129759"  
> }  
> }  
> }

but it gave below exception:

{  
"error" : {  
"root\_cause" : [  
{  
"type" : "parsing\_exception",  
"reason" : "Unknown key for a START\_OBJECT in [filter].",  
"line" : 3,  
"col" : 11  
}  
],  
"type" : "parsing\_exception",  
"reason" : "Unknown key for a START\_OBJECT in [filter].",  
"line" : 3,  
"col" : 11  
},  
"status" : 400  
}

---

<div class="post-metadata">

**Author:** ![DeeeFOX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deeefox/32/49566_2.png) [@DeeeFOX](https://discuss.elastic.co/u/DeeeFOX)\
**Post date:** [January 22, 2020, 8:58am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996/2 "2020-01-22T08:58:48Z")

</div>

1、Search can not perform on fields that not index ( index mapping field setting "index: false" )

solution: reindex ur index with setting field setting "index: true"

2、Ur query body is illegal, syntax of "filter" should not be use in that way...

---

<div class="post-metadata">

**Author:** ![srivatsalya](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srivatsalya](https://discuss.elastic.co/u/srivatsalya)\
**Post date:** [January 23, 2020, 7:46am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996/3 "2020-01-23T07:46:32Z")

</div>

Thank you for quick response.

Since I am new to elastic search I tried different solutions from Google and applied here. Could you please let me know the correct syntax for filter. I am trying in different ways but unable to make it work.

---

<div class="post-metadata">

**Author:** ![DeeeFOX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deeefox/32/49566_2.png) [@DeeeFOX](https://discuss.elastic.co/u/DeeeFOX)\
**Post date:** [January 23, 2020, 10:12am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996/4 "2020-01-23T10:12:30Z")

</div>

Do u mind parse the query body that not work here, so we can figure out the problem and correct it directly?

And also, u can follow [this tutor](https://www.tutorialspoint.com/elasticsearch/elasticsearch_query_dsl.htm) to create ur own query body for searching which i think, is more friendly to new user than [es ref](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 20, 2020, 10:12am UTC](https://discuss.elastic.co/t/search-for-non-indexed-fields-is-not-working-please-help/215996/5 "2020-02-20T10:12:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
