【发布时间】:2015-01-04 04:52:06
【问题描述】:
我有一个这样的文档模型:
"customer": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"orders": {
"type": "nested",
"properties": {
"id": { "type": "integer" },
"orderDate" : { "type": "date", "format" : "YYYY-MM-dd" },
"orderLines": {
"type": "nested",
"properties": {
"seqno": { "type": "integer" },
"quantity": { "type": "integer" },
"articleId": { "type": "integer" }
}
}
}
}
}
}
一个客户可以有 0、1 或多个订单,一个订单可以有 0、1 或多个 orderLines
(这是我为这个问题创建的模型,因为我认为这是每个人都能理解的数据,所以如果您发现任何错误,请告诉我,但不要让他们分散您对我实际问题的注意力)
我想使用 NEST 创建一个查询,该查询选择一个(或所有)具有特定 customer.id 值的客户,但前提是他们至少有一个具有特定 articleId 的 orderLine。
我查看了Need concrete documentation / examples of building complex index using NEST ElasticSearch library 和Matching a complete complex nested collection item instead of separate members with Elastic Search,但无法创建查询。基于第二个问题,我到了我写的地方
var results = client.Search<customer>(s => s
.From(0)
.Size(10)
.Types(typeof(customer))
.Query(q =>
q.Term(c => c.id, 12345)
&& q.Nested(n => n
.Path(c => c.order)
.Query(q2 => q2.Nested(n2 => n2
.Path(o => o.???))))
)
);
我希望第二个路径使用订单(订单是列表)作为泛型类型,但它是客户。
正确查询的代码是什么?
另外:NEST 的搜索/查询/过滤方法的文档是否比http://nest.azurewebsites.net/ 上的文档更详细?在第一个引用的问题中,复杂查询教程(有问题)和单元测试示例(已接受的答案)的链接都不起作用(分别为超时和 404)。
【问题讨论】:
标签: elasticsearch nest