# Search in type with one attribute as null or empty

**URL:** <https://discuss.elastic.co/t/search-in-type-with-one-attribute-as-null-or-empty/80457>\
**Category:** Elasticsearch\
**Created:** [March 29, 2017, 9:57am UTC](https://discuss.elastic.co/t/search-in-type-with-one-attribute-as-null-or-empty/80457 "2017-03-29T09:57:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![v.kumar](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@v.kumar](https://discuss.elastic.co/u/v.kumar)\
**Post date:** [March 29, 2017, 9:57am UTC](https://discuss.elastic.co/t/search-in-type-with-one-attribute-as-null-or-empty/80457/1 "2017-03-29T09:57:04Z")

</div>

Hi All,

I am using elastic search java api. We have indexed data as

GET eb\_portal\_index/part/\_search  
{  
"query": {  
"match": {  
"part\_no": "ME9143"  
}  
}  
}

We get result like

{  
"took": 16,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 11.686213,  
"hits": [  
{  
"\_index": "eb\_portal\_index",  
"\_type": "part",  
"\_id": "ME9143/0.0/null/null/null",  
"\_score": 11.686213,  
"\_source": {  
"part\_no": "ME9143",  
"min\_stock\_qty": 0,  
"latest\_price": 0,  
"latest\_leadtime": 0,  
"indexES": "part ME9143/00 IHC7\_Part",  
"revision": "00",  
"type": "IHC7\_Part",  
"object\_name": "ME9143",  
"object\_desc": "BB4026DU",  
"owning\_group": "Engineering",  
"uom\_tag": "each",  
"last\_release\_status": "Released",  
"date\_released": "2015-01-22T00:00:00.000+01:00",  
"last\_mod\_user": "Migrator (migrator)",  
"ihc7\_discipline": "Mechanical",  
"ihc7\_manufacturer": "",  
"ihc7\_manufacturerref": "",  
"bom\_qty": 0,  
"bom\_price": 0,  
"bom\_price\_total": 0  
}  
}  
]  
}  
}

Now I want to search all part in that index, which have object\_desc as empty or null , or object\_desc is not set for that part. Is it possible. How can i do in java

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [March 30, 2017, 9:01am UTC](https://discuss.elastic.co/t/search-in-type-with-one-attribute-as-null-or-empty/80457/2 "2017-03-30T09:01:23Z")

</div>

You can search using `exists` query inside a must\_not clause, see  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html#query-dsl-exists-query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html#query-dsl-exists-query)

Exists Query in Java API : [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-term-level-queries.html#java-query-dsl-exists-query](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-term-level-queries.html#java-query-dsl-exists-query)  
And Bool Query : [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-compound-queries.html#java-query-dsl-bool-query](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-compound-queries.html#java-query-dsl-bool-query)

---

<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:** [April 27, 2017, 9:01am UTC](https://discuss.elastic.co/t/search-in-type-with-one-attribute-as-null-or-empty/80457/3 "2017-04-27T09:01:34Z")

</div>

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