# Missing field in a filter

**URL:** <https://discuss.elastic.co/t/missing-field-in-a-filter/11198>\
**Category:** Elasticsearch\
**Created:** [March 19, 2013, 1:48am UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198 "2013-03-19T01:48:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [March 19, 2013, 1:48am UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/1 "2013-03-19T01:48:52Z")

</div>

I am working on a query to do some searching between  
multiple indexes with different fields and I am having an issue with the  
location filter. In the query I was hoping that an or filter with a  
missing clause would solve this but I am still getting the error.

The bool statements with the exists clause in the query section fixes this  
issue but I have not been able to fine a way to work around it in the  
filters section. I have tried every combination I can think of with and,  
or and bool to get this to work.

The error message that I am getting is "QueryParsingException[[]  
failed to find geo\_point field [location.lat\_lon]".

Can anyone help me out?

Thank you,  
Stefanie

My query looks something like this:

{  
"query": {  
"custom\_filters\_score": {  
"query": {  
"bool": {  
"should": [  
{  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": "_exists_:title"  
}  
},  
{  
"query\_string": {  
"query": "title:Dallas",  
"boost": 2.0  
}  
}  
]  
}  
},  
{  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": "_exists_:description"  
}  
},  
{  
"query\_string": {  
"query": "description:Dallas",  
"boost": 2.0  
}  
}  
]  
}  
}  
],  
"minimum\_number\_should\_match": 1  
}  
},  
"filters": [  
{  
"filter": {  
"or": [  
{  
"missing": {  
"field": "location.lat\_lon"  
}  
},  
{  
"geo\_distance": {  
"distance": "50mi",  
"location.lat\_lon": [  
-96.795402,  
32.778149  
]  
}  
}  
]  
},  
"boost": 2.0  
}  
]  
}  
},  
"size": 20,  
"from": 0  
}

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 19, 2013, 11:43am UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/2 "2013-03-19T11:43:51Z")

</div>

On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote:

> I am working on a query to do some searching between multiple indexes  
> with different fields and I am having an issue with the location  
> filter. In the query I was hoping that an or filter with a missing  
> clause would solve this but I am still getting the error.

I think you're looking in the wrong place - it's not the missing clause  
that is the problem. It's the geo\_point field that is not mapped as  
such.

To demonstrate that this works correctly:

curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
{  
"mappings" : {  
"foo" : {  
"properties" : {  
"loc" : {  
"type" : "geo\_point"  
}  
}  
}  
}  
}  
'

# One doc with a loc

curl -XPOST '[http://127.0.0.1:9200/test/foo?pretty=1](http://127.0.0.1:9200/test/foo?pretty=1)' -d '  
{  
"loc" : [  
0,  
0  
],  
"text" : "xxx"  
}  
'

# One doc without a loc, in the same type

curl -XPOST '[http://127.0.0.1:9200/test/foo?pretty=1](http://127.0.0.1:9200/test/foo?pretty=1)' -d '  
{  
"text" : "xxx"  
}  
'

# One doc without a loc, in a different type

curl -XPOST '[http://127.0.0.1:9200/test/bar?pretty=1](http://127.0.0.1:9200/test/bar?pretty=1)' -d '  
{  
"text" : "xxx"  
}  
'

# Search across all types:

curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
{  
"query" : {  
"filtered" : {  
"filter" : {  
"geo\_distance" : {  
"distance" : "5km",  
"loc" : [  
0,  
0  
]  
}  
},  
"query" : {  
"match\_all" : {}  
}  
}  
}  
}  
'

# {

# "hits" : {

# "hits" : [

# {

# "\_source" : {

# "text" : "xxx",

# "loc" : [

# 0,

# 0

# ]

# },

# "\_score" : 1,

# "\_index" : "test",

# "\_id" : "ZB\_XJ4FjQxOYGCMbmXHM1g",

# "\_type" : "foo"

# }

# ],

# "max\_score" : 1,

# "total" : 1

# },

# "timed\_out" : false,

# "\_shards" : {

# "failed" : 0,

# "successful" : 5,

# "total" : 5

# },

# "took" : 4

# }

--  
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:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [March 19, 2013, 4:21pm UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/3 "2013-03-19T16:21:01Z")

</div>

Clinton,  
Thank you for the reply.

