query and sort - actly/ElasticSearch-SearchSamples GitHub Wiki

{
  "sort": [
    {
      "created_at": {
        "order": "asc"
      }
    }
  ],
  "aggs": {
    "group_by_cat_id": {
      "terms": {
        "field": "cat_id"
      }
    }
  },
  "query": {
    "filtered": {
      "query": {
        "multi_match": {
          "query": "a",
          "type": "best_fields",
          "fields": [
            "title^10",
            "brand_name"
          ],
          "tie_breaker": 0.3,
          "minimum_should_match": "75%"
        }
      },
      "filter": {
        "and": [
          {
            "range": {
              "price": {
                "to": 10
              }
            }
          },
          {
            "geo_distance": {
              "distance": "10mi",
              "location": {
                "lat": "32.837308",
                "lon": "-96.776397"
              }
            }
          },
          {
            "term": {
              "is_robot": 0
            }
          }
        ]
      }
    }
  },
  "explain": "true",
  "from": 0,
  "size": 20
}