0
0

Merge branch 'slavikm-master4'

This commit is contained in:
Marty Schoch 2016-11-28 15:00:48 -05:00
commit c351931701
19 changed files with 224 additions and 105 deletions

View File

@ -23,8 +23,8 @@ import (
type BoolFieldQuery struct {
Bool bool `json:"bool"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewBoolFieldQuery creates a new Query for boolean fields
@ -36,21 +36,30 @@ func NewBoolFieldQuery(val bool) *BoolFieldQuery {
func (q *BoolFieldQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *BoolFieldQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *BoolFieldQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *BoolFieldQuery) Field() string{
return q.FieldVal
}
func (q *BoolFieldQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
field = m.DefaultSearchField()
}
term := "F"
if q.Bool {
term = "T"
}
return searcher.NewTermSearcher(i, term, field, q.Boost.Value(), explain)
return searcher.NewTermSearcher(i, term, field, q.BoostVal.Value(), explain)
}

View File

@ -25,10 +25,10 @@ import (
)
type BooleanQuery struct {
Must Query `json:"must,omitempty"`
Should Query `json:"should,omitempty"`
MustNot Query `json:"must_not,omitempty"`
Boost *Boost `json:"boost,omitempty"`
Must Query `json:"must,omitempty"`
Should Query `json:"should,omitempty"`
MustNot Query `json:"must_not,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewBooleanQuery creates a compound Query composed
@ -90,7 +90,11 @@ 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{
return q.BoostVal.Value()
}
func (q *BooleanQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
@ -199,7 +203,7 @@ func (q *BooleanQuery) UnmarshalJSON(data []byte) error {
}
}
q.Boost = tmp.Boost
q.BoostVal = tmp.Boost
return nil
}

View File

@ -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,11 @@ 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{
return q.BoostVal.Value()
}
func (q *ConjunctionQuery) AddQuery(aq ...Query) {
@ -93,6 +97,6 @@ func (q *ConjunctionQuery) UnmarshalJSON(data []byte) error {
}
q.Conjuncts[i] = query
}
q.Boost = tmp.Boost
q.BoostVal = tmp.Boost
return nil
}

View File

@ -80,8 +80,8 @@ type DateRangeQuery struct {
End BleveQueryTime `json:"end,omitempty"`
InclusiveStart *bool `json:"inclusive_start,omitempty"`
InclusiveEnd *bool `json:"inclusive_end,omitempty"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewDateRangeQuery creates a new Query for ranges
@ -110,11 +110,20 @@ func NewDateRangeInclusiveQuery(start, end time.Time, startInclusive, endInclusi
func (q *DateRangeQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *DateRangeQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *DateRangeQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *DateRangeQuery) Field() string{
return q.FieldVal
}
func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
@ -123,12 +132,12 @@ func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, e
return nil, err
}
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
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) {

View File

@ -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,14 @@ 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{
return q.BoostVal.Value()
}
func (q *DisjunctionQuery) AddQuery(aq ...Query) {
for _, aaq := range aq {
q.Disjuncts = append(q.Disjuncts, aaq)
@ -103,7 +108,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
}

View File

@ -22,8 +22,8 @@ import (
)
type DocIDQuery struct {
IDs []string `json:"ids"`
Boost *Boost `json:"boost,omitempty"`
IDs []string `json:"ids"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewDocIDQuery creates a new Query object returning indexed documents among
@ -37,9 +37,13 @@ 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{
return q.BoostVal.Value()
}
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)
}

View File