My issue I am having is not with my mapping but that I am searching across  
multiple indexes and not all  
of them has the location.lat\_log field. I want the filter to come back  
true for the indexes that have the field is within  
the range or if the index does not have the field. If I only run the query  
for the indexes with the location.lat\_lon field I do  
not get any errors but when the query is run across all of the indexes it  
fails on the once where the field does not exist.  
I am using alias to group multiple indexes together and I do not want to  
have to add unnecessary fields or run multiple  
queries if I do not need to.

I do not have this issue when I do something similar in the query section,  
using something like this where the field title  
is not in all of my indexes:

"bool": {  
"must": [  
{  
"query\_string": {  
"query": "_exists_:title"  
}  
},  
{  
"query\_string": {  
"query": "title:Dallas",  
"boost": 2.0  
}  
}  
]  
}

Thank you,  
Stefanie

On Tuesday, March 19, 2013 7:43:51 AM UTC-4, Clinton Gormley wrote:

> On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote:
> 
> > I am working on a query to do some searching between multiple indexes  
> > with different fields and I am having an issue with the location  
> > filter. In the query I was hoping that an or filter with a missing  
> > clause would solve this but I am still getting the error.
> 
> I think you're looking in the wrong place - it's not the missing clause  
> that is the problem. It's the geo\_point field that is not mapped as  
> such.
> 
> To demonstrate that this works correctly:
> 
> curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> {  
> "mappings" : {  
> "foo" : {  
> "properties" : {  
> "loc" : {  
> "type" : "geo\_point"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> # One doc with a loc
> 
> curl -XPOST '[http://127.0.0.1:9200/test/foo?pretty=1](http://127.0.0.1:9200/test/foo?pretty=1)' -d '  
> {  
> "loc" : [  
> 0,  
> 0  
> ],  
> "text" : "xxx"  
> }  
> '
> 
> # One doc without a loc, in the same type
> 
> curl -XPOST '[http://127.0.0.1:9200/test/foo?pretty=1](http://127.0.0.1:9200/test/foo?pretty=1)' -d '  
> {  
> "text" : "xxx"  
> }  
> '
> 
> # One doc without a loc, in a different type
> 
> curl -XPOST '[http://127.0.0.1:9200/test/bar?pretty=1](http://127.0.0.1:9200/test/bar?pretty=1)' -d '  
> {  
> "text" : "xxx"  
> }  
> '
> 
> # Search across all types:
> 
> curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "filtered" : {  
> "filter" : {  
> "geo\_distance" : {  
> "distance" : "5km",  
> "loc" : [  
> 0,  
> 0  
> ]  
> }  
> },  
> "query" : {  
> "match\_all" : {}  
> }  
> }  
> }  
> }  
> '
> 
> # {
> 
> # "hits" : {
> 
> # "hits" : [
> 
> # {
> 
> # "\_source" : {
> 
> # "text" : "xxx",
> 
> # "loc" : [
> 
> # 0,
> 
> # 0
> 
> # ]
> 
> # },
> 
> # "\_score" : 1,
> 
> # "\_index" : "test",
> 
> # "\_id" : "ZB\_XJ4FjQxOYGCMbmXHM1g",
> 
> # "\_type" : "foo"
> 
> # }
> 
> # ],
> 
> # "max\_score" : 1,
> 
> # "total" : 1
> 
> # },
> 
> # "timed\_out" : false,
> 
> # "\_shards" : {
> 
> # "failed" : 0,
> 
> # "successful" : 5,
> 
> # "total" : 5
> 
> # },
> 
> # "took" : 4
> 
> # }

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 19, 2013, 7:34pm UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/4 "2013-03-19T19:34:50Z")

</div>

Hi Stefanie

> Clinton,  
> Thank you for the reply.
> 
> My issue I am having is not with my mapping but that I am searching  
> across multiple indexes and not all  
> of them has the location.lat\_log field. I want the filter to come  
> back true for the indexes that have the field is within  
> the range or if the index does not have the field. If I only run the  
> query for the indexes with the location.lat\_lon field I do  
> not get any errors but when the query is run across all of the indexes  
> it fails on the once where the field does not exist.  
> I am using alias to group multiple indexes together and I do not want  
> to have to add unnecessary fields or run multiple  
> queries if I do not need to.
> 
> I do not have this issue when I do something similar in the query  
> section, using something like this where the field title  
> is not in all of my indexes:

Please reread my email. The problem is not what you think it is, as i  
demonstrated with my example below

> On Tuesday, March 19, 2013 7:43:51 AM UTC-4, Clinton Gormley wrote:  
> On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote:  
> \> I am working on a query to do some searching between  
> multiple indexes  
> \> with different fields and I am having an issue with the  
> location  
> \> filter. In the query I was hoping that an or filter with a  
> missing  
> \> clause would solve this but I am still getting the error.
> 
> ```
> I think you're looking in the wrong place - it's not the
> missing clause 
> that is the problem. It's the geo_point field that is not
> mapped as 
> such. 
>     
> To demonstrate that this works correctly: 
>     
> curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d ' 
> { 
> "mappings" : { 
> "foo" : { 
> "properties" : { 
> "loc" : { 
> "type" : "geo_point" 
> } 
> } 
> } 
> } 
> } 
> ' 
>     
> # One doc with a loc 
> curl -XPOST 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> { 
> "loc" : [ 
> 0, 
> 0 
> ], 
> "text" : "xxx" 
> } 
> ' 
>     
> # One doc without a loc, in the same type 
> curl -XPOST 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> { 
> "text" : "xxx" 
> } 
> ' 
>     
> # One doc without a loc, in a different type 
> curl -XPOST 'http://127.0.0.1:9200/test/bar?pretty=1' -d ' 
> { 
> "text" : "xxx" 
> } 
> ' 
>     
>     
> # Search across all types: 
>     
> curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1' -d
> ' 
> { 
> "query" : { 
> "filtered" : { 
> "filter" : { 
> "geo_distance" : { 
> "distance" : "5km", 
> "loc" : [ 
> 0, 
> 0 
> ] 
> } 
> }, 
> "query" : { 
> "match_all" : {} 
> } 
> } 
> } 
> } 
> ' 
>     
> # { 
> # "hits" : { 
> # "hits" : [ 
> # { 
> # "_source" : { 
> # "text" : "xxx", 
> # "loc" : [ 
> # 0, 
> # 0 
> # ] 
> # }, 
> # "_score" : 1, 
> # "_index" : "test", 
> # "_id" : "ZB_XJ4FjQxOYGCMbmXHM1g", 
> # "_type" : "foo" 
> # } 
> # ], 
> # "max_score" : 1, 
> # "total" : 1 
> # }, 
> # "timed_out" : false, 
> # "_shards" : { 
> # "failed" : 0, 
> # "successful" : 5, 
> # "total" : 5 
> # }, 
> # "took" : 4 
> # } 
> 
> ```
> 
> --  
> 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:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [March 19, 2013, 8:10pm UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/5 "2013-03-19T20:10:05Z")

</div>

Clinton,

The setup that I have is:

index test1  
curl -X POST [http://localhost:9200/test1](http://localhost:9200/test1) -d '{  
"mappings": {  
"a": {  
"properties": {  
"id": {  
"type": "string",  
"index": "not\_analyzed",  
"include\_in\_all": true  
},  
"title": {  
"type": "string",  
"analyzer": "snowball",  
"boost": 2.0  
},  
"description": {  
"type": "string",  
"analyzer": "snowball"  
}  
}  
}  
}  
}'

index test2  
curl -X POST [http://localhost:9200/test2](http://localhost:9200/test2) -d '{  
"mappings": {  
"b": {  
"properties": {  
"id": {  
"type": "string",  
"index": "not\_analyzed",  
"include\_in\_all": true  
},  
"description": {  
"type": "string",  
"analyzer": "snowball",  
"boost": 2.0  
},  
"location": {  
"properties": {  
"lat\_lon": {  
"type": "geo\_point",  
"lat\_lon": true  
}  
}  
}  
}  
}  
}  
}'

my alias is set up as  
curl -X POST "[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)" -d '{  
"actions":[  
{"add":{  
"index":"test1",  
"alias":"u1"  
}  
},  
{"add":{  
"index":"test2",  
"alias":"u1"  
}  
}  
]  
}'

I am running my query against the alias and what I am looking for is test1  
that matches "Dallas" in title or description and test2 that matches  
"Dallas" in description or location.lat\_lon within 50 miles of [-96.795402,  
32.778149]. The boolean in the query section works so that I do not get an  
error when test2 does not have the field title but is does not work within  
the filters section when test1 does not have the field location.lat\_lon.  
If I run the query against just test2 I do not get any errors.

Thank you,  
Stefanie

On Tuesday, March 19, 2013 3:34:50 PM UTC-4, Clinton Gormley wrote:

> Hi Stefanie
> 
> > Clinton,  
> > Thank you for the reply.
> > 
> > My issue I am having is not with my mapping but that I am searching  
> > across multiple indexes and not all  
> > of them has the location.lat\_log field. I want the filter to come  
> > back true for the indexes that have the field is within  
> > the range or if the index does not have the field. If I only run the  
> > query for the indexes with the location.lat\_lon field I do  
> > not get any errors but when the query is run across all of the indexes  
> > it fails on the once where the field does not exist.  
> > I am using alias to group multiple indexes together and I do not want  
> > to have to add unnecessary fields or run multiple  
> > queries if I do not need to.
> > 
> > I do not have this issue when I do something similar in the query  
> > section, using something like this where the field title  
> > is not in all of my indexes:
> 
> Please reread my email. The problem is not what you think it is, as i  
> demonstrated with my example below
> 
> > On Tuesday, March 19, 2013 7:43:51 AM UTC-4, Clinton Gormley wrote:  
> > On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote:  
> > \> I am working on a query to do some searching between  
> > multiple indexes  
> > \> with different fields and I am having an issue with the  
> > location  
> > \> filter. In the query I was hoping that an or filter with a  
> > missing  
> > \> clause would solve this but I am still getting the error.
> > 
> > ```
> > I think you're looking in the wrong place - it's not the 
> > missing clause 
> > that is the problem. It's the geo_point field that is not 
> > mapped as 
> > such. 
> >     
> > To demonstrate that this works correctly: 
> >     
> > curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d ' 
> > { 
> > "mappings" : { 
> > "foo" : { 
> > "properties" : { 
> > "loc" : { 
> > "type" : "geo_point" 
> > } 
> > } 
> > } 
> > } 
> > } 
> > ' 
> >     
> > # One doc with a loc 
> > curl -XPOST 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > { 
> > "loc" : [ 
> > 0, 
> > 0 
> > ], 
> > "text" : "xxx" 
> > } 
> > ' 
> >     
> > # One doc without a loc, in the same type 
> > curl -XPOST 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > { 
> > "text" : "xxx" 
> > } 
> > ' 
> >     
> > # One doc without a loc, in a different type 
> > curl -XPOST 'http://127.0.0.1:9200/test/bar?pretty=1' -d ' 
> > { 
> > "text" : "xxx" 
> > } 
> > ' 
> >     
> >     
> > # Search across all types: 
> >     
> > curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1' -d 
> > ' 
> > { 
> > "query" : { 
> > "filtered" : { 
> > "filter" : { 
> > "geo_distance" : { 
> > "distance" : "5km", 
> > "loc" : [ 
> > 0, 
> > 0 
> > ] 
> > } 
> > }, 
> > "query" : { 
> > "match_all" : {} 
> > } 
> > } 
> > } 
> > } 
> > ' 
> >     
> > # { 
> > # "hits" : { 
> > # "hits" : [ 
> > # { 
> > # "_source" : { 
> > # "text" : "xxx", 
> > # "loc" : [ 
> > # 0, 
> > # 0 
> > # ] 
> > # }, 
> > # "_score" : 1, 
> > # "_index" : "test", 
> > # "_id" : "ZB_XJ4FjQxOYGCMbmXHM1g", 
> > # "_type" : "foo" 
> > # } 
> > # ], 
> > # "max_score" : 1, 
> > # "total" : 1 
> > # }, 
> > # "timed_out" : false, 
> > # "_shards" : { 
> > # "failed" : 0, 
> > # "successful" : 5, 
> > # "total" : 5 
> > # }, 
> > # "took" : 4 
> > # } 
> > 
> > ```
> > 
> > --  
> > 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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 19, 2013, 8:32pm UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/6 "2013-03-19T20:32:10Z")

