es直方图脚本

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
      "must": {
        "function_score": {
          "query": {
            "bool": {
              
            }
          },
          "functions": [
            {
              "script_score": {
                "script": {
                  "inline": "if(doc['saleStatus'].value == 1){ return _score*10.0} else if( doc['saleStatus'].value == 0){return _score*5.0} else {return _score*0.001}"
                }
              }
            }
          ]
        }
      },
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "cityIds": [
                  "1"
                ]
              }
            },
            {
              "term": {
                "status": 1
              }
            },
            {
              "has_child": {
                "query": {
                  "bool": {
                    "must": [
                      {
                        "bool": {
                          "should": {
                            "bool": {
                              
                            }
                          }
                        }
                      },
                      {
                        "range": {
                          "buildArea": {
                            "from": 20,
                            "to": 300,
                            "include_lower": true,
                            "include_upper": true
                          }
                        }
                      },
                      {
                        "term": {
                          "status": 1
                        }
                      }
                    ]
                  }
                },
                "child_type": "eco_projecttype"
              }
            }
          ]
        }
      }
    }
  },
  "fields": [
    "pid",
    "projName",
    "relatedPhotos",
    "marketingSource",
    "marketingInfo",
    "marketingTime",
    "uid",
    "developerIds",
    "projNameAliasSource",
    "provinceId",
    "originCityId",
    "cityIds",
    "grade",
    "cityPrefixes",
    "citySuffixes",
    "districtIds",
    "districtNames",
    "isLive",
    "liveTotal",
    "circleIds",
    "circleDesc",
    "projAddress",
    "projPhotoPath",
    "projPhotoType",
    "constructTypes",
    "constructTypesDesc",
    "propertyTypeIds",
    "propertyTypeDesc",
    "projDecorationIds",
    "saleStatus",
    "status",
    "projFeatureIds",
    "projFeatureDesc",
    "loopLineId",
    "subwayIds",
    "subwayLineStations",
    "lon",
    "lat",
    "developerName",
    "priceType",
    "priceTime",
    "lowPrice",
    "avgPrice",
    "highPrice",
    "showPrice",
    "showAllPrice",
    "priceDesc",
    "openingYear",
    "openingMonth",
    "openingDay",
    "openingIsPredict",
    "openStartTime",
    "openEndTime",
    "moveinStartTime",
    "moveinEndTime",
    "propertyYear",
    "phoneCalled",
    "totalPVCount",
    "cityVDistricts",
    "updateTime",
    "totalClickCount",
    "originCityCircles",
    "agentAvatar",
    "agentUserName",
    "agentUid",
    "agentLevelStr",
    "displayVdistrict",
    "custodianScore",
    "expirationTime",
    "redPackets",
    "startTime",
    "isSaleCooperation",
    "firstHouseTitle",
    "houseCount"
  ],
  "sort": [
    {
      "grade": {
        "order": "asc",
        "missing": "_last"
      }
    },
    {
      "custodianScore": {
        "order": "desc",
        "missing": "_last"
      }
    },
    {
      "phoneCalled": {
        "order": "desc",
        "missing": "_last"
      }
    },
    {
      "pid": {
        "order": "desc"
      }
    }
  ],
  "aggs": {
    "prices": {
      "histogram": {
        "field": "showPrice",
        "interval": 20
      }
    },
    "prices2": {
      "histogram": {
        "field": "showPrice",
        "interval": 20,
        "min_doc_count": 1
      }
    }
  }
}

你可能感兴趣的:(es直方图脚本)