0

I am indexing product documents as shown in the snippet below and I want to sort the products according to the shops which are stored as child documents of the product.

{
  id: "101",
  title: "product title",
  nodeType: "product",
  ...
  _childDocuments_: [
    {
      id: "12432",
      name: "shop-name",
      quantity: 12,
      location: "42.1218,16.5432",
      nodeType: "shop"
    },
    {
      id: "14811",
      name: "shop-name-2",
      quantity: 0,
      location: "46.2995,14.9546",
      nodeType: "shop"
    },
    ...
  ]
}

indexing and filtering works fine but when I try to sort the results by distance of the children documents with the following sort-query it just does not work at all.

{!parent which="nodeType:product" v='nodeType:shop dist(2,latitude,longitude,48.185378,16.400646)'}asc

another sort-query I've tried:

{!parent which="nodeType:product"}{!geofilt sfield=location}&pt=48.1984032,16.3821551&d=5

this last one will always return infinity for geodist() and not give me the expected sorting.

I am really stuck with this. Any help or hint is appreciated.

kbax
  • 63
  • 1
  • 8

1 Answers1

0

I think the problem is how to sort based on lat,lan points with respect to shop. If that is the case I see there is something specific for this problem: latitude/longitude find nearest latitude/longitude - complex sql or complex calculation

Nitish Singla
  • 165
  • 1
  • 6