</div>

Hi Stefanie

Whole hearted apologies - I was incorrect.

It does indeed fail if the field is not in the mapping of whichever  
index it looks at first (which varies per shard and per run)

please open an issue for this

thanks

Clint

On Tue, 2013-03-19 at 13:10 -0700, Stefanie wrote:

> Clinton,
> 
> The setup that I have is:
> 
> index test1  
> curl -X POST [http://localhost:9200/test1](http://localhost:9200/test1) -d '{  
> "mappings": {  
> "a": {  
> "properties": {  
> "id": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "include\_in\_all": true  
> },  
> "title": {  
> "type": "string",  
> "analyzer": "snowball",  
> "boost": 2.0  
> },  
> "description": {  
> "type": "string",  
> "analyzer": "snowball"  
> }  
> }  
> }  
> }  
> }'
> 
> index test2  
> curl -X POST [http://localhost:9200/test2](http://localhost:9200/test2) -d '{  
> "mappings": {  
> "b": {  
> "properties": {  
> "id": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "include\_in\_all": true  
> },  
> "description": {  
> "type": "string",  
> "analyzer": "snowball",  
> "boost": 2.0  
> },  
> "location": {  
> "properties": {  
> "lat\_lon": {  
> "type": "geo\_point",  
> "lat\_lon": true  
> }  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> my alias is set up as  
> curl -X POST "[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)" -d '{  
> "actions":[  
> {"add":{  
> "index":"test1",  
> "alias":"u1"  
> }  
> },  
> {"add":{  
> "index":"test2",  
> "alias":"u1"  
> }  
> }  
> ]  
> }'
> 
> I am running my query against the alias and what I am looking for is  
> test1 that matches "Dallas" in title or description and test2 that  
> matches "Dallas" in description or location.lat\_lon within 50 miles  
> of [-96.795402, 32.778149]. The boolean in the query section works so  
> that I do not get an error when test2 does not have the field title  
> but is does not work within the filters section when test1 does not  
> have the field location.lat\_lon. If I run the query against just  
> test2 I do not get any errors.
> 
> Thank you,  
> Stefanie
> 
> On Tuesday, March 19, 2013 3:34:50 PM UTC-4, Clinton Gormley wrote:  
> Hi Stefanie
> 
> ```
> > Clinton, 
> > Thank you for the reply. 
> > 
> > 
> > My issue I am having is not with my mapping but that I am
> searching 
> > across multiple indexes and not all 
> > of them has the location.lat_log field. I want the filter
> to come 
> > back true for the indexes that have the field is within 
> > the range or if the index does not have the field. If I
> only run the 
> > query for the indexes with the location.lat_lon field I do 
> > not get any errors but when the query is run across all of
> the indexes 
> > it fails on the once where the field does not exist.   
> > I am using alias to group multiple indexes together and I do
> not want 
> > to have to add unnecessary fields or run multiple 
> > queries if I do not need to.   
> > 
> > 
> > I do not have this issue when I do something similar in the
> query 
> > section, using something like this where the field title 
> > is not in all of my indexes: 
>     
> Please reread my email. The problem is not what you think it
> is, as i 
> demonstrated with my example below 
>     
> > 
> > On Tuesday, March 19, 2013 7:43:51 AM UTC-4, Clinton Gormley
> wrote: 
> > On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote: 
> > > I am working on a query to do some searching
> between 
> > multiple indexes 
> > > with different fields and I am having an issue
> with the 
> > location 
> > > filter. In the query I was hoping that an or
> filter with a 
> > missing 
> > > clause would solve this but I am still getting the
> error.   
> >         
> > I think you're looking in the wrong place - it's not
> the 
> > missing clause 
> > that is the problem. It's the geo_point field that
> is not 
> > mapped as 
> > such. 
> >         
> > To demonstrate that this works correctly: 
> >         
> > curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'
> -d ' 
> > { 
> > "mappings" : { 
> > "foo" : { 
> > "properties" : { 
> > "loc" : { 
> > "type" : "geo_point" 
> > } 
> > } 
> > } 
> > } 
> > } 
> > ' 
> >         
> > # One doc with a loc 
> > curl -XPOST
> 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > { 
> > "loc" : [ 
> > 0, 
> > 0 
> > ], 
> > "text" : "xxx" 
> > } 
> > ' 
> >         
> > # One doc without a loc, in the same type 
> > curl -XPOST
> 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > { 
> > "text" : "xxx" 
> > } 
> > ' 
> >         
> > # One doc without a loc, in a different type 
> > curl -XPOST
> 'http://127.0.0.1:9200/test/bar?pretty=1' -d ' 
> > { 
> > "text" : "xxx" 
> > } 
> > ' 
> >         
> >         
> > # Search across all types: 
> >         
> > curl -XGET
> 'http://127.0.0.1:9200/test/_search?pretty=1' -d 
> > ' 
> > { 
> > "query" : { 
> > "filtered" : { 
> > "filter" : { 
> > "geo_distance" : { 
> > "distance" : "5km", 
> > "loc" : [ 
> > 0, 
> > 0 
> > ] 
> > } 
> > }, 
> > "query" : { 
> > "match_all" : {} 
> > } 
> > } 
> > } 
> > } 
> > ' 
> >         
> > # { 
> > # "hits" : { 
> > # "hits" : [ 
> > # { 
> > # "_source" : { 
> > # "text" : "xxx", 
> > # "loc" : [ 
> > # 0, 
> > # 0 
> > # ] 
> > # }, 
> > # "_score" : 1, 
> > # "_index" : "test", 
> > # "_id" : "ZB_XJ4FjQxOYGCMbmXHM1g", 
> > # "_type" : "foo" 
> > # } 
> > # ], 
> > # "max_score" : 1, 
> > # "total" : 1 
> > # }, 
> > # "timed_out" : false, 
> > # "_shards" : { 
> > # "failed" : 0, 
> > # "successful" : 5, 
> > # "total" : 5 
> > # }, 
> > # "took" : 4 
> > # } 
> >         
> >         
> >         
> > 
> > -- 
> > 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. 
> > For more options, visit
> 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).

--  
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:** ![Stefanie](https://avatars.discourse-cdn.com/v4/letter/s/fbc32d/32.png) [@Stefanie](https://discuss.elastic.co/u/Stefanie)\
**Post date:** [March 19, 2013, 9:15pm UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/7 "2013-03-19T21:15:40Z")

</div>

No problem.

The issue number is 2801

Stefanie

On Tuesday, March 19, 2013 4:32:10 PM UTC-4, Clinton Gormley wrote:

> Hi Stefanie
> 
> Whole hearted apologies - I was incorrect.
> 
> It does indeed fail if the field is not in the mapping of whichever  
> index it looks at first (which varies per shard and per run)
> 
> please open an issue for this
> 
> thanks
> 
> Clint
> 
> On Tue, 2013-03-19 at 13:10 -0700, Stefanie wrote:
> 
> > Clinton,
> > 
> > The setup that I have is:
> > 
> > index test1  
> > curl -X POST [http://localhost:9200/test1](http://localhost:9200/test1) -d '{  
> > "mappings": {  
> > "a": {  
> > "properties": {  
> > "id": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "include\_in\_all": true  
> > },  
> > "title": {  
> > "type": "string",  
> > "analyzer": "snowball",  
> > "boost": 2.0  
> > },  
> > "description": {  
> > "type": "string",  
> > "analyzer": "snowball"  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > index test2  
> > curl -X POST [http://localhost:9200/test2](http://localhost:9200/test2) -d '{  
> > "mappings": {  
> > "b": {  
> > "properties": {  
> > "id": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "include\_in\_all": true  
> > },  
> > "description": {  
> > "type": "string",  
> > "analyzer": "snowball",  
> > "boost": 2.0  
> > },  
> > "location": {  
> > "properties": {  
> > "lat\_lon": {  
> > "type": "geo\_point",  
> > "lat\_lon": true  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > my alias is set up as  
> > curl -X POST "[http://localhost:9200/\_aliases](http://localhost:9200/_aliases)" -d '{  
> > "actions":[  
> > {"add":{  
> > "index":"test1",  
> > "alias":"u1"  
> > }  
> > },  
> > {"add":{  
> > "index":"test2",  
> > "alias":"u1"  
> > }  
> > }  
> > ]  
> > }'
> > 
> > I am running my query against the alias and what I am looking for is  
> > test1 that matches "Dallas" in title or description and test2 that  
> > matches "Dallas" in description or location.lat\_lon within 50 miles  
> > of [-96.795402, 32.778149]. The boolean in the query section works so  
> > that I do not get an error when test2 does not have the field title  
> > but is does not work within the filters section when test1 does not  
> > have the field location.lat\_lon. If I run the query against just  
> > test2 I do not get any errors.
> > 
> > Thank you,  
> > Stefanie
> > 
> > On Tuesday, March 19, 2013 3:34:50 PM UTC-4, Clinton Gormley wrote:  
> > Hi Stefanie
> > 
> > ```
> > > Clinton, 
> > > Thank you for the reply. 
> > > 
> > > 
> > > My issue I am having is not with my mapping but that I am 
> > searching 
> > > across multiple indexes and not all 
> > > of them has the location.lat_log field. I want the filter 
> > to come 
> > > back true for the indexes that have the field is within 
> > > the range or if the index does not have the field. If I 
> > only run the 
> > > query for the indexes with the location.lat_lon field I do 
> > > not get any errors but when the query is run across all of 
> > the indexes 
> > > it fails on the once where the field does not exist.   
> > > I am using alias to group multiple indexes together and I do 
> > not want 
> > > to have to add unnecessary fields or run multiple 
> > > queries if I do not need to.   
> > > 
> > > 
> > > I do not have this issue when I do something similar in the 
> > query 
> > > section, using something like this where the field title 
> > > is not in all of my indexes: 
> >     
> > Please reread my email. The problem is not what you think it 
> > is, as i 
> > demonstrated with my example below 
> >     
> > > 
> > > On Tuesday, March 19, 2013 7:43:51 AM UTC-4, Clinton Gormley 
> > wrote: 
> > > On Mon, 2013-03-18 at 18:48 -0700, Stefanie wrote: 
> > > > I am working on a query to do some searching 
> > between 
> > > multiple indexes 
> > > > with different fields and I am having an issue 
> > with the 
> > > location 
> > > > filter. In the query I was hoping that an or 
> > filter with a 
> > > missing 
> > > > clause would solve this but I am still getting the 
> > error.   
> > >         
> > > I think you're looking in the wrong place - it's not 
> > the 
> > > missing clause 
> > > that is the problem. It's the geo_point field that 
> > is not 
> > > mapped as 
> > > such. 
> > >         
> > > To demonstrate that this works correctly: 
> > >         
> > > curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' 
> > -d ' 
> > > { 
> > > "mappings" : { 
> > > "foo" : { 
> > > "properties" : { 
> > > "loc" : { 
> > > "type" : "geo_point" 
> > > } 
> > > } 
> > > } 
> > > } 
> > > } 
> > > ' 
> > >         
> > > # One doc with a loc 
> > > curl -XPOST 
> > 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > > { 
> > > "loc" : [ 
> > > 0, 
> > > 0 
> > > ], 
> > > "text" : "xxx" 
> > > } 
> > > ' 
> > >         
> > > # One doc without a loc, in the same type 
> > > curl -XPOST 
> > 'http://127.0.0.1:9200/test/foo?pretty=1' -d ' 
> > > { 
> > > "text" : "xxx" 
> > > } 
> > > ' 
> > >         
> > > # One doc without a loc, in a different type 
> > > curl -XPOST 
> > 'http://127.0.0.1:9200/test/bar?pretty=1' -d ' 
> > > { 
> > > "text" : "xxx" 
> > > } 
> > > ' 
> > >         
> > >         
> > > # Search across all types: 
> > >         
> > > curl -XGET 
> > 'http://127.0.0.1:9200/test/_search?pretty=1' -d 
> > > ' 
> > > { 
> > > "query" : { 
> > > "filtered" : { 
> > > "filter" : { 
> > > "geo_distance" : { 
> > > "distance" : "5km", 
> > > "loc" : [ 
> > > 0, 
> > > 0 
> > > ] 
> > > } 
> > > }, 
> > > "query" : { 
> > > "match_all" : {} 
> > > } 
> > > } 
> > > } 
> > > } 
> > > ' 
> > >         
> > > # { 
> > > # "hits" : { 
> > > # "hits" : [ 
> > > # { 
> > > # "_source" : { 
> > > # "text" : "xxx", 
> > > # "loc" : [ 
> > > # 0, 
> > > # 0 
> > > # ] 
> > > # }, 
> > > # "_score" : 1, 
> > > # "_index" : "test", 
> > > # "_id" : "ZB_XJ4FjQxOYGCMbmXHM1g", 
> > > # "_type" : "foo" 
> > > # } 
> > > # ], 
> > > # "max_score" : 1, 
> > > # "total" : 1 
> > > # }, 
> > > # "timed_out" : false, 
> > > # "_shards" : { 
> > > # "failed" : 0, 
> > > # "successful" : 5, 
> > > # "total" : 5 
> > > # }, 
> > > # "took" : 4 
> > > # } 
> > >         
> > >         
> > >         
> > > 
> > > -- 
> > > 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. 
> > > For more options, visit 
> > 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 [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:** ![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:45am UTC](https://discuss.elastic.co/t/missing-field-in-a-filter/11198/8 "2017-07-06T02:45:43Z")

</div>