@ -25,8 +25,8 @@ type FuzzyQuery struct {
Term string `json:"term"`
Prefix int `json:"prefix_length"`
Fuzziness int `json:"fuzziness"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewFuzzyQuery creates a new Query which finds
@ -45,11 +45,19 @@ func NewFuzzyQuery(term string) *FuzzyQuery {
func (q *FuzzyQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *FuzzyQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *FuzzyQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *FuzzyQuery) Field() string{
return q.FieldVal
}
func (q *FuzzyQuery) SetFuzziness(f int) {
@ -61,9 +69,9 @@ func (q *FuzzyQuery) SetPrefix(p int) {
}
func (q *FuzzyQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
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)
}

View File

@ -25,9 +25,9 @@ import (
type MatchQuery struct {
Match string `json:"match"`
Field string `json:"field,omitempty"`
FieldVal string `json:"field,omitempty"`
Analyzer string `json:"analyzer,omitempty"`
Boost *Boost `json:"boost,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
Prefix int `json:"prefix_length"`
Fuzziness int `json:"fuzziness"`
Operator MatchQueryOperator `json:"operator,omitempty"`
@ -87,11 +87,19 @@ func NewMatchQuery(match string) *MatchQuery {
func (q *MatchQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *MatchQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *MatchQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *MatchQuery) Field() string{
return q.FieldVal
}
func (q *MatchQuery) SetFuzziness(f int) {
@ -108,8 +116,8 @@ func (q *MatchQuery) SetOperator(operator MatchQueryOperator) {
func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
field = m.DefaultSearchField()
}
@ -135,14 +143,14 @@ func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expla
query.SetFuzziness(q.Fuzziness)
query.SetPrefix(q.Prefix)
query.SetField(field)
query.SetBoost(q.Boost.Value())
query.SetBoost(q.BoostVal.Value())
tqs[i] = query
}
} else {
for i, token := range tokens {
tq := NewTermQuery(string(token.Term))
tq.SetField(field)
tq.SetBoost(q.Boost.Value())
tq.SetBoost(q.BoostVal.Value())
tqs[i] = tq
}
}
@ -151,12 +159,12 @@ func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expla
case MatchQueryOperatorOr:
shouldQuery := NewDisjunctionQuery(tqs)
shouldQuery.SetMin(1)
shouldQuery.SetBoost(q.Boost.Value())
shouldQuery.SetBoost(q.BoostVal.Value())
return shouldQuery.Searcher(i, m, explain)
case MatchQueryOperatorAnd:
mustQuery := NewConjunctionQuery(tqs)
mustQuery.SetBoost(q.Boost.Value())
mustQuery.SetBoost(q.BoostVal.Value())
return mustQuery.Searcher(i, m, explain)
default:

View File

@ -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,22 @@ func NewMatchAllQuery() *MatchAllQuery {
func (q *MatchAllQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *MatchAllQuery) Boost() float64{
return q.BoostVal.Value()
}
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)

View File

@ -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,11 @@ func NewMatchNoneQuery() *MatchNoneQuery {
func (q *MatchNoneQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *MatchNoneQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *MatchNoneQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
@ -44,7 +48,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)

View File

@ -25,9 +25,9 @@ import (
type MatchPhraseQuery struct {
MatchPhrase string `json:"match_phrase"`
Field string `json:"field,omitempty"`
FieldVal string `json:"field,omitempty"`
Analyzer string `json:"analyzer,omitempty"`
Boost *Boost `json:"boost,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewMatchPhraseQuery creates a new Query object
@ -46,16 +46,24 @@ func NewMatchPhraseQuery(matchPhrase string) *MatchPhraseQuery {
func (q *MatchPhraseQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *MatchPhraseQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *MatchPhraseQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *MatchPhraseQuery) Field() string{
return q.FieldVal
}
func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
field = m.DefaultSearchField()
}
@ -74,7 +82,7 @@ func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping,
if len(tokens) > 0 {
phrase := tokenStreamToPhrase(tokens)
phraseQuery := NewPhraseQuery(phrase, field)
phraseQuery.SetBoost(q.Boost.Value())
phraseQuery.SetBoost(q.BoostVal.Value())
return phraseQuery.Searcher(i, m, explain)
}
noneQuery := NewMatchNoneQuery()

View File

@ -28,8 +28,8 @@ type NumericRangeQuery struct {
Max *float64 `json:"max,omitempty"`
InclusiveMin *bool `json:"inclusive_min,omitempty"`
InclusiveMax *bool `json:"inclusive_max,omitempty"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewNumericRangeQuery creates a new Query for ranges
@ -56,19 +56,27 @@ func NewNumericRangeInclusiveQuery(min, max *float64, minInclusive, maxInclusive
func (q *NumericRangeQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *NumericRangeQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *NumericRangeQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *NumericRangeQuery) Field() string{
return q.FieldVal
}
func (q *NumericRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
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 {

View File

@ -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,11 @@ 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{
return q.BoostVal.Value()
}
func (q *PhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
@ -84,10 +88,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, Field: q.Field, Boost: q.Boost}
q.termQueries[i] = &TermQuery{Term: term, FieldVal: q.Field, BoostVal: q.BoostVal}
}
return nil
}

View File

@ -22,9 +22,9 @@ import (
)
type PrefixQuery struct {
Prefix string `json:"prefix"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
Prefix string `json:"prefix"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewPrefixQuery creates a new Query which finds
@ -38,17 +38,25 @@ func NewPrefixQuery(prefix string) *PrefixQuery {
func (q *PrefixQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *PrefixQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *PrefixQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *PrefixQuery) Field() string{
return q.FieldVal
}
func (q *PrefixQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
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)
}

View File

@ -44,6 +44,7 @@ type Query interface {
type BoostableQuery interface {
Query
SetBoost(b float64)
Boost() float64
}
// A FieldableQuery represents a Query which can be restricted
@ -51,6 +52,7 @@ type BoostableQuery interface {
type FieldableQuery interface {
Query
SetField(f string)
Field() string
}
// A ValidatableQuery represents a Query which can be validated

View File

@ -21,8 +21,8 @@ import (
)
type QueryStringQuery struct {
Query string `json:"query"`
Boost *Boost `json:"boost,omitempty"`
Query string `json:"query"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewQueryStringQuery creates a new Query used for
@ -36,7 +36,11 @@ 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{
return q.BoostVal.Value()
}
func (q *QueryStringQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {

View File

@ -26,8 +26,8 @@ import (
type RegexpQuery struct {
Regexp string `json:"regexp"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
compiled *regexp.Regexp
}
@ -42,16 +42,24 @@ func NewRegexpQuery(regexp string) *RegexpQuery {
func (q *RegexpQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *RegexpQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *RegexpQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *RegexpQuery) Field() string{
return q.FieldVal
}
func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
field = m.DefaultSearchField()
}
err := q.compile()
@ -59,7 +67,7 @@ func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, expl
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 {

View File

@ -22,9 +22,9 @@ import (
)
type TermQuery struct {
Term string `json:"term"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
Term string `json:"term"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
}
// NewTermQuery creates a new Query for finding an
@ -37,17 +37,25 @@ func NewTermQuery(term string) *TermQuery {
func (q *TermQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *TermQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *TermQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *TermQuery) Field() string{
return q.FieldVal
}
func (q *TermQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
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)
}

View File

@ -45,8 +45,8 @@ var wildcardRegexpReplacer = strings.NewReplacer(
type WildcardQuery struct {
Wildcard string `json:"wildcard"`
Field string `json:"field,omitempty"`
Boost *Boost `json:"boost,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
compiled *regexp.Regexp
}
@ -63,16 +63,24 @@ func NewWildcardQuery(wildcard string) *WildcardQuery {
func (q *WildcardQuery) SetBoost(b float64) {
boost := Boost(b)
q.Boost = &boost
q.BoostVal = &boost
}
func (q *WildcardQuery) Boost() float64{
return q.BoostVal.Value()
}
func (q *WildcardQuery) SetField(f string) {
q.Field = f
q.FieldVal = f
}
func (q *WildcardQuery) Field() string{
return q.FieldVal
}
func (q *WildcardQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
field := q.Field
if q.Field == "" {
field := q.FieldVal
if q.FieldVal == "" {
field = m.DefaultSearchField()
}
if q.compiled == nil {
@ -83,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 {