我正在使用elasticsearch。我想在查询中使用多个嵌套匹配。
我的查询:
$query = [
"bool"=> [
"must"=> [
[ "match" => ["category_name" => $category]],
[ "match" => ["category.status" => '1']],
[ "match" => ["default_product_low_price_with_seller.seller_detail.approve_status" => '1']],
[ "match" => ["is_published" => '1']],
[ "match" => ["brand.approve_status" => '1']]
]
]
];
但它返回0结果而不是1. 如何在上面的查询中使用不同的嵌套匹配?
MAPPING
{
"product-list":{
"properties":{
"id":{
"type":"integer"
},
"category_id":{
"type":"integer"
},
"type_id":{
"type":"integer"
},
"brancd_id":{
"type":"integer"
},
"has_variant":{
"type":"integer"
},
"title":{
"type":"string"
},
"slug":{
"type":"string"
},
"model":{
"type":"string"
},
"aupc":{
"type":"string"
},
"height":{
"type":"string"
},
"width":{
"type":"string"
},
"length":{
"type":"string"
},
"weight":{
"type":"string"
},
"is_published":{
"type":"integer"
},
"created_at":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"updated_at":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"default_product_low_price_with_seller":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"product_id":{
"type":"integer"
},
"product_seller_id":{
"type":"integer"
},
"product_image_id":{
"type":"integer"
},
"sku":{
"type":"string"
},
"price":{
"type":"double"
},
"selling_price":{
"type":"double"
},
"sale_price":{
"type":"double"
},
"sale_start":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"sale_end":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"shipping_cost":{
"type":"double"
},
"include_shipping_cost":{
"type":"double"
},
"qty":{
"type":"double"
},
"min_qty":{
"type":"double"
},
"download_limit":{
"type":"integer"
},
"delivery_in_days":{
"type":"integer"
},
"approval_status":{
"type":"integer"
},
"warranty":{
"type":"string"
},
"display_in_list":{
"type":"string"
},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"status":{
"type":"integer"
},
"discountSale":{
"type":"double"
},
"discountSelling":{
"type":"double"
},
"sku_variants":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"product_id":{
"type":"integer"
},
"product_sku_id":{
"type":"integer"
},
"product_attribute_id":{
"type":"integer"
},
"attribute_id":{
"type":"integer"
},
"attribute_value":{
"type":"string"
},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"attribute":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"name":{
"type":"string"
},
"label":{
"type":"string"
},
"inputtype":{
"type":"string"
},
"default_value":{
"type":"string"
},
"select_validation":{
"type":"string"
},
"required":{
"type":"integer"
},
"is_searchable":{
"type":"integer"
},
"is_variants":{
"type":"integer"
},
"status":{
"type":"integer"
},
"has_variants":{
"type":"integer"
},
"deleted":{
"type":"integer"
},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
},
"attr_value":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"attribute_id":{
"type":"integer"
},
"value":{
"type":"string"
},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"deleted":{
"type":"integer"
}
}
}
}
},
"seller_detail":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"vendor_id":{
"type":"integer"
},
"approve_status":{
"type":"integer"
},
"seller_detail":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"name":{
"type":"string"
}
}
}
}
},
"image":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"image":{
"type":"nested",
"properties":{
"id": {
"type": "integer"
},
"product_images_id": {
"type": "integer"
},
"image": {
"type": "string"
}
}
},
"default_image":{
"type":"nested",
"properties":{
"id": {
"type": "integer"
},
"product_images_id": {
"type": "integer"
},
"image": {
"type": "string"
}
}
}
}
}
}
},
"attribute_details":{
"type":"nested",
"properties":{
"id": {
"type": "integer"
},
"product_id": {
"type": "integer"
},
"attribute_name": {
"type": "string"
}
}
},
"attributes":{
"type":"nested",
"properties":{
"id": {
"type": "integer"
},
"product_id": {
"type": "integer"
},
"attribute_id": {
"type": "string"
},
"attribute_value": {
"type": "string"
},
"attribute":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"name":{
"type":"string"
},
"label":{
"type":"string"
}
}
},
"attr_value":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"value":{
"type":"string"
}
}
}
}
},
"category": {
"type": "nested",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"parent_id": {
"type": "integer"
},
"slug": {
"type": "string"
},
"sort_order": {
"type": "integer"
},
"status": {
"type": "integer"
},
"title": {
"type": "string"
},
"parent_cat":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"parent_id":{
"type":"integer"
},
"title":{
"type":"string"
},
"slug":{
"type":"string"
},
"description":{
"type":"string"
},
"status":{
"type":"integer"
}
}
}
}
},
"category_name":{
"type":"string"
},
"brand_name":{
"type":"string"
},
"brand": {
"type": "nested",
"properties": {
"approved_status": {
"type": "integer"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"image": {
"type": "string"
},
"name": {
"type": "string"
},
"slug": {
"type": "string"
}
}
},
"description": {
"type": "nested",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"product_id": {
"type": "integer"
}
}
},
"product_rating_avg":{
"type":"nested",
"properties":{
"product_id":{
"type":"integer"
},
"rate":{
"type":"integer"
}
}
}
}
}
}
我已经更新了我的答案。上面是我的弹性搜索服务器中的映射代码。
答案 0 :(得分:0)
以下是您可以使用的json版本的查询。
<DataGridTextColumn ElementStyle="{StaticResource Centering}"/>
<Style x:Key="Centering" TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>