Make sure getters follow the Go convention
This commit is contained in:
parent
339ddbe0fa
commit
187d6013df
|
@ -23,8 +23,8 @@ import (
|
||||||
|
|
||||||
type BoolFieldQuery struct {
|
type BoolFieldQuery struct {
|
||||||
Bool bool `json:"bool"`
|
Bool bool `json:"bool"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBoolFieldQuery creates a new Query for boolean fields
|
// NewBoolFieldQuery creates a new Query for boolean fields
|
||||||
|
@ -36,30 +36,30 @@ func NewBoolFieldQuery(val bool) *BoolFieldQuery {
|
||||||
|
|
||||||
func (q *BoolFieldQuery) SetBoost(b float64) {
|
func (q *BoolFieldQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *BoolFieldQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *BoolFieldQuery) SetField(f string) {
|
func (q *BoolFieldQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *BoolFieldQuery) GetField() string{
|
func (q *BoolFieldQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *BoolFieldQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (q *BoolFieldQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *BoolFieldQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
term := "F"
|
term := "F"
|
||||||
if q.Bool {
|
if q.Bool {
|
||||||
term = "T"
|
term = "T"
|
||||||
}
|
}
|
||||||
return searcher.NewTermSearcher(i, term, field, q.Boost.Value(), explain)
|
return searcher.NewTermSearcher(i, term, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ type DateRangeQuery struct {
|
||||||
End BleveQueryTime `json:"end,omitempty"`
|
End BleveQueryTime `json:"end,omitempty"`
|
||||||
InclusiveStart *bool `json:"inclusive_start,omitempty"`
|
InclusiveStart *bool `json:"inclusive_start,omitempty"`
|
||||||
InclusiveEnd *bool `json:"inclusive_end,omitempty"`
|
InclusiveEnd *bool `json:"inclusive_end,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDateRangeQuery creates a new Query for ranges
|
// NewDateRangeQuery creates a new Query for ranges
|
||||||
|
@ -110,19 +110,20 @@ func NewDateRangeInclusiveQuery(start, end time.Time, startInclusive, endInclusi
|
||||||
|
|
||||||
func (q *DateRangeQuery) SetBoost(b float64) {
|
func (q *DateRangeQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *DateRangeQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (q *DateRangeQuery) SetField(f string) {
|
func (q *DateRangeQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *DateRangeQuery) GetField() string{
|
func (q *DateRangeQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *DateRangeQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
|
@ -131,12 +132,12 @@ func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, e
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
|
|
||||||
return searcher.NewNumericRangeSearcher(i, min, max, q.InclusiveStart, q.InclusiveEnd, field, q.Boost.Value(), explain)
|
return searcher.NewNumericRangeSearcher(i, min, max, q.InclusiveStart, q.InclusiveEnd, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *DateRangeQuery) parseEndpoints() (*float64, *float64, error) {
|
func (q *DateRangeQuery) parseEndpoints() (*float64, *float64, error) {
|
||||||
|
|
|
@ -25,8 +25,8 @@ type FuzzyQuery struct {
|
||||||
Term string `json:"term"`
|
Term string `json:"term"`
|
||||||
Prefix int `json:"prefix_length"`
|
Prefix int `json:"prefix_length"`
|
||||||
Fuzziness int `json:"fuzziness"`
|
Fuzziness int `json:"fuzziness"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFuzzyQuery creates a new Query which finds
|
// NewFuzzyQuery creates a new Query which finds
|
||||||
|
@ -45,19 +45,19 @@ func NewFuzzyQuery(term string) *FuzzyQuery {
|
||||||
|
|
||||||
func (q *FuzzyQuery) SetBoost(b float64) {
|
func (q *FuzzyQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *FuzzyQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *FuzzyQuery) SetField(f string) {
|
func (q *FuzzyQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *FuzzyQuery) GetField() string{
|
func (q *FuzzyQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *FuzzyQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *FuzzyQuery) SetFuzziness(f int) {
|
func (q *FuzzyQuery) SetFuzziness(f int) {
|
||||||
|
@ -69,9 +69,9 @@ func (q *FuzzyQuery) SetPrefix(p int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *FuzzyQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *FuzzyQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
return searcher.NewFuzzySearcher(i, q.Term, q.Prefix, q.Fuzziness, field, q.Boost.Value(), explain)
|
return searcher.NewFuzzySearcher(i, q.Term, q.Prefix, q.Fuzziness, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ import (
|
||||||
|
|
||||||
type MatchQuery struct {
|
type MatchQuery struct {
|
||||||
Match string `json:"match"`
|
Match string `json:"match"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Analyzer string `json:"analyzer,omitempty"`
|
Analyzer string `json:"analyzer,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
Prefix int `json:"prefix_length"`
|
Prefix int `json:"prefix_length"`
|
||||||
Fuzziness int `json:"fuzziness"`
|
Fuzziness int `json:"fuzziness"`
|
||||||
Operator MatchQueryOperator `json:"operator,omitempty"`
|
Operator MatchQueryOperator `json:"operator,omitempty"`
|
||||||
|
@ -87,19 +87,19 @@ func NewMatchQuery(match string) *MatchQuery {
|
||||||
|
|
||||||
func (q *MatchQuery) SetBoost(b float64) {
|
func (q *MatchQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *MatchQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchQuery) SetField(f string) {
|
func (q *MatchQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchQuery) GetField() string{
|
func (q *MatchQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *MatchQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchQuery) SetFuzziness(f int) {
|
func (q *MatchQuery) SetFuzziness(f int) {
|
||||||
|
@ -116,8 +116,8 @@ func (q *MatchQuery) SetOperator(operator MatchQueryOperator) {
|
||||||
|
|
||||||
func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
|
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@ func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expla
|
||||||
query.SetFuzziness(q.Fuzziness)
|
query.SetFuzziness(q.Fuzziness)
|
||||||
query.SetPrefix(q.Prefix)
|
query.SetPrefix(q.Prefix)
|
||||||
query.SetField(field)
|
query.SetField(field)
|
||||||
query.SetBoost(q.Boost.Value())
|
query.SetBoost(q.BoostVal.Value())
|
||||||
tqs[i] = query
|
tqs[i] = query
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, token := range tokens {
|
for i, token := range tokens {
|
||||||
tq := NewTermQuery(string(token.Term))
|
tq := NewTermQuery(string(token.Term))
|
||||||
tq.SetField(field)
|
tq.SetField(field)
|
||||||
tq.SetBoost(q.Boost.Value())
|
tq.SetBoost(q.BoostVal.Value())
|
||||||
tqs[i] = tq
|
tqs[i] = tq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,12 +159,12 @@ func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expla
|
||||||
case MatchQueryOperatorOr:
|
case MatchQueryOperatorOr:
|
||||||
shouldQuery := NewDisjunctionQuery(tqs)
|
shouldQuery := NewDisjunctionQuery(tqs)
|
||||||
shouldQuery.SetMin(1)
|
shouldQuery.SetMin(1)
|
||||||
shouldQuery.SetBoost(q.Boost.Value())
|
shouldQuery.SetBoost(q.BoostVal.Value())
|
||||||
return shouldQuery.Searcher(i, m, explain)
|
return shouldQuery.Searcher(i, m, explain)
|
||||||
|
|
||||||
case MatchQueryOperatorAnd:
|
case MatchQueryOperatorAnd:
|
||||||
mustQuery := NewConjunctionQuery(tqs)
|
mustQuery := NewConjunctionQuery(tqs)
|
||||||
mustQuery.SetBoost(q.Boost.Value())
|
mustQuery.SetBoost(q.BoostVal.Value())
|
||||||
return mustQuery.Searcher(i, m, explain)
|
return mustQuery.Searcher(i, m, explain)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -25,9 +25,9 @@ import (
|
||||||
|
|
||||||
type MatchPhraseQuery struct {
|
type MatchPhraseQuery struct {
|
||||||
MatchPhrase string `json:"match_phrase"`
|
MatchPhrase string `json:"match_phrase"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Analyzer string `json:"analyzer,omitempty"`
|
Analyzer string `json:"analyzer,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMatchPhraseQuery creates a new Query object
|
// NewMatchPhraseQuery creates a new Query object
|
||||||
|
@ -46,24 +46,24 @@ func NewMatchPhraseQuery(matchPhrase string) *MatchPhraseQuery {
|
||||||
|
|
||||||
func (q *MatchPhraseQuery) SetBoost(b float64) {
|
func (q *MatchPhraseQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *MatchPhraseQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchPhraseQuery) SetField(f string) {
|
func (q *MatchPhraseQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchPhraseQuery) GetField() string{
|
func (q *MatchPhraseQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *MatchPhraseQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping,
|
||||||
if len(tokens) > 0 {
|
if len(tokens) > 0 {
|
||||||
phrase := tokenStreamToPhrase(tokens)
|
phrase := tokenStreamToPhrase(tokens)
|
||||||
phraseQuery := NewPhraseQuery(phrase, field)
|
phraseQuery := NewPhraseQuery(phrase, field)
|
||||||
phraseQuery.SetBoost(q.Boost.Value())
|
phraseQuery.SetBoost(q.BoostVal.Value())
|
||||||
return phraseQuery.Searcher(i, m, explain)
|
return phraseQuery.Searcher(i, m, explain)
|
||||||
}
|
}
|
||||||
noneQuery := NewMatchNoneQuery()
|
noneQuery := NewMatchNoneQuery()
|
||||||
|
|
|
@ -28,8 +28,8 @@ type NumericRangeQuery struct {
|
||||||
Max *float64 `json:"max,omitempty"`
|
Max *float64 `json:"max,omitempty"`
|
||||||
InclusiveMin *bool `json:"inclusive_min,omitempty"`
|
InclusiveMin *bool `json:"inclusive_min,omitempty"`
|
||||||
InclusiveMax *bool `json:"inclusive_max,omitempty"`
|
InclusiveMax *bool `json:"inclusive_max,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNumericRangeQuery creates a new Query for ranges
|
// NewNumericRangeQuery creates a new Query for ranges
|
||||||
|
@ -56,27 +56,27 @@ func NewNumericRangeInclusiveQuery(min, max *float64, minInclusive, maxInclusive
|
||||||
|
|
||||||
func (q *NumericRangeQuery) SetBoost(b float64) {
|
func (q *NumericRangeQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *NumericRangeQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *NumericRangeQuery) SetField(f string) {
|
func (q *NumericRangeQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *NumericRangeQuery) GetField() string{
|
func (q *NumericRangeQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *NumericRangeQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *NumericRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *NumericRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
return searcher.NewNumericRangeSearcher(i, q.Min, q.Max, q.InclusiveMin, q.InclusiveMax, field, q.Boost.Value(), explain)
|
return searcher.NewNumericRangeSearcher(i, q.Min, q.Max, q.InclusiveMin, q.InclusiveMax, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *NumericRangeQuery) Validate() error {
|
func (q *NumericRangeQuery) Validate() error {
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (q *PhraseQuery) UnmarshalJSON(data []byte) error {
|
||||||
q.Boost = tmp.Boost
|
q.Boost = tmp.Boost
|
||||||
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, Field: q.Field, Boost: q.Boost}
|
q.termQueries[i] = &TermQuery{Term: term, FieldVal: q.Field, BoostVal: q.Boost}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrefixQuery struct {
|
type PrefixQuery struct {
|
||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrefixQuery creates a new Query which finds
|
// NewPrefixQuery creates a new Query which finds
|
||||||
|
@ -38,25 +38,25 @@ func NewPrefixQuery(prefix string) *PrefixQuery {
|
||||||
|
|
||||||
func (q *PrefixQuery) SetBoost(b float64) {
|
func (q *PrefixQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *PrefixQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *PrefixQuery) SetField(f string) {
|
func (q *PrefixQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *PrefixQuery) GetField() string{
|
func (q *PrefixQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *PrefixQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *PrefixQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *PrefixQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
return searcher.NewTermPrefixSearcher(i, q.Prefix, field, q.Boost.Value(), explain)
|
return searcher.NewTermPrefixSearcher(i, q.Prefix, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ type Query interface {
|
||||||
type BoostableQuery interface {
|
type BoostableQuery interface {
|
||||||
Query
|
Query
|
||||||
SetBoost(b float64)
|
SetBoost(b float64)
|
||||||
GetBoost() float64
|
Boost() float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// A FieldableQuery represents a Query which can be restricted
|
// A FieldableQuery represents a Query which can be restricted
|
||||||
|
@ -52,7 +52,7 @@ type BoostableQuery interface {
|
||||||
type FieldableQuery interface {
|
type FieldableQuery interface {
|
||||||
Query
|
Query
|
||||||
SetField(f string)
|
SetField(f string)
|
||||||
GetField() string
|
Field() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// A ValidatableQuery represents a Query which can be validated
|
// A ValidatableQuery represents a Query which can be validated
|
||||||
|
|
|
@ -26,8 +26,8 @@ import (
|
||||||
|
|
||||||
type RegexpQuery struct {
|
type RegexpQuery struct {
|
||||||
Regexp string `json:"regexp"`
|
Regexp string `json:"regexp"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
compiled *regexp.Regexp
|
compiled *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,24 +42,24 @@ func NewRegexpQuery(regexp string) *RegexpQuery {
|
||||||
|
|
||||||
func (q *RegexpQuery) SetBoost(b float64) {
|
func (q *RegexpQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *RegexpQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *RegexpQuery) SetField(f string) {
|
func (q *RegexpQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *RegexpQuery) GetField() string{
|
func (q *RegexpQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *RegexpQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
err := q.compile()
|
err := q.compile()
|
||||||
|
@ -67,7 +67,7 @@ func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expl
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return searcher.NewRegexpSearcher(i, q.compiled, field, q.Boost.Value(), explain)
|
return searcher.NewRegexpSearcher(i, q.compiled, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *RegexpQuery) Validate() error {
|
func (q *RegexpQuery) Validate() error {
|
||||||
|
|
|
@ -22,9 +22,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type TermQuery struct {
|
type TermQuery struct {
|
||||||
Term string `json:"term"`
|
Term string `json:"term"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTermQuery creates a new Query for finding an
|
// NewTermQuery creates a new Query for finding an
|
||||||
|
@ -37,25 +37,25 @@ func NewTermQuery(term string) *TermQuery {
|
||||||
|
|
||||||
func (q *TermQuery) SetBoost(b float64) {
|
func (q *TermQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *TermQuery) Boost() float64{
|
||||||
|
return q.BoostVal.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *TermQuery) SetField(f string) {
|
func (q *TermQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *TermQuery) GetField() string{
|
func (q *TermQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
|
||||||
|
|
||||||
func (q *TermQuery) GetBoost() float64{
|
|
||||||
return q.Boost.Value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *TermQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
func (q *TermQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
|
||||||
field := q.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
return searcher.NewTermSearcher(i, q.Term, field, q.Boost.Value(), explain)
|
return searcher.NewTermSearcher(i, q.Term, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ var wildcardRegexpReplacer = strings.NewReplacer(
|
||||||
|
|
||||||
type WildcardQuery struct {
|
type WildcardQuery struct {
|
||||||
Wildcard string `json:"wildcard"`
|
Wildcard string `json:"wildcard"`
|
||||||
Field string `json:"field,omitempty"`
|
FieldVal string `json:"field,omitempty"`
|
||||||
Boost *Boost `json:"boost,omitempty"`
|
BoostVal *Boost `json:"boost,omitempty"`
|
||||||
compiled *regexp.Regexp
|
compiled *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,24 +63,24 @@ func NewWildcardQuery(wildcard string) *WildcardQuery {
|
||||||
|
|
||||||
func (q *WildcardQuery) SetBoost(b float64) {
|
func (q *WildcardQuery) SetBoost(b float64) {
|
||||||
boost := Boost(b)
|
boost := Boost(b)
|
||||||
q.Boost = &boost
|
q.BoostVal = &boost
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *WildcardQuery) SetField(f string) {
|
func (q *WildcardQuery) SetField(f string) {
|
||||||
q.Field = f
|
q.FieldVal = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *WildcardQuery) GetField() string{
|
func (q *WildcardQuery) Field() string{
|
||||||
return q.Field
|
return q.FieldVal
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *WildcardQuery) GetBoost() float64{
|
func (q *WildcardQuery) Boost() float64{
|
||||||
return q.Boost.Value()
|
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.Field
|
field := q.FieldVal
|
||||||
if q.Field == "" {
|
if q.FieldVal == "" {
|
||||||
field = m.DefaultSearchField()
|
field = m.DefaultSearchField()
|
||||||
}
|
}
|
||||||
if q.compiled == nil {
|
if q.compiled == nil {
|
||||||
|
@ -91,7 +91,7 @@ func (q *WildcardQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, ex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return searcher.NewRegexpSearcher(i, q.compiled, field, q.Boost.Value(), explain)
|
return searcher.NewRegexpSearcher(i, q.compiled, field, q.BoostVal.Value(), explain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *WildcardQuery) Validate() error {
|
func (q *WildcardQuery) Validate() error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user