Skip to content

Commit

Permalink
switch default index to scorch with latest zap (#1528)
Browse files Browse the repository at this point in the history
one example required updating as it's custom sort contained a
tie (both fields with age 0).  upsidedown always returned the
results in a particular order, which was not guaranteed by scorch.
to address this, the exmaple has been updated to include the
doc id as an additional sort criteria (ensuring the original
order expected is kept by scorch)
  • Loading branch information
mschoch authored Dec 22, 2020
1 parent a6e5e07 commit 44887af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
7 changes: 2 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ import (
"log"
"time"

"github.com/blevesearch/bleve/index/scorch"
"github.com/blevesearch/bleve/index/upsidedown/store/gtreap"
"github.com/blevesearch/bleve/index/upsidedown"
"github.com/blevesearch/bleve/registry"
"github.com/blevesearch/bleve/search/highlight/highlighter/html"
index "github.com/blevesearch/bleve_index_api"

// force import of scorch so its accessible by default
_ "github.com/blevesearch/bleve/index/scorch"
)

var bleveExpVar = expvar.NewMap("bleve")
Expand Down Expand Up @@ -79,7 +76,7 @@ func init() {
Config.DefaultMemKVStore = gtreap.Name

// default index
Config.DefaultIndexType = upsidedown.Name
Config.DefaultIndexType = scorch.Name

bootDuration := time.Since(bootStart)
bleveExpVar.Add("bootDuration", int64(bootDuration))
Expand Down
1 change: 1 addition & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ func ExampleSearchRequest_SortByCustom() {
Field: "Age",
Missing: search.SortFieldMissingFirst,
},
&search.SortDocID{},
})
searchResults, err := exampleIndex.Search(searchRequest)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package bleve

import (
"context"
"github.com/blevesearch/bleve/index/upsidedown"

"github.com/blevesearch/bleve/document"
"github.com/blevesearch/bleve/mapping"
Expand Down Expand Up @@ -261,7 +262,7 @@ func New(path string, mapping mapping.IndexMapping) (Index, error) {
// The provided mapping will be used for all
// Index/Search operations.
func NewMemOnly(mapping mapping.IndexMapping) (Index, error) {
return newIndexUsing("", mapping, Config.DefaultIndexType, Config.DefaultMemKVStore, nil)
return newIndexUsing("", mapping, upsidedown.Name, Config.DefaultMemKVStore, nil)
}

// NewUsing creates index at the specified path,
Expand Down
4 changes: 2 additions & 2 deletions index/scorch/segment_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ var defaultSegmentPlugin SegmentPlugin

func init() {
ResetSegmentPlugins()
RegisterSegmentPlugin(&zapv15.ZapPlugin{}, false)
RegisterSegmentPlugin(&zapv15.ZapPlugin{}, true)
RegisterSegmentPlugin(&zapv14.ZapPlugin{}, false)
RegisterSegmentPlugin(&zapv13.ZapPlugin{}, false)
RegisterSegmentPlugin(&zapv12.ZapPlugin{}, false)
RegisterSegmentPlugin(&zapv11.ZapPlugin{}, true)
RegisterSegmentPlugin(&zapv11.ZapPlugin{}, false)
}

func ResetSegmentPlugins() {
Expand Down

0 comments on commit 44887af

Please sign in to comment.