Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing API's for a few queries #2089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions search/query/multi_phrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

type MultiPhraseQuery struct {
Terms [][]string `json:"terms"`
Field string `json:"field,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
Fuzziness int `json:"fuzziness"`
}
Expand All @@ -43,8 +43,8 @@ type MultiPhraseQuery struct {
// IncludeTermVectors set to true.
func NewMultiPhraseQuery(terms [][]string, field string) *MultiPhraseQuery {
return &MultiPhraseQuery{
Terms: terms,
Field: field,
Terms: terms,
FieldVal: field,
}
}

Expand All @@ -61,8 +61,16 @@ func (q *MultiPhraseQuery) Boost() float64 {
return q.BoostVal.Value()
}

func (q *MultiPhraseQuery) Field() string {
return q.FieldVal
}

func (q *MultiPhraseQuery) SetField(f string) {
q.FieldVal = f
}

func (q *MultiPhraseQuery) Searcher(ctx context.Context, i index.IndexReader, m mapping.IndexMapping, options search.SearcherOptions) (search.Searcher, error) {
return searcher.NewMultiPhraseSearcher(ctx, i, q.Terms, q.Fuzziness, q.Field, q.BoostVal.Value(), options)
return searcher.NewMultiPhraseSearcher(ctx, i, q.Terms, q.Fuzziness, q.FieldVal, q.BoostVal.Value(), options)
}

func (q *MultiPhraseQuery) Validate() error {
Expand All @@ -80,7 +88,7 @@ func (q *MultiPhraseQuery) UnmarshalJSON(data []byte) error {
return err
}
q.Terms = tmp.Terms
q.Field = tmp.Field
q.FieldVal = tmp.FieldVal
q.BoostVal = tmp.BoostVal
q.Fuzziness = tmp.Fuzziness
return nil
Expand Down
18 changes: 13 additions & 5 deletions search/query/phrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

type PhraseQuery struct {
Terms []string `json:"terms"`
Field string `json:"field,omitempty"`
FieldVal string `json:"field,omitempty"`
BoostVal *Boost `json:"boost,omitempty"`
Fuzziness int `json:"fuzziness"`
}
Expand All @@ -40,8 +40,8 @@ type PhraseQuery struct {
// IncludeTermVectors set to true.
func NewPhraseQuery(terms []string, field string) *PhraseQuery {
return &PhraseQuery{
Terms: terms,
Field: field,
Terms: terms,
FieldVal: field,
}
}

Expand All @@ -58,8 +58,16 @@ func (q *PhraseQuery) Boost() float64 {
return q.BoostVal.Value()
}

func (q *PhraseQuery) SetField(f string) {
q.FieldVal = f
}

func (q *PhraseQuery) Field() string {
return q.FieldVal
}

func (q *PhraseQuery) Searcher(ctx context.Context, i index.IndexReader, m mapping.IndexMapping, options search.SearcherOptions) (search.Searcher, error) {
return searcher.NewPhraseSearcher(ctx, i, q.Terms, q.Fuzziness, q.Field, q.BoostVal.Value(), options)
return searcher.NewPhraseSearcher(ctx, i, q.Terms, q.Fuzziness, q.FieldVal, q.BoostVal.Value(), options)
}

func (q *PhraseQuery) Validate() error {
Expand All @@ -77,7 +85,7 @@ func (q *PhraseQuery) UnmarshalJSON(data []byte) error {
return err
}
q.Terms = tmp.Terms
q.Field = tmp.Field
q.FieldVal = tmp.FieldVal
q.BoostVal = tmp.BoostVal
q.Fuzziness = tmp.Fuzziness
return nil
Expand Down
Loading