If you have location data about your products and customers then you can use the GEO_INSIDE() function to filter or boost products that are closer to the customer.

For example if you send your customers location with your search query like the example below:

{
  "q": "shoes",
  "customer_latitude" : "-4.768047",
  "customer_longitude" : "21.173796"
}
CODE

Then you could add an add-filter step like the one below to your query pipeline:

- id: add-filter
  params:
    filter:
      constant: GEO_INSIDE(product_latitude,product_longitude,customer_latitude,customer_longitude,4)
  condition: customer_latitude AND customer_longitude
CODE

The search results will only contain records/products which product_latitude and product_longitude data is within a radius of 4.

A alternative approach to achieve the same result is to simply construct a filter on every query containing the customers location data. This removes the need for an add-filter pipeline step

{
  "q": "",
  "filter": "GEO_INSIDE(product_latitude,product_longitude,-4.768047,100,21.173796,4)",
  "fields": ""
}
CODE

Here is a document detailing all of our Filter expressions