Expand search if results are less than a Limit

Hi, I would look inside a bounding box and I read how to do it. But I would like to expand this search to a certain range if the hits are less than N.

So: look inside the bounding box of NY, if results are less than 10 look for objects in a range of 100Kms

Is it possible?

I don't think it's possible inside of one DSL call. You can handle this logic on the client side via two DSL queries.

I would use
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
to combine a query for the small bounding box (with big score boost) and a
query for the bigger bounding box (with lower score boost).

Then Elasticsearch will boost the entries which are in the smaller bounding
box x-times higher then the ones in the bigger bounding box. So you end up
having the elements in the small bounding box as first results and the
other elements will appear afterwards in the result list.