【发布时间】:2019-03-12 06:04:46
【问题描述】:
我正在尝试构建一个 NEST 搜索,在每个嵌套级别上查询所有字段(包括整数和字符串)以找到匹配项。
此外,能够传入某个 masterProductID,仅从中搜索 masterProduct 下的产品会很棒,但这不是必需的。
我不知道如何复合三个或四个级别的查询,例如,每当我传入“1”时,Elastic 永远不会返回找到整数 1 的任何地方。这两个都需要实现,并且 Elastic 的文档嵌套没有太多用处的例子。
下面是我正在处理的那种层次结构的非常简洁的轮廓。 (比这更糟糕,这是交给我搜索的索引)。
有什么简单的方法可以做到这一点吗?
提前致谢。
"masterProductId":2
"manufacturerId" : 1
"productAttributes": [
{
"masterProductId": 2,
"attributeTypeName": "Storage",
"attributeTypeId": 2,
"attributeName": "16GB",
"attributeId": 4,
"productId": 1124,
"attributeSortOrder": 2,
"attributeTypeSortOrder": 1,
"attributeNameUrl": "16gb"
},
{
"masterProductId": 2,
"attributeTypeName": "Condition",
"attributeTypeId": 5,
"attributeName": "Refurbished Good",
"value": "Excellent condition with very minor, isolated wear and tear",
"attributeId": 30,
"productId": 1124,
"attributeSortOrder": 3,
"attributeTypeSortOrder": 4,
"attributeNameUrl": "refurbished-good"
}
"products": [
{
"masterProductId": 2,
"productId": 37,
"basePrice": 110,
"websitePriceIncTax": 110,
"productImages": [
{
"productImageId": 0,
"masterProductId": 2,
"productId": 37,
"name": "Apple iPhone 4s White",
"productImageTypeId": 2,
"productImageTypeName": "Front",
"imageExtension": "jpg",
"fileName": "front-appleiphone4swhite.jpg",
"fileNameThumb": "front-appleiphone4swhite-thumb.jpg",
"isDefault": true
}
【问题讨论】:
-
您能否包含相关索引的映射?提供的示例看起来有点奇怪,例如是
"products"属性在"productAttributes"数组中,还是应该在"products"之前有一个右数组括号? -
@RussCam 在我之前在这个系统上工作的人决定使用自动映射从一个巨大的对象中嵌套较小的对象(我知道,对..)在 Kibana 中一个完整的示例映射将超过 16,800 行,这并不容易看透。我猜没有“到处搜索”功能?
-
在 6.x 之前的版本中有一个
_all字段,可用于搜索所有文档字段,但在 6.x 中已弃用。您可以在 6.x 中使用copy_to自行设置。如果我没记错的话,_all不包括来自nested数据类型的字段。见elastic.co/guide/en/elasticsearch/reference/current/…
标签: c# elasticsearch nest