2014-07-03 20:54:50 +02:00
|
|
|
package search
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/couchbaselabs/bleve/index"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PhraseQuery struct {
|
2014-07-11 20:49:59 +02:00
|
|
|
Terms []*TermQuery `json:"terms,omitempty"`
|
|
|
|
BoostVal float64 `json:"boost,omitempty"`
|
|
|
|
Explain bool `json:"explain,omitempty"`
|
2014-07-03 20:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *PhraseQuery) Boost() float64 {
|
|
|
|
return q.BoostVal
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *PhraseQuery) Searcher(index index.Index) (Searcher, error) {
|
|
|
|
return NewPhraseSearcher(index, q)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *PhraseQuery) Validate() error {
|
|
|
|
if q.Terms == nil {
|
|
|
|
return fmt.Errorf("Phrase query must contain at least one term")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|