Question: How to write query elastic search?

I have a index review like this

{
        "_index": "zody_review",
        "_type": "review",
        "_id": "5b3c6c9e68cf860e1af5f7fd",
        "_score": null,
        "_source": {
          "user": "571899623dc63af34d67a662",
          "merchant": "56f8f80119a4c1ae791cf7bf",
          "point": 3,
          "score": 2,
          "createdAt": "2018-07-04T13:43:42.331+07:00",
          "location": {
            "lat": 16.07054040054832,
            "lon": 108.22062939405441
          },
          "feedback": "Phuc vu khong tot lam "
        }
      },

How can I query to get list review nearby, but limit get 5 reviews for each group by field merchant ?
I've been stuck here too long!
Thank you!

What's your elasticsearch version?

What is the mapping for the document you mention?

I'm using version 6.2
And this mapping

"mappings": {
    "review": {
      "properties": {
        "merchant": {
          "type": "keyword"
        },
        "user": {
          "type": "keyword"
        },
        "point": {
          "type": "integer"
        },
        "createdAt": {
          "type": "date"
        },
        "score": {
          "type": "float"
        },
        "location": {
          "type": "geo_point"
        },
        "feedback": {
          "type": "text",
          "fields": {
            "search": {
              "type": "text",
              "analyzer": "edge_ngram"
            }
          }
        }
      }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.