Added missing boost getters
This commit is contained in:
parent
187d6013df
commit
a4c94e440e
|
@ -40,8 +40,11 @@ func (q *BoolFieldQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *BoolFieldQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *BoolFieldQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -28,7 +28,7 @@ type BooleanQuery struct {
|
|||
Must Query `json:"must,omitempty"`
|
||||
Should Query `json:"should,omitempty"`
|
||||
MustNot Query `json:"must_not,omitempty"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewBooleanQuery creates a compound Query composed
|
||||
|
@ -90,7 +90,14 @@ func (q *BooleanQuery) AddMustNot(m ...Query) {
|
|||
|
||||
func (q *BooleanQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *BooleanQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *BooleanQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
|
@ -199,7 +206,7 @@ func (q *BooleanQuery) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
}
|
||||
|
||||
q.Boost = tmp.Boost
|
||||
q.BoostVal = tmp.Boost
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
type ConjunctionQuery struct {
|
||||
Conjuncts []Query `json:"conjuncts"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewConjunctionQuery creates a new compound Query.
|
||||
|
@ -38,7 +38,14 @@ func NewConjunctionQuery(conjuncts []Query) *ConjunctionQuery {
|
|||
|
||||
func (q *ConjunctionQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *ConjunctionQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *ConjunctionQuery) AddQuery(aq ...Query) {
|
||||
|
@ -93,6 +100,6 @@ func (q *ConjunctionQuery) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
q.Conjuncts[i] = query
|
||||
}
|
||||
q.Boost = tmp.Boost
|
||||
q.BoostVal = tmp.Boost
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -114,8 +114,11 @@ func (q *DateRangeQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *DateRangeQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
func (q *DateRangeQuery) SetField(f string) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
type DisjunctionQuery struct {
|
||||
Disjuncts []Query `json:"disjuncts"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
Min float64 `json:"min"`
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,17 @@ func NewDisjunctionQuery(disjuncts []Query) *DisjunctionQuery {
|
|||
|
||||
func (q *DisjunctionQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *DisjunctionQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
func (q *DisjunctionQuery) AddQuery(aq ...Query) {
|
||||
for _, aaq := range aq {
|
||||
q.Disjuncts = append(q.Disjuncts, aaq)
|
||||
|
@ -103,7 +111,7 @@ func (q *DisjunctionQuery) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
q.Disjuncts[i] = query
|
||||
}
|
||||
q.Boost = tmp.Boost
|
||||
q.BoostVal = tmp.Boost
|
||||
q.Min = tmp.Min
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
type DocIDQuery struct {
|
||||
IDs []string `json:"ids"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewDocIDQuery creates a new Query object returning indexed documents among
|
||||
|
@ -37,9 +37,16 @@ func NewDocIDQuery(ids []string) *DocIDQuery {
|
|||
|
||||
func (q *DocIDQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *DocIDQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *DocIDQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
return searcher.NewDocIDSearcher(i, q.IDs, q.Boost.Value(), explain)
|
||||
return searcher.NewDocIDSearcher(i, q.IDs, q.BoostVal.Value(), explain)
|
||||
}
|
||||
|
|
|
@ -49,8 +49,11 @@ func (q *FuzzyQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *FuzzyQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *FuzzyQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -91,8 +91,11 @@ func (q *MatchQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *MatchQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *MatchQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
type MatchAllQuery struct {
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewMatchAllQuery creates a Query which will
|
||||
|
@ -35,16 +35,25 @@ func NewMatchAllQuery() *MatchAllQuery {
|
|||
|
||||
func (q *MatchAllQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *MatchAllQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (q *MatchAllQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
return searcher.NewMatchAllSearcher(i, q.Boost.Value(), explain)
|
||||
return searcher.NewMatchAllSearcher(i, q.BoostVal.Value(), explain)
|
||||
}
|
||||
|
||||
func (q *MatchAllQuery) MarshalJSON() ([]byte, error) {
|
||||
tmp := map[string]interface{}{
|
||||
"boost": q.Boost,
|
||||
"boost": q.BoostVal,
|
||||
"match_all": map[string]interface{}{},
|
||||
}
|
||||
return json.Marshal(tmp)
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
type MatchNoneQuery struct {
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewMatchNoneQuery creates a Query which will not
|
||||
|
@ -35,7 +35,14 @@ func NewMatchNoneQuery() *MatchNoneQuery {
|
|||
|
||||
func (q *MatchNoneQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *MatchNoneQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *MatchNoneQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
|
@ -44,7 +51,7 @@ func (q *MatchNoneQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, e
|
|||
|
||||
func (q *MatchNoneQuery) MarshalJSON() ([]byte, error) {
|
||||
tmp := map[string]interface{}{
|
||||
"boost": q.Boost,
|
||||
"boost": q.BoostVal,
|
||||
"match_none": map[string]interface{}{},
|
||||
}
|
||||
return json.Marshal(tmp)
|
||||
|
|
|
@ -50,8 +50,11 @@ func (q *MatchPhraseQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *MatchPhraseQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *MatchPhraseQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -60,8 +60,11 @@ func (q *NumericRangeQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *NumericRangeQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *NumericRangeQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
type PhraseQuery struct {
|
||||
Terms []string `json:"terms"`
|
||||
Field string `json:"field,omitempty"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
termQueries []Query
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,14 @@ func NewPhraseQuery(terms []string, field string) *PhraseQuery {
|
|||
|
||||
func (q *PhraseQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *PhraseQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *PhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
|
@ -84,10 +91,10 @@ func (q *PhraseQuery) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
q.Terms = tmp.Terms
|
||||
q.Field = tmp.Field
|
||||
q.Boost = tmp.Boost
|
||||
q.BoostVal = tmp.BoostVal
|
||||
q.termQueries = make([]Query, len(q.Terms))
|
||||
for i, term := range q.Terms {
|
||||
q.termQueries[i] = &TermQuery{Term: term, FieldVal: q.Field, BoostVal: q.Boost}
|
||||
q.termQueries[i] = &TermQuery{Term: term, FieldVal: q.Field, BoostVal: q.BoostVal}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -42,8 +42,11 @@ func (q *PrefixQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *PrefixQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *PrefixQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
type QueryStringQuery struct {
|
||||
Query string `json:"query"`
|
||||
Boost *Boost `json:"boost,omitempty"`
|
||||
BoostVal *Boost `json:"boost,omitempty"`
|
||||
}
|
||||
|
||||
// NewQueryStringQuery creates a new Query used for
|
||||
|
@ -36,7 +36,14 @@ func NewQueryStringQuery(query string) *QueryStringQuery {
|
|||
|
||||
func (q *QueryStringQuery) SetBoost(b float64) {
|
||||
boost := Boost(b)
|
||||
q.Boost = &boost
|
||||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *QueryStringQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *QueryStringQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
|
|
|
@ -46,8 +46,11 @@ func (q *RegexpQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *RegexpQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *RegexpQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -41,8 +41,11 @@ func (q *TermQuery) SetBoost(b float64) {
|
|||
}
|
||||
|
||||
func (q *TermQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *TermQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
|
|
|
@ -66,6 +66,13 @@ func (q *WildcardQuery) SetBoost(b float64) {
|
|||
q.BoostVal = &boost
|
||||
}
|
||||
|
||||
func (q *WildcardQuery) Boost() float64{
|
||||
if q.BoostVal != nil {
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (q *WildcardQuery) SetField(f string) {
|
||||
q.FieldVal = f
|
||||
}
|
||||
|
@ -74,10 +81,6 @@ func (q *WildcardQuery) Field() string{
|
|||
return q.FieldVal
|
||||
}
|
||||
|
||||
func (q *WildcardQuery) Boost() float64{
|
||||
return q.BoostVal.Value()
|
||||
}
|
||||
|
||||
func (q *WildcardQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||
field := q.FieldVal
|
||||
if q.FieldVal == "" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user