带分页、过滤条件的DSL

"query": {
    "bool": {
        "must_not": {
            "match_phrase": {
                "product_name": "测试"
            }
        },
        "must": [
            {
                "match_phrase": {
                    "product_name": "米"
                }
            },
            {
                "query": {
                    "bool": {
                        "should": [
                            {
                                "match_phrase": {“people_name": "张三"}
                            }, {
                                "match_phrase": {"people_name": “李四"}
                            }
                        ]
                    }
                }
            },
            {
                "range": {
                    "create_time": {"gte": "1990-06-01", "lt": "2016-06-01"}
                }
            }
        ]
    }
},
"sort": {"create_time": {"order": "desc"}},
"from": 0,
"size": 10

match_phrase :match_phrase查询首先解析查询字符串来产生一个词条列表。然后会搜索所有的词条,但只保留含有了所有搜索词条的文档,并且词条的位置要邻接。
should : 拼接多个查询结果

posted @ 2016-12-07 11:05  夜未央丿  阅读(223)  评论(0编辑  收藏  举报