Elasticsearch使用bool提升查询

时间:2018-02-08 16:40:00

标签: elasticsearch

我正在尝试在提升查询中进行bool查询,但无法获得所需的结果

qry = {
"query" : {
        "boosting" : {
            "positive" : {
                "bool" : {
                    "must" : [
                    {   
                        "match" : {
                            "author" : "doyle"
                        }
                    },
                    {
                        "match" : {
                            "text" : "elementary"
                        }
                    }
                    ]
                }
            },
            "negative" :{
                "match" : {
                    "text" : "holmes"
                }
            },
            "negative_boost" : 0.2
        }
    }
}

提升查询的否定部分似乎并不适用于具有' holmes'不被压制。

以下是索引

的映射
mapping = {
    "mappings" : {
        "book" : {
            "properties" : {
                "title" : {
                    "type" : "text",
                    "index_options" : "docs"
                },
                "author" : {
                    "type" : "text",
                    "index_options" : "docs"
                },
                "line_no" : {
                    "type" : "integer"
                },
                "text" : {
                    "type" : "text",
                    "index_options" : "offsets"
                }
            }
        }
    }
}

0 个答案:

没有答案