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