I have a problem that requires finding the value corresponding to the label. I have a query with the following script:
GET hawkcam_object_v3_test/_search
{
"query": {
"bool": {
"filter": [
{
"script": {
"script": {
"source": """
def attrs = doc['attributes.jewelry_v2.keyword'];
def confs = doc['attributes.jewelry_v2_conf'];
if (attrs == null || confs == null || attrs.size() == 0 || confs.size() == 0 || attrs.size() != confs.size()) {
return false;
}
for (int i = 0; i < attrs.size(); i++) {
def attr = attrs[i];
def conf = confs[i];
def required_conf = params.rules.get(attr);
if (required_conf != null && conf >= required_conf) {
return true;
}
}
return false;
""",
"params": {
"rules": {
"sunglasses": 0.99
}
}
}
}
},
{
"match_phrase": {
"id_video": {
"query": "68aedcb3e3709137c0fda89f"
}
}
}
]
}
}
}
Results search:
{
"_index": "hawkcam_object_v3_test",
"_id": "68aedcb3e3709137c0fda89f_1_3_344",
"_score": 0,
"_routing": "68aedcb3e3709137c0fda89f_344",
"_source": {
"id_video": "68aedcb3e3709137c0fda89f",
"local_object_url": "/data/hawkice/image/68aedcb3e3709137c0fda89f/344.jpg",
"created_time": 1756252813761,
"path_object_local": "/data/hawkice/image/68aedcb3e3709137c0fda89f/344.jpg",
"path_object_url": "http://localhost:13579/api/hawkice/get_image/68aedcb3e3709137c0fda89f/344.jpg?bounding_box=1217.170.1435.591",
"location_obj": {
"lon": 41,
"lat": 21
},
"image_url": "http://localhost:13579/api/hawkice/get_image/68aedcb3e3709137c0fda89f/344.jpg?bounding_box=1217.170.1435.591",
"id_tracking": "68aedcb3e3709137c0fda89f_1_3",
"box": {
"x_center": 1326,
"top": 0.15793177286783855,
"left": 0.634092140197754,
"frame_h": 1080,
"width": 218,
"y_center": 381,
"frame_w": 1920,
"y-left": 170,
"x-left": 1217,
"height": 421
},
"source_type": "video",
"relation_type": {
"parent": "68aedcb3e3709137c0fda89f_344",
"name": "person"
},
"id_frame": "68aedcb3e3709137c0fda89f_344",
"score": 0.956775426864624,
"cluster_id": "6699ec0f9e0ceada2cafa633",
"id_object": "68aedcb3e3709137c0fda89f_1_3_344",
"meta": {
"source_frame_width": 1920,
"ntp_timestamp": 1756883316718506000,
"camera_id": "68aedcb3e3709137c0fda89f",
"pre_timestamp": 13761000000,
"source_id": 0,
"object_id": 3,
"frame_id": 344,
"source_frame_height": 1080
},
"obj_path": "http://localhost:13579/api/hawkice/get_image/68aedcb3e3709137c0fda89f/344.jpg?bounding_box=1217.170.1435.591",
"attributes": {
"lowerbodycolor_v2": [
"grey"
],
"lowerbodycolor_v2_v3": [
"grey"
],
"lowerbodycolor_conf": 0.6743054866790771,
"lowerbodycolor_v2_conf": [
0.6743054866790771
],
"hairstyle_conf": 1,
"upperbodycolor_conf": 0.6987885236740112,
"carrying_v2": [
"backpack"
],
"upperbody": "casual",
"hairstyle_v2_v3": [
"short"
],
"sex_v2_conf": [
0.6999989151954651
],
"direction_in_v3": [
"East"
],
"direction_out_v3": [
"North-East"
],
"upperbodycolor_v2": [
"black"
],
"footwearcolor_v2_v3": [
"white",
"black"
],
"jewelry": "nothing",
"upperbodycolor_v2_v3": [
"black"
],
"jewelry_v2_v3": [
"nothing",
"sunglasses"
],
"upperbodycolor": [
"black"
],
"jewelry_v2": [
"nothing",
"sunglasses"
],
"upperbodycolor_v2_conf": [
0.6987885236740112,
0.5612784087657928,
0.6157483220100403
],
"haircolor_v2_v3": [
"black"
],
"carrying_conf": 1,
"haircolor_conf": 1,
"jewelry_conf": 0.9999997615814209,
"direction_in": "East",
"hairstyle_v2": [
"short"
],
"hairstyle": "short",
"upperbody_v2_v3": [
"casual",
"long_sleeve"
],
"hairstyle_v2_conf": [
1
],
"sex_v2_v3": [
"male"
],
"lowerbody_v2_conf": [
0.9996740818023682,
1
],
"shoe_v2_v3": [
"sneakers"
],
"upperbody_v2": [
"casual",
"long_sleeve"
],
"carrying": "backpack",
"upperbody_conf": 1,
"carrying_v2_conf": [
1
],
"haircolor_v2": [
"black"
],
"lowerbody_conf": 0.9996740818023682,
"lowerbody_v2_v3": [
"trousers",
"casual"
],
"age_conf": 0.9999995231628418,
"lowerbody_v2": [
"casual",
"trousers"
],
"age_v2_conf": [
0.9999995231628418
],
"jewelry_v2_conf": [
0.9999997615814209,
0.83
],
"age_v2": [
"unknown"
],
"direction_out": "North-East",
"upperbody_v2_conf": [
1,
1
],
"lowerbodycolor": [
"grey"
],
"age_v2_v3": [
"unknown"
],
"sex_v2": [
"male"
],
"carrying_v2_v3": [
"backpack",
"luggage_case"
],
"lowerbody": "casual",
"haircolor_v2_conf": [
1
],
"haircolor": "black",
"age": "unknown"
},
"class": "person",
"frame_url": "http://localhost:13579/api/hawkice/get_image/68aedcb3e3709137c0fda89f/344.jpg"
}
}
The returned result has a document containing the attribute sunglasses in jewelry_v2 but its threshold is 0.83 ??? I don't understand what's wrong. I hope everyone can review it and give me advice.
Information Elastic
Mapping: