• Elasticsearch-语句


    聚合优化参考:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_preventing_combinatorial_explosions.html

    ES笔记(有道云):

    http://note.youdao.com/noteshare?id=2a9e896be3fd997d29a868bd17d1241a&sub=57DBAF694BBB459B89EE19D7FE731FD7

    优化聚合查询:

    https://www.elastic.co/guide/cn/elasticsearch/guide/current/_preventing_combinatorial_explosions.html#_preventing_combinatorial_explosions

    1,ES配置(参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html)

    http://47.96.229.136:9200/_cluster/health?level=indices

    贸易搜索:
    
    {
        "size": 0,
        "query": {
            "bool": {
                "must": [{
                    "match_phrase": {
                        "details": {
                            "query": "books",
                            "slop": 0,
                            "zero_terms_query": "NONE",
                            "boost": 1.0
                        }
                    }
                }],
                "must_not": [{
                    "terms": {
                        "buyer.keyword": ["N/A", "NVL", "", "NULL", "null", "n/a", "nvl"],
                        "boost": 1.0
                    }
                }],
                "adjust_pure_negative": true,
                "boost": 1.0
            }
        },
        "aggregations": {
            "buyer_count": {
                "terms": {
                    "field": "buyer.keyword",
                    "size": 10,
                    "min_doc_count": 1,
                    "shard_min_doc_count": 0,
                    "show_term_doc_count_error": false,
                    "order": [{
                        "max_arrivaldate ": "desc"
                    }, {
                        "_key": "asc"
                    }]
                },
                "aggregations": {
                    "TOP": {
                        "top_hits": {
                            "from": 0,
                            "size": 1,
                            "version": false,
                            "explain": false,
                            "sort": [{
                                "arrivaldate": {
                                    "order": "desc"
                                }
                            }]
                        }
                    },
                    "max_arrivaldate": {
                        "max": {
                            "field": "arrivaldate"
                        }
                    }
                }
            }
        }
    }
    
    记录条数:
    
    {
        "size": 0,
        "query": {
            "bool": {
                "must": [{
                    "term": {
                        "buyer.keyword": {
                            "value": "SAAD TRADING",
                            "boost": 1.0
                        }
                    }
                }, {
                    "match_phrase": {
                        "details": {
                            "query": "lamana",
                            "slop": 0,
                            "zero_terms_query": "NONE",
                            "boost": 1.0
                        }
                    }
                }],
                "adjust_pure_negative": true,
                "boost": 1.0
            }
        }
    }
    
    
    总金额:
    
    {
        "size": 0,
        "query": {
            "bool": {
                "must": [{
                    "term": {
                        "buyer.keyword": {
                            "value": "SILCOM S A",
                            "boost": 1.0
                        }
                    }
                }, {
                    "range": {
                        "arrivaldate": {
                            "from": 1500171889297,
                            "to": 1531707889297,
                            "include_lower": true,
                            "include_upper": true,
                            "boost": 1.0
                        }
                    }
                }, {
                    "bool": {
                        "should": [{
                            "term": {
                                "htsCodes.keyword": {
                                    "value": "1106300000",
                                    "boost": 1.0
                                }
                            }
                        }, {
                            "term": {
                                "hsCode.keyword": {
                                    "value": "1106300000",
                                    "boost": 1.0
                                }
                            }
                        }],
                        "adjust_pure_negative": true,
                        "boost": 1.0
                    }
                }],
                "adjust_pure_negative": true,
                "boost": 1.0
            }
        },
        "sort": [{
            "arrivaldate": {
                "order": "desc"
            }
        }, {
            "_id": {
                "order": "desc"
            }
        }],
        "aggregations": {
            "totalValueUsd": {
                "sum": {
                    "field": "totalValueUsd"
                }
            },
            "totalFob": {
                "sum": {
                    "field": "totalFob"
                }
            },
            "totalCif": {
                "sum": {
                    "field": "totalCif"
                }
            }
        }
    }
    
    
    
    贸易趋势:
    
    {
        "size": 0,
        "query": {
            "bool": {
                "must": [{
                    "term": {
                        "buyer.keyword": {
                            "value": "ASSOULINE PUBLISHING",
                            "boost": 1.0
                        }
                    }
                }, {
                    "match_phrase": {
                        "details": {
                            "query": "books",
                            "slop": 0,
                            "zero_terms_query": "NONE",
                            "boost": 1.0
                        }
                    }
                }, {
                    "range": {
                        "arrivaldate": {
                            "from": 1498838399000,
                            "to": 1532966401000,
                            "include_lower": true,
                            "include_upper": true,
                            "boost": 1.0
                        }
                    }
                }],
                "adjust_pure_negative": true,
                "boost": 1.0
            }
        },
        "sort": [{
            "arrivaldate": {
                "order": "desc"
            }
        }, {
            "_id": {
                "order": "desc"
            }
        }],
        "aggregations": {
            "count": {
                "terms": {
                    "field": "arrivaldateMonth",
                    "size": 10,
                    "min_doc_count": 1,
                    "shard_min_doc_count": 0,
                    "show_term_doc_count_error": false,
                    "order": [{
                        "_count": "desc"
                    }, {
                        "_key": "asc"
                    }]
                }
            }
        }
    }
    
    
    贸易记录:
    
    {
        "from": 0,
        "size": 10,
        "query": {
            "bool": {
                "must": [{
                    "term": {
                        "buyer.keyword": {
                            "value": "ASSOULINE PUBLISHING",
                            "boost": 1.0
                        }
                    }
                }, {
                    "match_phrase": {
                        "details": {
                            "query": "books",
                            "slop": 0,
                            "zero_terms_query": "NONE",
                            "boost": 1.0
                        }
                    }
                }],
                "adjust_pure_negative": true,
                "boost": 1.0
            }
        },
        "sort": [{
            "arrivaldate": {
                "order": "desc"
            }
        }, {
            "_id": {
                "order": "desc"
            }
        }]
    }
  • 相关阅读:
    各种视角了解数组Array以及案例展示
    js基础面试高频面点2:Javascript中undefined和not defined有什么区别,和null又有什么联系?
    一些好用的Linux命令工具
    Linux实用命令工具-dtrx根据需要自动解压
    J2EE--Hibernate基础笔记
    mysql用户与权限管理笔记
    找出字符串中出现频率最少的字符,并将其去除
    Linux常用命令--文件(夹)查找之find命令
    J2EE--Struts2基础开发笔记
    Java多线程基础知识总结笔记
  • 原文地址:https://www.cnblogs.com/wanhua-wu/p/9316266.html
Copyright © 2020-2023  润新知