zipkin链路数据通过elasticsearch查询一

zipkin索引创建格式如下

{
    "version":17,
    "mapping_version":13,
    "settings_version":1,
    "aliases_version":1,
    "routing_num_shards":1024,
    "state":"open",
    "settings":{
        "index":{
            "routing":{
                "allocation":{
                    "include":{
                        "_tier_preference":"data_content"
                    }
                }
            },
            "number_of_shards":"1",
            "provided_name":"zipkin-span-2023-02-02",
            "creation_date":"1675296000270",
            "number_of_replicas":"1",
            "uuid":"ySAa5RIsTiSEHBN8pZv_IA",
            "version":{
                "created":"7160199"
            }
        }
    },
    "mappings":{
        "_doc":{
            "properties":{
                "traceId":{
                    "fielddata":true,
                    "type":"text",
                    "fields":{
                        "keyword":{
                            "ignore_above":256,
                            "type":"keyword"
                        }
                    }
                },
                "shared":{
                    "type":"boolean"
                },
                "timestamp_millis":{
                    "type":"long"
                },
                "kind":{
                    "type":"text",
                    "fields":{
                        "keyword":{
                            "ignore_above":256,
                            "type":"keyword"
                        }
                    }
                },
                "tags":{
                    "properties":{
                        "gisq_request_id":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        },
                        "method":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        }
                     
                },
                "duration":{
                    "type":"long"
                },
                "remoteEndpoint":{
                    "properties":{
                        "ipv4":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        },
                        "port":{
                            "type":"long"
                        },
                        "ipv6":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        },
                        "serviceName":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        }
                    }
                },
                  
                "id":{
                    "type":"text",
                    "fields":{
                        "keyword":{
                            "ignore_above":256,
                            "type":"keyword"
                        }
                    }
                },
   
                "timestamp":{
                    "type":"long"
                }
            }
        }
    }
   
}

term和match的区别: term代表完全匹配,搜索前不会再对搜索词进行分词

这里主要是想查询tags下的gisq_request_id这种嵌套类型怎么查询

              "tags":{
                    "properties":{
                        "gisq_request_id":{
                            "type":"text",
                            "fields":{
                                "keyword":{
                                    "ignore_above":256,
                                    "type":"keyword"
                                }
                            }
                        },

 模板可以知道gisq_request_id有两种类型可以查看模糊匹配和精确匹配查询

模糊匹配查询

 方式一

 方式二

完全匹配查询

猜你喜欢

转载自blog.csdn.net/qq_38423256/article/details/128903253