最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

constant

运维笔记admin15浏览0评论

constant

constant

当我尝试运行以下代码时,“常量分数查询不支持查询”错误即将发生。

client.search({
    index: ['index1','index2'],
    body: {
        from: 0, size: 20,
        query: {
            "constant_score": {
                boost: 1.0,
                "query": {
                    query_string: {
                        query: str,
                        fields: ['field_1']
                    }
                }
            }
        }
    },
});
回答如下:

constant_score查询包装另一个查询。它接受另一个queryfilter。在query_string而不是filter包裹query

尝试使用以下内容:

client.search({
    index: ['index1','index2'],
    body: {
        from: 0, size: 20,
        query: {
            "constant_score": {
                boost: 1.0,
                filter: {
                   query_string: {
                       query: str,
                       fields: ['field_1']
                   }
                }                
            }
        }
    },
});

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论