Skip to content

Instantly share code, notes, and snippets.

@wrfly
Last active April 12, 2019 06:39
Show Gist options
  • Save wrfly/a9d98097488805eae1eac294ee021807 to your computer and use it in GitHub Desktop.
Save wrfly/a9d98097488805eae1eac294ee021807 to your computer and use it in GitHub Desktop.

AGG

返回某一字段的所有值

{
    "aggs": {
      "item_id": {
        "terms": {
          "field": "itemid",
          "size": 10
        }
      }
    },
    "_source": false,
    "size": 0
}

返回某一字段的统计值

{
    "aggs": {
      "item_id": {
        "sum": {
          "field": "attr_price"
        }
      }
    },
    "_source": false,
    "size": 0
}
{
  "aggs": {
    "item_id": {
      "sum": {
        "field": "attr_price"
      }
    }
  },
  "_source": false,
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "item_id": "1111"
          }
        }
      ]
    }
  }
}
{
  "aggs": {
    "price total": {
      "sum": {
        "field": "attr_price"
      }
    }
  },
  "_source": false,
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "item_id": {
              "value": "1682296"
            }
          }
        },
        {
          "term": {
            "visible": {
              "value": 1
            }
          }
        }
      ]
    }
  }
}
@wrfly
Copy link
Author

wrfly commented Apr 12, 2019

join \
    <(curl 10.65.235.26:9200/_cat/indices -s | grep -v ' \.' | awk '{print $3 "\t" $6}' | sort | tr "[dwn]1" "[dwn]0") \
    <(curl 10.65.238.208:9206/_cat/indices -s | grep -v ' \.' | awk '{print $3 "\t" $7}' | sort)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment