f225d484b3
many bugs fixed in existing search phrase query updated to support gaps in term sequence new query types all,none,match,phrase match and new query syntax search, like google search: +/-(optional field qualifier:)<term or quoted phrase>
29 lines
568 B
Go
29 lines
568 B
Go
package search
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/couchbaselabs/bleve/index"
|
|
)
|
|
|
|
type PhraseQuery struct {
|
|
Terms []*TermQuery `json:"terms,omitempty"`
|
|
BoostVal float64 `json:"boost,omitempty"`
|
|
Explain bool `json:"explain,omitempty"`
|
|
}
|
|
|
|
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
|
|
}
|