# Elasticsearch shows points outside boundingbox nest

**URL:** <https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130>\
**Category:** Elasticsearch\
**Created:** [June 29, 2019, 6:52am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130 "2019-06-29T06:52:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [June 29, 2019, 6:52am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/1 "2019-06-29T06:52:17Z")

</div>

I use Bounding Box in elasticsearch but, I get points outside of box ,it never shows points inside this box. this my Code:

```
 var response = _elasticClient.Search<ElasticSearchModel>(
                     s => s.From((model.CurrentPage-1)*model.PageSize)
                     .Size(model.PageSize)
                     .Query(query => query.Bool(b => b
                     .Filter(f=>f.QueryString(d => d.Query(model.Keyword)))))
                     .Query(query => query.Bool(b => b
                     .Filter(filter => filter
           
                    .GeoBoundingBox(g => g
                    .Boost(1.1)
                    .Name("Location")
                    .Field(p => p.Location)
                    .BoundingBox(c => c
                    .TopLeft(model.Points.X2, model.Points.Y2)
                    .BottomRight(model.Points.X1, model.Points.Y1)  
                     )
                    .ValidationMethod(GeoValidationMethod.Strict)
                    .Type(GeoExecution.Indexed)
                    )
                    )
              

                        )
               ));
```

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [June 29, 2019, 7:28am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/2 "2019-06-29T07:28:44Z")

</div>

Hi,

Could you provide the following information:

- Version of Elasticsearch

- Mapping example

- Bounding box example

- Point example that you are expecting to be inside of the bounding box and it is not getting match.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [June 29, 2019, 11:33am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/3 "2019-06-29T11:33:22Z")

</div>

1)Version of Elasticsearch is 6.5, my amozon elasticsearch also 6.5.  
2) Mapping

```
{

* "state": "open",
* "settings": {
  * "index": {
    * "creation_date": "1561656440210",
    * "number_of_shards": "5",
    * "number_of_replicas": "1",
    * "uuid": "-KYZLyItRbSGaCcZ2y4wag",
    * "version": {
      * "created": "6050499"},
    * "provided_name": "honadonz"}},
* "mappings": {
  * "elasticsearchmodel": {
    * "properties": {
      * "buildingPhotos": {
        * "properties": {
          * "title": {
            * "type": "text",
            * "fields": {
              * "keyword": {
                * "ignore_above": 256,
                * "type": "keyword"}}}}},
      * "address": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "buildingRooms": {
        * "properties": {
          * "roomCount": {
            * "type": "integer"},
          * "roomType": {
            * "type": "integer"}}},
      * "moneyType": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "description": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "totalRooms": {
        * "type": "integer"},
      * "createdDate": {
        * "type": "date"},
      * "size": {
        * "type": "double"},
      * "sizeName": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "buildAction": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "ownerPrice": {
        * "type": "double"},
      * "buildType": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}},
      * "location": {
        * "type": "geo_point"},
      * "id": {
        * "type": "integer"},
      * "buildTitle": {
        * "type": "text",
        * "fields": {
          * "keyword": {
            * "ignore_above": 256,
            * "type": "keyword"}}}}}},
* "aliases": [],
* "primary_terms": {
  * "0": 1,
  * "1": 1,
  * "2": 1,
  * "3": 1,
  * "4": 1},
* "in_sync_allocations": {
  * "0": [
    * "R4A0rGIETFipJHArGG9MPQ"
, * "2eVySrycSWSShjyt6vSX5w"],
  * "1": [
    * "2ytj0PYXT5WN34TdDR058w"
, * "SNWs5bZUSlqt5d0MAoakMA"],
  * "2": [
    * "zW2g7W2vSVCtXmTsWH6xtA"
, * "CDsaaTjVTPijiABC61TzpA"],
  * "3": [
    * "ufemNrnGSTy1KH1kPegMrA"
, * "eYxzTCLPRY-JNGgITEseGQ"],
  * "4": [
    * "CifuWl5tT06qwOeVTej6nA"
, * "ZaPWMzwxRA-PMeEYLnkMcA"]}

}

```

1. 

