Help to Combine Queries

Hello,

Here is my Schema,

{
	"cmslocal": {
		"mappings": {
			"video": {
				"properties": {
					"assetProps": {
						"properties": {
							"assetType": {
								"type": "string"
							},
							"configPath": {
								"type": "string",
								"fields": {
									"raw": {
										"type": "string",
										"index": "not_analyzed"
									}
								},
								"analyzer": "standard"
							},
							"contentSha1": {
								"type": "string"
							},
							"originalPath": {
								"type": "string",
								"fields": {
									"raw": {
										"type": "string",
										"index": "not_analyzed"
									}
								},
								"analyzer": "standard"
							},
							"path": {
								"type": "string",
								"fields": {
									"raw": {
										"type": "string",
										"index": "not_analyzed"
									}
								},
								"analyzer": "standard"
							},
							"thumbnailPath": {
								"type": "string",
								"fields": {
									"raw": {
										"type": "string",
										"index": "not_analyzed"
									}
								},
								"analyzer": "standard"
							}
						}
					},
					"channel": {
						"type": "string"
					},
					"configProps": {
						"properties": {
							"events": {
								"type": "nested",
								"include_in_root": true,
								"properties": {
									"Desc": {
										"type": "string"
									},
									"Tags": {
										"type": "string"
									},
									"UUID": {
										"type": "string"
									}
								}
							},
							"roiUUID": {
								"type": "string"
							}
						}
					},
					"contentSha1": {
						"type": "string"
					},
					"eventDesc": {
						"type": "string"
					},
					"ext": {
						"type": "string"
					},
					"format": {
						"type": "string"
					},
					"fovProps": {
						"properties": {
							"description": {
								"type": "string"
							},
							"width": {
								"type": "float"
							}
						}
					},
					"locationProps": {
						"type": "nested",
						"properties": {
							"address": {
								"type": "string"
							},
							"city": {
								"type": "string"
							},
							"country": {
								"type": "string"
							},
							"county": {
								"type": "string"
							},
							"location": {
								"type": "geo_point"
							},
							"postcode": {
								"type": "string"
							},
							"state": {
								"type": "string"
							}
						}
					},
					"nodeid": {
						"type": "string"
					},
					"poleHeight": {
						"type": "float"
					},
					"query": {
						"properties": {
							"bool": {
								"properties": {
									"filter": {
										"properties": {
											"term": {
												"properties": {
													"nodeid": {
														"type": "string"
													}
												}
											}
										}
									}
								}
							}
						}
					},
					"retentionPolicy": {
						"type": "string"
					},
					"siteScopeID": {
						"type": "string"
					},
					"tagProps": {
						"type": "nested",
						"properties": {
							"conditions": {
								"type": "string"
							},
							"environment": {
								"type": "string"
							},
							"events": {
								"type": "string"
							},
							"lighting": {
								"type": "string"
							},
							"objects": {
								"type": "string"
							},
							"other": {
								"type": "string"
							},
							"scenes": {
								"type": "string"
							},
							"useCases": {
								"type": "string"
							},
							"weather": {
								"type": "string"
							}
						}
					},
					"test": {
						"type": "string"
					},
					"title": {
						"type": "string"
					},
					"uploadTime": {
						"type": "date",
						"format": "strict_date_optional_time||epoch_millis"
					},
					"videoProps": {
						"properties": {
							"bitrate": {
								"type": "float"
							},
							"datetime": {
								"type": "date",
								"format": "date_hour_minute_second_millis"
							},
							"daySegments": {
								"type": "string"
							},
							"duration": {
								"type": "long"
							},
							"framerate": {
								"type": "float"
							},
							"height": {
								"type": "integer"
							},
							"overlaysOn": {
								"type": "boolean"
							},
							"width": {
								"type": "integer"
							}
						}
					}
				}
			}
		}
	}
}

Please help to build the query so I can search for

  1. Only nodeId, Only Channel, Date Range
  2. Any of the Tags

I'm able to search for nodeId, Channel Id using

{
    "query": {
        "bool": {
            "filter": [
                { "match": { "nodeid": "N02cff15a" } },
                { "match": { "channel": "1" } }
            ]
        }
    }
}

and I can able to Search for tagProps using

{
    "nested": {
        "path": "tagProps",
        "query": {
            "bool": {
                "must": [
                    { "match": { "tagProps.objects": "car" } },
                    { "match": { "tagProps.objects": "truck" } }
                ]
            }
        }
    }
}

Help me combine two queries so I can search for NodeId with Combination of Tags.

you need to use the bool query to combine things like this

"bool" : {
  "must": { "nested" : ... },
  "filter" : [  { "match": ... }, { "match": ... } ]
}

hope this makes sense

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.