0

I am trying to search two points in same query like below. but results returning empty.

"query": {
            "bool": {
                "must": {
                    "match_all": {}
                },
                "filter": [{
                    "geo_shape": {
                        "border": {
                            "shape": {
                                "type": "point",
                                "coordinates": [longitude1, latitude1]
                            },
                            "relation": "intersects"
                        }
                    }
                }, {
                    "geo_shape": {
                        "border": {
                            "shape": {
                                "type": "point",
                                "coordinates": [longitude2, latitude2]
                            },
                            "relation": "intersects"
                        }
                    }
                }
                ]
            }

        }

the query working for only one point at a time.

How can I search two points at a time ?

Karesh A
  • 1,731
  • 3
  • 22
  • 47
  • I have also tried two bool queries inside the query block. That also empty – Karesh A Sep 20 '17 at 12:01
  • Do both points need to match or only one of them? – Val Sep 20 '17 at 12:06
  • results should be OR. if one point on one polygon and another one is in another polygon , query should return both polygon ids. if it is in the same polygon query can return two results with same id or one. – Karesh A Sep 20 '17 at 12:10

1 Answers1

1

If you need OR behavior, yo uneed to use bool/should instead:

"query": {
        "bool": {
            "should": [{                <--- change this
                "geo_shape": {
                    "border": {
                        "shape": {
                            "type": "point",
                            "coordinates": [longitude1, latitude1]
                        },
                        "relation": "intersects"
                    }
                }
            }, {
                "geo_shape": {
                    "border": {
                        "shape": {
                            "type": "point",
                            "coordinates": [longitude2, latitude2]
                        },
                        "relation": "intersects"
                    }
                }
            }
            ]
        }

    }
Val
  • 207,596
  • 13
  • 358
  • 360