I can't edit my original post for some reason..

Above it doesn't show the "distance" field in the results, it is there, i 
just made an error pasting (trimmed the product ids field)

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": null,
    "hits": [
      {
        "_index": "test",
        "_type": "places",
        "_id": "AUtvK2OILrMWSKLclj9Z",
        "_score": null,
        "_source": {
          "id": "1",
          "name": "Chubby Company",
          "summary": "",
          "content": "",
          "locations": [
            {
              "lat": 51.8200763,
              "lon": 0.5264076
            }
          ],
          "address": [
            {
              "addr1": "xxxx",
              "addr2": "",
              "town": "MyTown",
              "county": "Essex",
              "postcode": "XX1 2XX",
              "tel1": "01111 111111",
              "tel2": "",
              "email": null
            }
          ],
          "website": "",
          "media": {
            "logo": "",
            "image": "",
            "video": ""
          },
          "product_ids": [
            "1",
            "3",
            "2"
          ],
          "distance": "20"
        },
        "sort": [
          0.031774582056958885
        ]
      }
    ]
  }
}


I've also tried 

{
  "filter": {
    "geo_distance": {
      "distance": "30mi",
      "companies.locations": {
        "lat": "51.8801595",
        "lon": "0.577141"
      }
    },
    "script": {
      "script": "_source.distance < sort.value"
    }
  },
  "sort": {
    "_geo_distance": {
      "companies.locations": {
        "lat": "51.8801595",
        "lon": "0.577141"
      },
      "order": "asc",
      "unit": "mi",
      "mode": "min"
    }
  },
  "from": 0,
  "size": 500
}


But i can't seem to successfully reference the distance and sort results

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3e85e7ef-d6ff-4b0d-80b4-c9c393eabc8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to