elasticsearch常用查询语法

match

会进行全文匹配

{
    "query" : {
        "match": {
            "": ""
        }
    }
}

constant_score

{
    "query": {
        "constant_score": {
            "filter": {
                "match": {
                    "": ""
                }
            },
            "boost": 2
        }
    }
}

should

两个条件是 or 的关系

{
    "query": {
        "bool": {
            "should": [
                {
                    "match": {
                        "": ""
                    }
                },
                {
                    "match": {
                        "": ""
                    }
                }
            ]
        }
    }
}

must

可搭配 filter 进行过滤

{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "": ""
                    }
                },
                {
                    "match": {
                        "": ""
                    }
                }
            ],
            "filter": [
                {
                    "term": {
                        "": ""
                    }
                }
            ]
        }
    }
}

must_not

{
    "query": {
        "bool": {
            "must_not": {
                "term": {
                    "author": "瓦力"
                }
            }
        }
    }
}

你可能感兴趣的:(elasticsearch常用查询语法)