Skip to content
Merged
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
3 changes: 1 addition & 2 deletions analysis/token/keyword/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func NewKeyWordMarkerFilter(keyWords analysis.TokenMap) *KeyWordMarkerFilter {

func (f *KeyWordMarkerFilter) Filter(input analysis.TokenStream) analysis.TokenStream {
for _, token := range input {
word := string(token.Term)
_, isKeyWord := f.keyWords[word]
_, isKeyWord := f.keyWords[string(token.Term)]
if isKeyWord {
token.KeyWord = true
}
Expand Down
1 change: 0 additions & 1 deletion index/scorch/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func TestIndexReader(t *testing.T) {
t.Errorf("Error accessing term field reader: %v", err)
}

expectedCount = 2
count = reader.Count()
if count != expectedCount {
t.Errorf("Expected doc count to be: %d got: %d", expectedCount, count)
Expand Down
16 changes: 8 additions & 8 deletions index/upsidedown/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import (
"github.com/golang/protobuf/proto"
)

var reflectStaticSizeTermFrequencyRow int
var reflectStaticSizeTermVector int
var (
reflectStaticSizeTermFrequencyRow int
reflectStaticSizeTermVector int
)

func init() {
var tfr TermFrequencyRow
Expand Down Expand Up @@ -322,7 +324,6 @@ func NewDictionaryRowKV(key, value []byte) (*DictionaryRow, error) {
return nil, err
}
return rv, nil

}

func NewDictionaryRowK(key []byte) (*DictionaryRow, error) {
Expand Down Expand Up @@ -642,7 +643,7 @@ func (tfr *TermFrequencyRow) parseV(value []byte, includeTermVectors bool) error
}
currOffset += bytesRead

var arrayPositionsLen uint64 = 0
var arrayPositionsLen uint64
arrayPositionsLen, bytesRead = binary.Uvarint(value[currOffset:])
if bytesRead <= 0 {
return fmt.Errorf("invalid term frequency value, vector contains no arrayPositionLen")
Expand Down Expand Up @@ -682,7 +683,6 @@ func NewTermFrequencyRowKV(key, value []byte) (*TermFrequencyRow, error) {
return nil, err
}
return rv, nil

}

type BackIndexRow struct {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ func visitBackIndexRow(data []byte, callback backIndexFieldTermVisitor) error {
return io.ErrUnexpectedEOF
}
// don't track unrecognized data
//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
// m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func visitBackIndexRowFieldTerms(data []byte, callback backIndexFieldTermVisitor
if postIndex > l {
return io.ErrUnexpectedEOF
}
//m.Terms = append(m.Terms, string(data[iNdEx:postIndex]))
// m.Terms = append(m.Terms, string(data[iNdEx:postIndex]))
callback(theField, data[iNdEx:postIndex])
iNdEx = postIndex
default:
Expand All @@ -1132,7 +1132,7 @@ func visitBackIndexRowFieldTerms(data []byte, callback backIndexFieldTermVisitor
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
// m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
iNdEx += skippy
}
}
Expand Down
7 changes: 2 additions & 5 deletions search/query/regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ func (q *RegexpQuery) Searcher(ctx context.Context, i index.IndexReader, m mappi
// known to interfere with LiteralPrefix() the way ^ does
// and removing $ introduces possible ambiguities with escaped \$, \\$, etc
actualRegexp := q.Regexp
if strings.HasPrefix(actualRegexp, "^") {
actualRegexp = actualRegexp[1:] // remove leading ^
}
actualRegexp = strings.TrimPrefix(actualRegexp, "^") // remove leading ^ if it exists

return searcher.NewRegexpStringSearcher(ctx, i, actualRegexp, field,
q.BoostVal.Value(), options)
return searcher.NewRegexpStringSearcher(ctx, i, actualRegexp, field, q.BoostVal.Value(), options)
}

func (q *RegexpQuery) Validate() error {
Expand Down
7 changes: 3 additions & 4 deletions search/searcher/search_conjunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ type ConjunctionSearcher struct {

func NewConjunctionSearcher(ctx context.Context, indexReader index.IndexReader,
qsearchers []search.Searcher, options search.SearcherOptions) (
search.Searcher, error) {
search.Searcher, error,
) {
// build the sorted downstream searchers
searchers := make(OrderedSearcherList, len(qsearchers))
for i, searcher := range qsearchers {
searchers[i] = searcher
}
copy(searchers, qsearchers)
sort.Sort(searchers)

// attempt the "unadorned" conjunction optimization only when we
Expand Down
16 changes: 9 additions & 7 deletions search/searcher/search_disjunction_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ type DisjunctionSliceSearcher struct {
func newDisjunctionSliceSearcher(ctx context.Context, indexReader index.IndexReader,
qsearchers []search.Searcher, min float64, options search.SearcherOptions,
limit bool) (
*DisjunctionSliceSearcher, error) {
*DisjunctionSliceSearcher, error,
) {
if limit && tooManyClauses(len(qsearchers)) {
return nil, tooManyClausesErr("", len(qsearchers))
}
Expand All @@ -79,9 +80,7 @@ func newDisjunctionSliceSearcher(ctx context.Context, indexReader index.IndexRea
originalPos = sortedSearchers.index
} else {
searchers = make(OrderedSearcherList, len(qsearchers))
for i, searcher := range qsearchers {
searchers[i] = searcher
}
copy(searchers, qsearchers)
sort.Sort(searchers)
}

Expand Down Expand Up @@ -210,7 +209,8 @@ func (s *DisjunctionSliceSearcher) SetQueryNorm(qnorm float64) {
}

func (s *DisjunctionSliceSearcher) Next(ctx *search.SearchContext) (
*search.DocumentMatch, error) {
*search.DocumentMatch, error,
) {
if !s.initialized {
err := s.initSearchers(ctx)
if err != nil {
Expand Down Expand Up @@ -255,7 +255,8 @@ func (s *DisjunctionSliceSearcher) Next(ctx *search.SearchContext) (
}

func (s *DisjunctionSliceSearcher) Advance(ctx *search.SearchContext,
ID index.IndexInternalID) (*search.DocumentMatch, error) {
ID index.IndexInternalID,
) (*search.DocumentMatch, error) {
if !s.initialized {
err := s.initSearchers(ctx)
if err != nil {
Expand Down Expand Up @@ -320,7 +321,8 @@ func (s *DisjunctionSliceSearcher) DocumentMatchPoolSize() int {
// but only activates on an edge case where the disjunction is a
// wrapper around a single Optimizable child searcher
func (s *DisjunctionSliceSearcher) Optimize(kind string, octx index.OptimizableContext) (
index.OptimizableContext, error) {
index.OptimizableContext, error,
) {
if len(s.searchers) == 1 {
o, ok := s.searchers[0].(index.Optimizable)
if ok {
Expand Down
14 changes: 11 additions & 3 deletions search/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import (
"github.com/blevesearch/bleve/v2/util"
)

var HighTerm = strings.Repeat(string(utf8.MaxRune), 3)
var LowTerm = string([]byte{0x00})
var (
HighTerm = strings.Repeat(string(utf8.MaxRune), 3)
LowTerm = string([]byte{0x00})
)

type SearchSort interface {
UpdateVisitor(field string, term []byte)
Expand All @@ -47,10 +49,15 @@ type SearchSort interface {

func ParseSearchSortObj(input map[string]interface{}) (SearchSort, error) {
descending, ok := input["desc"].(bool)
if !ok {
descending = false
}

by, ok := input["by"].(string)
if !ok {
return nil, fmt.Errorf("search sort must specify by")
}

switch by {
case "id":
return &SortDocID{
Expand Down Expand Up @@ -612,7 +619,8 @@ var maxDistance = string(numeric.MustNewPrefixCodedInt64(math.MaxInt64, 0))
// NewSortGeoDistance creates SearchSort instance for sorting documents by
// their distance from the specified point.
func NewSortGeoDistance(field, unit string, lon, lat float64, desc bool) (
*SortGeoDistance, error) {
*SortGeoDistance, error,
) {
rv := &SortGeoDistance{
Field: field,
Desc: desc,
Expand Down
Loading