![20](https://us1.discourse-cdn.com/elastic/original/3X/c/e/cec9a23d1e78022410665aa6fed930d9ccde4142.jpeg)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 29, 2019, 11:58am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/4 "2019-06-29T11:58:55Z")

</div>

Not related to your question but

> [@Ilyoskhuja](#):
>
> 1)Version of Elasticsearch is 6.5, my amozon elasticsearch also 6.5.

BTW did you look at [Elastic Cloud: Hosted Elasticsearch, Hosted Search | Elastic](https://www.elastic.co/cloud) and [AWS Marketplace: Elastic Cloud (Elasticsearch Service)](https://aws.amazon.com/marketplace/pp/B01N6YCISK) ?

Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, APM, Logs UI, Infra UI, SIEM, Maps UI and what is coming next 🙂 ...

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [June 29, 2019, 12:47pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/5 "2019-06-29T12:47:28Z")

</div>

for my startup amazon is suitable, it is free for 12 month. How can I fix my problem?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 29, 2019, 12:59pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/6 "2019-06-29T12:59:16Z")

</div>

> [@Ilyoskhuja](#):
>
> How can I fix my problem?

Let's wait for @Ignacio_Vera to answer. 🙂

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [June 30, 2019, 7:28am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/7 "2019-06-30T07:28:49Z")

</div>

The plot shows us the issue but it does not help trying to debug / understand what is going oon. We would need the actual values of the bounding box (TopLeft and BottomRight points) and the value of one of the points ( Lat and Lon).

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [June 30, 2019, 1:03pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/8 "2019-06-30T13:03:26Z")

</div>

BottomRight: x1=41.22388330186993 x2:69.13315496215819  
TopLeft : y1:41.375029128357596 y2:69.34704503784178

Point inside bouding box:

```
* "location": {
  * "lat": 41.3096311599291,
  * "lon": 69.24346804618834},
```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 30, 2019, 4:09pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/9 "2019-06-30T16:09:01Z")

</div>

It looks to me like your BottomRight is actually a BottomLeft as x1 \< y1. This also makes your TopLeft a TopRight. If you correct these I suspect you will see a different result.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [June 30, 2019, 5:11pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/10 "2019-06-30T17:11:40Z")

</div>

I changed TopLeft and BottomRight value from

```
                    .GeoBoundingBox(g => g
                    .Boost(1.1)
                    .Name("Location")
                    .Field(p => p.Location)
                    .BoundingBox(c => c
                    .TopLeft(model.Points.Y1, model.Points.Y2)
                    .BottomRight(model.Points.X1, model.Points.X2)  
                     )
                    )

```

to

```
                 .GeoBoundingBox(g => g
                    .Boost(1.1)
                    .Name("Location")
                    .Field(p => p.Location)
                    .BoundingBox(c => c
                    .TopLeft(model.Points.X1, model.Points.X2)
                    .BottomRight(model.Points.Y1, model.Points.Y2)  
                     )
                    )

```

But I got error

> "Invalid NEST response built from a unsuccessful low level call on POST: /honadonz/elasticsearchmodel/\_search?typed\_keys=true\n# Audit trail of this API call:\n - [1] BadResponse: Node: [https://search-honadon-aws-s2kjvr4n5ncradyspmbopyjw2e.us-east-2.es.amazonaws.com/](https://search-honadon-aws-s2kjvr4n5ncradyspmbopyjw2e.us-east-2.es.amazonaws.com/) Took: 00:00:00.2333030\n# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /honadonz/elasticsearchmodel/\_search?typed\_keys=true. ServerError: Type: illegal\_argument\_exception Reason: "top is below bottom corner: 41.239679247732255 vs. 41.36792753714556"\n# Request:\r\n{"from":0,"query":{"bool":{"filter":[{"geo\_bounding\_box":{"boost":1.1,"\_name":"Location","location":{"bottom\_right":{"lat":41.367927537145562,"lon":69.350024455166078},"top\_left":{"lat":41.239679247732255,"lon":69.141140046615661}}}}]}},"size":100}\n# Response:\r\n{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"top is below bottom corner: 41.239679247732255 vs. 41.36792753714556"}],"type":"illegal\_argument\_exception","reason":"top is below bottom corner: 41.239679247732255 vs. 41.36792753714556"},"status":400}\n"

You Right, I get value from openlayers BottomLeft, TopRight,  
What you suggest , how can I fix problem?

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [June 30, 2019, 6:54pm UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/11 "2019-06-30T18:54:20Z")

</div>

I think the right answer is as following:

```auto
.GeoBoundingBox(g => g
                    .Boost(1.1)
                    .Name("Location")
                    .Field(p => p.Location)
                    .BoundingBox(c => c
                    .TopLeft(model.Points.y1, model.Points.X2) 
                    .BottomRight(model.Points.X1, model.Points.Y2) 
                     )
                    )

```

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 1, 2019, 6:09am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/12 "2019-07-01T06:09:28Z")

</div>

thank you, now it's working correctly.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 20, 2019, 8:16am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/13 "2019-07-20T08:16:33Z")

</div>

BTW, Now I have bad Experience with aws, I don't recommend to anybody to use aws elasticsearch it cost more money even with this ads,

 ![21](https://us1.discourse-cdn.com/elastic/original/3X/8/8/88041f95d253c645da0db2bacb15098c405e0bd1.png)

I dont know about how much total cost elastic cloud service per month , i used calculator, but i didn't understood total price per month.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 20, 2019, 8:59am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/14 "2019-07-20T08:59:27Z")

</div>

Regardless of the service you use the cost will typically depend on what size cluster you need and in which region you want to deploy. Without any information about this it is hard for anyone to help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 20, 2019, 9:04am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/15 "2019-07-20T09:04:46Z")

</div>

I think that the price calculator gives you a price per hour, right?

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 20, 2019, 9:07am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/16 "2019-07-20T09:07:03Z")

</div>

YES, it gives a price per hour.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 20, 2019, 9:08am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/17 "2019-07-20T09:08:23Z")

</div>

Then take that times 24 times 365 and you have the cost per year. The cost per month will depend on the number of days in the month.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 20, 2019, 9:12am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/18 "2019-07-20T09:12:04Z")

</div>

If i have limit , and my elastic uses more than limit, cloud get extra money for it or cloud blocks requests more than limit

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 20, 2019, 9:13am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/19 "2019-07-20T09:13:56Z")

</div>

You are paying for the size of the cluster, not number of documents or requests. There are typically some additional costs related to traffic in and out of the cluster and snapshots (depends on your usage), but I would expect that to be small compared to the base cost. Naturally there is a limit to the amount of traffic and data a cluster of a specific size can handle.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 20, 2019, 9:17am UTC](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130/20 "2019-07-20T09:17:07Z")

</div>

AWS get money for extra requests, and I got letter in end of month that i should pay extra money for that. I have question about [https://cloud.elastic.co/](https://cloud.elastic.co/), it works like AWS?

[Next page](https://discuss.elastic.co/t/elasticsearch-shows-points-outside-boundingbox-nest/188130.md?page=2)
