Elasticsearch父/子,FacetDateHistogram使用子数据

时间:2013-10-17 16:08:47

标签: elasticsearch facets nest

我在父/子关系中运行此NEST客户端查询,我需要运行FacetDateHistograms / FacetTerms,使用父数据或使用子父:

这适用于使用父数据的方面

sourceClient.Search<type_properties>(body => body.Query(q => q.Bool(b =>b.Must(q.Term("zip","90064"),q.HasChild<type_sales(x=>x.Query(asofF=>asofF.Range(rangeFrom=>rangeFrom.OnField("salesDate").From("2009-01-01T00:00:00"))))))).FacetTerm("Global Count", gc=> gc.OnField("state").Global().Size(60)) .FacetTerm("Zip Count", zc=>zc.OnField("zip")))

但如果添加此FacetDateHistogram,其中“salesDate”和“salesPrice”是子字段,

.FacetDateHistogram("ZipSales",h=>h.OnField("salesDate").ValueField("salesPrice").Interval(DateInte
                                                rval.Year))

返回

嵌套:FacetPhaseExecutionException [Facet [Zip Sales] :( key)字段[salesDate] not found]; } {[sdsdssd] [test] [4]:RemoteTransportException [[test-lin04] [inet [/xx.xx.xx.xx:xxxx]] [search / phase / query]];嵌套:SearchParseException [[usncd] [4]:from [-1],size [-1]:Parse Failure [无法解析源代码[{

"facets": {
    "Zip Sales": {
      "date_histogram": {
        "field": "salesDate",
        "value_field": "salesPrice",
        "interval": "year"
      }
    },
    "Global Count": {
      "global": true,
      "terms": {
        "field": "state",
        "size": 60
      }
    },
    "Zip Count": {
      "terms": {
        "field": "zip"
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "zip": {
              "value": "90064"
            }
          }
        },
        {
          "has_child": {
            "type": "type_sales",
            "query": {
              "range": {
                "salesDate": {
                  "from": "2009-01-01T00:00:00"
                }
              }
            }
          }
        }
      ]
    }
  }
}]]]

请帮忙吗?

0 个答案:

没有答案