# Erorr: "\[query\_shard\_exception\] failed to find geo\_point field (in node js application)

**URL:** <https://discuss.elastic.co/t/erorr-query-shard-exception-failed-to-find-geo-point-field-in-node-js-application/114228>\
**Category:** Elasticsearch\
**Created:** [January 5, 2018, 7:33am UTC](https://discuss.elastic.co/t/erorr-query-shard-exception-failed-to-find-geo-point-field-in-node-js-application/114228 "2018-01-05T07:33:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thealitahir](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@thealitahir](https://discuss.elastic.co/u/thealitahir)\
**Post date:** [January 5, 2018, 7:33am UTC](https://discuss.elastic.co/t/erorr-query-shard-exception-failed-to-find-geo-point-field-in-node-js-application/114228/1 "2018-01-05T07:33:50Z")

</div>

I'm working on node js (version 6.1.0 ) application and using elasticsearch (version 5.0.1) in it. But I'm having issues in geo\_point query.  
I'm doing mapping like this

```
client.indices.putMapping({
    index: 'newtesting',
    type: 'newtesting',
    body: {
        "mappings": {
            "location": {
                "properties": {
                    "pin": {
                        "properties": {
                            "location": {
                                "type": "geo_point"
                            }
                        }
                    }
                }
            }
        }
    }
});

```

and inserting data like this

```
client.index({
                index: 'newtesting',
                type: 'newtesting',
                body: {

                    "pin" : {
                        "location" : {
                            "lat" : 40.12,
                            "lon" : -71.34
                        }
                    }
                }
            },
            function (err, result, ElasticStatus) {
                if(err)
                    res.send("Unable to add Vendor Location" + err );
                else{
                    console.log("Location Stored "+result);
                    res.send(result);
                }

            });

```

and doing searching like this

```
client.search({
                index: 'newtesting',
                type: 'newtesting',
                body: {
                    "query": {
                        "bool" : {
                            "must" : {
                                "match_all" : { }
                            },
                            "filter" : {
                                "geo_distance" : {
                                    "distance" : "200km",
                                    "pin.location" : {
                                        "lat" : 40,
                                        "lon" : -70
                                    }
                                }
                            }
                        }
                    }
                }
            }, function (error, response)
            {
                if(error)
                    console.log("error occured " + error);
                else {
                    console.log(response.hits.hits[0]._source);
                    vendorArray.push(response.hits.hits[0]._source);
                    res.status(200).json(vendorArray);
                }
            });

```

I've tried many different formats, but I always get this same error, tried different versions as well, but same error  
"[query\_shard\_exception] failed to find geo\_point field [pin.location]"  
Please help me if you have any idea about this

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [January 7, 2018, 1:08pm UTC](https://discuss.elastic.co/t/erorr-query-shard-exception-failed-to-find-geo-point-field-in-node-js-application/114228/2 "2018-01-07T13:08:52Z")

</div>

There are a few things wrong here. Your dealing with a type named `location` while calling `newtesting` everywhere. Here is what you need to fix:

1. The `putMapping` should have `"type": "location"` and the body should be the object under `properties.location`
2. The index request should have `"type": "location"`.
3. The search request should have `"type": "location"`

---

<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 4, 2018, 1:08pm UTC](https://discuss.elastic.co/t/erorr-query-shard-exception-failed-to-find-geo-point-field-in-node-js-application/114228/3 "2018-02-04T13:08:57Z")

</div>

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