# Missing Query

**URL:** <https://discuss.elastic.co/t/missing-query/11723>\
**Category:** Elasticsearch\
**Created:** [April 29, 2013, 5:15am UTC](https://discuss.elastic.co/t/missing-query/11723 "2013-04-29T05:15:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@mohit\_Kumar](https://discuss.elastic.co/u/mohit_Kumar)\
**Post date:** [April 29, 2013, 5:15am UTC](https://discuss.elastic.co/t/missing-query/11723/1 "2013-04-29T05:15:15Z")

</div>

Hello floks,  
can you please help me out in identify where i am doing wrong.  
Following is my missing query :  
curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)' -d'{  
"query": {  
"match\_all": {}  
},  
"filter": {  
"or": [  
{  
"missing": {  
"field": "CompanyId"  
}  
},  
{  
"term": {  
"CompanyId": 119  
}  
}  
]  
}  
}'

I have 10 document in my elasticsearch. Only 8 of them having "CompanyId"  
field.  
when i run only missing query it result is correct that is 2 document which  
are not having "CompanyId" field. but when i am using it with "or" function  
it result is 2 document. which is wrong. I think total 10 document should  
be return by the above query.

kindly help me...  
thanks in advance.

Regrads  
Mohit Kumar Yadav  
(MCA/BBA)  
Assocaite Software Developer  
Next Gen Invent Corporation, Noida  
Email Id : [mohit.kumar@ngiventures.com](mailto:mohit.kumar@ngiventures.com),mohit.kumar.ngi@gmail.com

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [April 29, 2013, 5:28am UTC](https://discuss.elastic.co/t/missing-query/11723/2 "2013-04-29T05:28:06Z")

</div>

Hard to say without the data. Have you tried only the term filter? What is  
the mapping for the CompanyId field? Are you sure it is numeric? If not, is  
it not-analyzed?

--  
Ivan

On Sun, Apr 28, 2013 at 10:15 PM, Mohit Kumar Yadav \<  
[mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com)\> wrote:

> Hello floks,  
> can you please help me out in identify where i am doing wrong.  
> Following is my missing query :  
> curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)'  
> -d'{  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "or": [  
> {  
> "missing": {  
> "field": "CompanyId"  
> }  
> },  
> {  
> "term": {  
> "CompanyId": 119  
> }  
> }  
> ]  
> }  
> }'
> 
> I have 10 document in my elasticsearch. Only 8 of them having "CompanyId"  
> field.  
> when i run only missing query it result is correct that is 2 document  
> which are not having "CompanyId" field. but when i am using it with "or"  
> function it result is 2 document. which is wrong. I think total 10 document  
> should be return by the above query.
> 
> kindly help me...  
> thanks in advance.
> 
> Regrads  
> Mohit Kumar Yadav  
> (MCA/BBA)  
> Assocaite Software Developer  
> Next Gen Invent Corporation, Noida  
> Email Id : [mohit.kumar@ngiventures.com](mailto:mohit.kumar@ngiventures.com),mohit.kumar.ngi@gmail.com
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [April 29, 2013, 6:15am UTC](https://discuss.elastic.co/t/missing-query/11723/3 "2013-04-29T06:15:36Z")

</div>

Hi,  
Try to provide full curl recreation example. IMO the URL parameter 'size=0'  
looks strange.  
Lukáš  
Dne 29.4.2013 7:15 "Mohit Kumar Yadav" [mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com)  
napsal(a):

> Hello floks,  
> can you please help me out in identify where i am doing wrong.  
> Following is my missing query :  
> curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)'  
> -d'{  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "or": [  
> {  
> "missing": {  
> "field": "CompanyId"  
> }  
> },  
> {  
> "term": {  
> "CompanyId": 119  
> }  
> }  
> ]  
> }  
> }'
> 
> I have 10 document in my elasticsearch. Only 8 of them having "CompanyId"  
> field.  
> when i run only missing query it result is correct that is 2 document  
> which are not having "CompanyId" field. but when i am using it with "or"  
> function it result is 2 document. which is wrong. I think total 10 document  
> should be return by the above query.
> 
> kindly help me...  
> thanks in advance.
> 
> Regrads  
> Mohit Kumar Yadav  
> (MCA/BBA)  
> Assocaite Software Developer  
> Next Gen Invent Corporation, Noida  
> Email Id : [mohit.kumar@ngiventures.com](mailto:mohit.kumar@ngiventures.com),mohit.kumar.ngi@gmail.com
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mohit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@mohit\_Kumar](https://discuss.elastic.co/u/mohit_Kumar)\
**Post date:** [May 1, 2013, 6:16am UTC](https://discuss.elastic.co/t/missing-query/11723/4 "2013-05-01T06:16:02Z")

</div>

CompanyID Field - DataType is String.  
yes.. I have only try term filter.

On Monday, April 29, 2013 10:58:06 AM UTC+5:30, Ivan Brusic wrote:

> Hard to say without the data. Have you tried only the term filter? What is  
> the mapping for the CompanyId field? Are you sure it is numeric? If not, is  
> it not-analyzed?
> 
> --  
> Ivan
> 
> On Sun, Apr 28, 2013 at 10:15 PM, Mohit Kumar Yadav \<[mohit.k...@gmail.com](mailto:mohit.k...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello floks,  
> > can you please help me out in identify where i am doing wrong.  
> > Following is my missing query :  
> > curl -XGET '[http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)'  
> > -d'{  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "or": [  
> > {  
> > "missing": {  
> > "field": "CompanyId"  
> > }  
> > },  
> > {  
> > "term": {  
> > "CompanyId": 119  
> > }  
> > }  
> > ]  
> > }  
> > }'
> > 
> > I have 10 document in my elasticsearch. Only 8 of them having "CompanyId"  
> > field.  
> > when i run only missing query it result is correct that is 2 document  
> > which are not having "CompanyId" field. but when i am using it with "or"  
> > function it result is 2 document. which is wrong. I think total 10 document  
> > should be return by the above query.
> > 
> > kindly help me...  
> > thanks in advance.
> > 
> > Regrads  
> > Mohit Kumar Yadav  
> > (MCA/BBA)  
> > Assocaite Software Developer  
> > Next Gen Invent Corporation, Noida  
> > Email Id : [mohit...@ngiventures.com](mailto:mohit...@ngiventures.com) \<javascript:\>,  
> > [mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com) \<javascript:\>
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![aash\_dhariya](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@aash\_dhariya](https://discuss.elastic.co/u/aash_dhariya)\
**Post date:** [May 1, 2013, 7:52am UTC](https://discuss.elastic.co/t/missing-query/11723/5 "2013-05-01T07:52:03Z")

</div>

I think you need to set the companyId as numeric type as term query only  
matches the documents that have fields that contain the term(not\_analyzed) (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/term-query/))  
Or, if you want to keep it as string, you can also set the companyId field  
as not\_analyzed, like this]  
companId: {  
"type" : "string"  
"index" : "not\_analyzed"  
}

