代码拉取完成,页面将自动刷新
// Copyright 2012-2015 Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
package elastic
// ConstantScoreQuery wraps a filter or another query and simply returns
// a constant score equal to the query boost for every document in the filter.
//
// For more details, see
// https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-constant-score-query.html
type ConstantScoreQuery struct {
query Query
filter Filter
boost *float64
}
// NewConstantScoreQuery creates a new constant score query.
func NewConstantScoreQuery() ConstantScoreQuery {
return ConstantScoreQuery{}
}
// Query to wrap in this constant score query.
func (q ConstantScoreQuery) Query(query Query) ConstantScoreQuery {
q.query = query
q.filter = nil
return q
}
// Filter to wrap in this constant score query.
func (q ConstantScoreQuery) Filter(filter Filter) ConstantScoreQuery {
q.query = nil
q.filter = filter
return q
}
// Boost sets the boost for this query. Documents matching this query
// will (in addition to the normal weightings) have their score multiplied
// by the boost provided.
func (q ConstantScoreQuery) Boost(boost float64) ConstantScoreQuery {
q.boost = &boost
return q
}
// Source returns JSON for the function score query.
func (q ConstantScoreQuery) Source() interface{} {
source := make(map[string]interface{})
query := make(map[string]interface{})
source["constant_score"] = query
if q.query != nil {
query["query"] = q.query.Source()
} else if q.filter != nil {
query["filter"] = q.filter.Source()
}
if q.boost != nil {
query["boost"] = *q.boost
}
return source
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。