On Wed, May 1, 2013 at 11:46 AM, Mohit Kumar Yadav \<  
[mohit.kumar.ngi@gmail.com](mailto:mohit.kumar.ngi@gmail.com)\> wrote:

> CompanyID Field - DataType is String.  
> yes.. I have only try term filter.
> 
> On Monday, April 29, 2013 10:58:06 AM UTC+5:30, Ivan Brusic wrote:
> 
> > Hard to say without the data. Have you tried only the term filter? What  
> > is the mapping for the CompanyId field? Are you sure it is numeric? If not,  
> > is it not-analyzed?
> > 
> > --  
> > Ivan
> > 
> > On Sun, Apr 28, 2013 at 10:15 PM, Mohit Kumar Yadav \<[mohit.k...@gmail.com](mailto:mohit.k...@gmail.com)
> > 
> > > wrote:
> > 
> > > Hello floks,  
> > > can you please help me out in identify where i am doing wrong.  
> > > Following is my missing query :  
> > > curl -XGET '[http://localhost:9200/new\_\*\*index/new\_indext/\_search?size=](http://localhost:9200/new_**index/new_indext/_search?size=)\*\*  
> > > 0 [http://localhost:9200/new\_index/new\_indext/\_search?size=0](http://localhost:9200/new_index/new_indext/_search?size=0)' -d'{  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "or": [  
> > > {  
> > > "missing": {  
> > > "field": "CompanyId"  
> > > }  
> > > },  
> > > {  
> > > "term": {  
> > > "CompanyId": 119  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }'
> > > 
> > > I have 10 document in my elasticsearch. Only 8 of them having  
> > > "CompanyId" field.  
> > > when i run only missing query it result is correct that is 2 document  
> > > which are not having "CompanyId" field. but when i am using it with "or"  
> > > function it result is 2 document. which is wrong. I think total 10 document  
> > > should be return by the above query.
> > > 
> > > kindly help me...  
> > > thanks in advance.
> > > 
> > > Regrads  
> > > Mohit Kumar Yadav  
> > > (MCA/BBA)  
> > > Assocaite Software Developer  
> > > Next Gen Invent Corporation, Noida  
> > > Email Id : [mohit...@ngiventures.com](mailto:mohit...@ngiventures.com),mo\*\*hit.kumar.ngi@gmail.com
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Thanks,  
Aash

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:38am UTC](https://discuss.elastic.co/t/missing-query/11723/6 "2017-07-06T02:38:55Z")

</div>


