diff --git a/analysis/analyzer/custom/custom.go b/analysis/analyzer/custom/custom.go index bcd4d42db..70e7a2699 100644 --- a/analysis/analyzer/custom/custom.go +++ b/analysis/analyzer/custom/custom.go @@ -17,8 +17,8 @@ package custom import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "custom" diff --git a/analysis/analyzer/keyword/keyword.go b/analysis/analyzer/keyword/keyword.go index 2a6c1aff7..473c29471 100644 --- a/analysis/analyzer/keyword/keyword.go +++ b/analysis/analyzer/keyword/keyword.go @@ -15,9 +15,9 @@ package keyword import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/single" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/single" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "keyword" diff --git a/analysis/analyzer/simple/simple.go b/analysis/analyzer/simple/simple.go index f8cf95066..46a715c2b 100644 --- a/analysis/analyzer/simple/simple.go +++ b/analysis/analyzer/simple/simple.go @@ -15,10 +15,10 @@ package simple import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/letter" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/letter" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "simple" diff --git a/analysis/analyzer/standard/standard.go b/analysis/analyzer/standard/standard.go index 74ea564ea..80a481be0 100644 --- a/analysis/analyzer/standard/standard.go +++ b/analysis/analyzer/standard/standard.go @@ -15,11 +15,11 @@ package standard import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/lang/en" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/lang/en" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "standard" diff --git a/analysis/analyzer/web/web.go b/analysis/analyzer/web/web.go index 3d597ba03..5d4145bd1 100644 --- a/analysis/analyzer/web/web.go +++ b/analysis/analyzer/web/web.go @@ -15,11 +15,11 @@ package web import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/lang/en" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/web" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/lang/en" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/web" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "web" diff --git a/analysis/benchmark_test.go b/analysis/benchmark_test.go index 4ff00e00a..c5b6647aa 100644 --- a/analysis/benchmark_test.go +++ b/analysis/benchmark_test.go @@ -15,11 +15,12 @@ package analysis_test import ( + index "github.com/blevesearch/bleve_index_api" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + "github.com/blevesearch/bleve/v2/registry" ) func BenchmarkAnalysis(b *testing.B) { @@ -32,7 +33,7 @@ func BenchmarkAnalysis(b *testing.B) { } ts := analyzer.Analyze(bleveWikiArticle) - freqs := analysis.TokenFrequency(ts, nil, true) + freqs := analysis.TokenFrequency(ts, nil, index.IncludeTermVectors) if len(freqs) != 511 { b.Errorf("expected %d freqs, got %d", 511, len(freqs)) } diff --git a/analysis/char/asciifolding/asciifolding.go b/analysis/char/asciifolding/asciifolding.go index facce07e1..4b422aed8 100644 --- a/analysis/char/asciifolding/asciifolding.go +++ b/analysis/char/asciifolding/asciifolding.go @@ -18,8 +18,8 @@ package asciifolding import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "asciifolding" diff --git a/analysis/char/html/html.go b/analysis/char/html/html.go index a16677b06..922edef3e 100644 --- a/analysis/char/html/html.go +++ b/analysis/char/html/html.go @@ -17,9 +17,9 @@ package html import ( "regexp" - "github.com/blevesearch/bleve/analysis" - regexpCharFilter "github.com/blevesearch/bleve/analysis/char/regexp" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + regexpCharFilter "github.com/blevesearch/bleve/v2/analysis/char/regexp" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "html" diff --git a/analysis/char/regexp/regexp.go b/analysis/char/regexp/regexp.go index fc344b312..b645322d5 100644 --- a/analysis/char/regexp/regexp.go +++ b/analysis/char/regexp/regexp.go @@ -18,8 +18,8 @@ import ( "fmt" "regexp" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "regexp" diff --git a/analysis/char/zerowidthnonjoiner/zerowidthnonjoiner.go b/analysis/char/zerowidthnonjoiner/zerowidthnonjoiner.go index 8d160d7ac..991f90918 100644 --- a/analysis/char/zerowidthnonjoiner/zerowidthnonjoiner.go +++ b/analysis/char/zerowidthnonjoiner/zerowidthnonjoiner.go @@ -17,9 +17,9 @@ package zerowidthnonjoiner import ( "regexp" - "github.com/blevesearch/bleve/analysis" - regexpCharFilter "github.com/blevesearch/bleve/analysis/char/regexp" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + regexpCharFilter "github.com/blevesearch/bleve/v2/analysis/char/regexp" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "zero_width_spaces" diff --git a/analysis/datetime/flexible/flexible.go b/analysis/datetime/flexible/flexible.go index cd549f55f..0eba074cd 100644 --- a/analysis/datetime/flexible/flexible.go +++ b/analysis/datetime/flexible/flexible.go @@ -18,8 +18,8 @@ import ( "fmt" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "flexiblego" diff --git a/analysis/datetime/flexible/flexible_test.go b/analysis/datetime/flexible/flexible_test.go index 644d91eb0..e4d1d5dc1 100644 --- a/analysis/datetime/flexible/flexible_test.go +++ b/analysis/datetime/flexible/flexible_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestFlexibleDateTimeParser(t *testing.T) { diff --git a/analysis/datetime/optional/optional.go b/analysis/datetime/optional/optional.go index 4b98de666..196aa25cb 100644 --- a/analysis/datetime/optional/optional.go +++ b/analysis/datetime/optional/optional.go @@ -17,9 +17,9 @@ package optional import ( "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/datetime/flexible" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/datetime/flexible" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "dateTimeOptional" diff --git a/analysis/freq.go b/analysis/freq.go index 198c149b2..a0fd1a416 100644 --- a/analysis/freq.go +++ b/analysis/freq.go @@ -15,105 +15,18 @@ package analysis import ( - "reflect" - - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" ) -var reflectStaticSizeTokenLocation int -var reflectStaticSizeTokenFreq int - -func init() { - var tl TokenLocation - reflectStaticSizeTokenLocation = int(reflect.TypeOf(tl).Size()) - var tf TokenFreq - reflectStaticSizeTokenFreq = int(reflect.TypeOf(tf).Size()) -} - -// TokenLocation represents one occurrence of a term at a particular location in -// a field. Start, End and Position have the same meaning as in analysis.Token. -// Field and ArrayPositions identify the field value in the source document. -// See document.Field for details. -type TokenLocation struct { - Field string - ArrayPositions []uint64 - Start int - End int - Position int -} - -func (tl *TokenLocation) Size() int { - rv := reflectStaticSizeTokenLocation - rv += len(tl.ArrayPositions) * size.SizeOfUint64 - return rv -} - -// TokenFreq represents all the occurrences of a term in all fields of a -// document. -type TokenFreq struct { - Term []byte - Locations []*TokenLocation - frequency int -} - -func (tf *TokenFreq) Size() int { - rv := reflectStaticSizeTokenFreq - rv += len(tf.Term) - for _, loc := range tf.Locations { - rv += loc.Size() - } - return rv -} - -func (tf *TokenFreq) Frequency() int { - return tf.frequency -} - -// TokenFrequencies maps document terms to their combined frequencies from all -// fields. -type TokenFrequencies map[string]*TokenFreq +func TokenFrequency(tokens TokenStream, arrayPositions []uint64, options index.FieldIndexingOptions) index.TokenFrequencies { + rv := make(map[string]*index.TokenFreq, len(tokens)) -func (tfs TokenFrequencies) Size() int { - rv := size.SizeOfMap - rv += len(tfs) * (size.SizeOfString + size.SizeOfPtr) - for k, v := range tfs { - rv += len(k) - rv += v.Size() - } - return rv -} - -func (tfs TokenFrequencies) MergeAll(remoteField string, other TokenFrequencies) { - // walk the new token frequencies - for tfk, tf := range other { - // set the remoteField value in incoming token freqs - for _, l := range tf.Locations { - l.Field = remoteField - } - existingTf, exists := tfs[tfk] - if exists { - existingTf.Locations = append(existingTf.Locations, tf.Locations...) - existingTf.frequency = existingTf.frequency + tf.frequency - } else { - tfs[tfk] = &TokenFreq{ - Term: tf.Term, - frequency: tf.frequency, - Locations: make([]*TokenLocation, len(tf.Locations)), - } - copy(tfs[tfk].Locations, tf.Locations) - } - } -} - -func TokenFrequency(tokens TokenStream, arrayPositions []uint64, includeTermVectors bool) TokenFrequencies { - rv := make(map[string]*TokenFreq, len(tokens)) - - if includeTermVectors { - tls := make([]TokenLocation, len(tokens)) + if options.IncludeTermVectors() { + tls := make([]index.TokenLocation, len(tokens)) tlNext := 0 for _, token := range tokens { - tls[tlNext] = TokenLocation{ + tls[tlNext] = index.TokenLocation{ ArrayPositions: arrayPositions, Start: token.Start, End: token.End, @@ -123,13 +36,16 @@ func TokenFrequency(tokens TokenStream, arrayPositions []uint64, includeTermVect curr, ok := rv[string(token.Term)] if ok { curr.Locations = append(curr.Locations, &tls[tlNext]) - curr.frequency++ } else { - rv[string(token.Term)] = &TokenFreq{ + curr = &index.TokenFreq{ Term: token.Term, - Locations: []*TokenLocation{&tls[tlNext]}, - frequency: 1, + Locations: []*index.TokenLocation{&tls[tlNext]}, } + rv[string(token.Term)] = curr + } + + if !options.SkipFreqNorm() { + curr.SetFrequency(curr.Frequency() + 1) } tlNext++ @@ -137,13 +53,15 @@ func TokenFrequency(tokens TokenStream, arrayPositions []uint64, includeTermVect } else { for _, token := range tokens { curr, exists := rv[string(token.Term)] - if exists { - curr.frequency++ - } else { - rv[string(token.Term)] = &TokenFreq{ - Term: token.Term, - frequency: 1, + if !exists { + curr = &index.TokenFreq{ + Term: token.Term, } + rv[string(token.Term)] = curr + } + + if !options.SkipFreqNorm() { + curr.SetFrequency(curr.Frequency() + 1) } } } diff --git a/analysis/freq_test.go b/analysis/freq_test.go index 36dce23c7..724ff4546 100644 --- a/analysis/freq_test.go +++ b/analysis/freq_test.go @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. + package analysis import ( + index "github.com/blevesearch/bleve_index_api" "reflect" "testing" ) @@ -34,10 +36,10 @@ func TestTokenFrequency(t *testing.T) { End: 11, }, } - expectedResult := TokenFrequencies{ - "water": &TokenFreq{ + expectedResult := index.TokenFrequencies{ + "water": &index.TokenFreq{ Term: []byte("water"), - Locations: []*TokenLocation{ + Locations: []*index.TokenLocation{ { Position: 1, Start: 0, @@ -49,125 +51,11 @@ func TestTokenFrequency(t *testing.T) { End: 11, }, }, - frequency: 2, }, } - result := TokenFrequency(tokens, nil, true) + expectedResult["water"].SetFrequency(2) + result := TokenFrequency(tokens, nil, index.IncludeTermVectors) if !reflect.DeepEqual(result, expectedResult) { t.Errorf("expected %#v, got %#v", expectedResult, result) } } - -func TestTokenFrequenciesMergeAll(t *testing.T) { - tf1 := TokenFrequencies{ - "water": &TokenFreq{ - Term: []byte("water"), - Locations: []*TokenLocation{ - { - Position: 1, - Start: 0, - End: 5, - }, - { - Position: 2, - Start: 6, - End: 11, - }, - }, - }, - } - tf2 := TokenFrequencies{ - "water": &TokenFreq{ - Term: []byte("water"), - Locations: []*TokenLocation{ - { - Position: 1, - Start: 0, - End: 5, - }, - { - Position: 2, - Start: 6, - End: 11, - }, - }, - }, - } - expectedResult := TokenFrequencies{ - "water": &TokenFreq{ - Term: []byte("water"), - Locations: []*TokenLocation{ - { - Position: 1, - Start: 0, - End: 5, - }, - { - Position: 2, - Start: 6, - End: 11, - }, - { - Field: "tf2", - Position: 1, - Start: 0, - End: 5, - }, - { - Field: "tf2", - Position: 2, - Start: 6, - End: 11, - }, - }, - }, - } - tf1.MergeAll("tf2", tf2) - if !reflect.DeepEqual(tf1, expectedResult) { - t.Errorf("expected %#v, got %#v", expectedResult, tf1) - } -} - -func TestTokenFrequenciesMergeAllLeftEmpty(t *testing.T) { - tf1 := TokenFrequencies{} - tf2 := TokenFrequencies{ - "water": &TokenFreq{ - Term: []byte("water"), - Locations: []*TokenLocation{ - { - Position: 1, - Start: 0, - End: 5, - }, - { - Position: 2, - Start: 6, - End: 11, - }, - }, - }, - } - expectedResult := TokenFrequencies{ - "water": &TokenFreq{ - Term: []byte("water"), - Locations: []*TokenLocation{ - { - Field: "tf2", - Position: 1, - Start: 0, - End: 5, - }, - { - Field: "tf2", - Position: 2, - Start: 6, - End: 11, - }, - }, - }, - } - tf1.MergeAll("tf2", tf2) - if !reflect.DeepEqual(tf1, expectedResult) { - t.Errorf("expected %#v, got %#v", expectedResult, tf1) - } -} diff --git a/analysis/lang/ar/analyzer_ar.go b/analysis/lang/ar/analyzer_ar.go index 29132a697..e6f1f8f30 100644 --- a/analysis/lang/ar/analyzer_ar.go +++ b/analysis/lang/ar/analyzer_ar.go @@ -15,12 +15,12 @@ package ar import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/token/unicodenorm" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/token/unicodenorm" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "ar" diff --git a/analysis/lang/ar/analyzer_ar_test.go b/analysis/lang/ar/analyzer_ar_test.go index 13b66e2a3..437d69fd9 100644 --- a/analysis/lang/ar/analyzer_ar_test.go +++ b/analysis/lang/ar/analyzer_ar_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestArabicAnalyzer(t *testing.T) { diff --git a/analysis/lang/ar/arabic_normalize.go b/analysis/lang/ar/arabic_normalize.go index 50829397d..8fdb89904 100644 --- a/analysis/lang/ar/arabic_normalize.go +++ b/analysis/lang/ar/arabic_normalize.go @@ -17,8 +17,8 @@ package ar import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_ar" diff --git a/analysis/lang/ar/arabic_normalize_test.go b/analysis/lang/ar/arabic_normalize_test.go index 9a313acdf..e3f472ee9 100644 --- a/analysis/lang/ar/arabic_normalize_test.go +++ b/analysis/lang/ar/arabic_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestArabicNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/ar/stemmer_ar.go b/analysis/lang/ar/stemmer_ar.go index 5165cf06c..d4540e1dd 100644 --- a/analysis/lang/ar/stemmer_ar.go +++ b/analysis/lang/ar/stemmer_ar.go @@ -17,8 +17,8 @@ package ar import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StemmerName = "stemmer_ar" diff --git a/analysis/lang/ar/stemmer_ar_test.go b/analysis/lang/ar/stemmer_ar_test.go index ff8f89c0b..dfc1e82ca 100644 --- a/analysis/lang/ar/stemmer_ar_test.go +++ b/analysis/lang/ar/stemmer_ar_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestArabicStemmerFilter(t *testing.T) { diff --git a/analysis/lang/ar/stop_filter_ar.go b/analysis/lang/ar/stop_filter_ar.go index cb532e605..d8af36022 100644 --- a/analysis/lang/ar/stop_filter_ar.go +++ b/analysis/lang/ar/stop_filter_ar.go @@ -15,9 +15,9 @@ package ar import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ar/stop_words_ar.go b/analysis/lang/ar/stop_words_ar.go index 09e9a5997..2d1bd56d6 100644 --- a/analysis/lang/ar/stop_words_ar.go +++ b/analysis/lang/ar/stop_words_ar.go @@ -1,8 +1,8 @@ package ar import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ar" diff --git a/analysis/lang/bg/stop_filter_bg.go b/analysis/lang/bg/stop_filter_bg.go index 821210c92..97bbabe14 100644 --- a/analysis/lang/bg/stop_filter_bg.go +++ b/analysis/lang/bg/stop_filter_bg.go @@ -15,9 +15,9 @@ package bg import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/bg/stop_words_bg.go b/analysis/lang/bg/stop_words_bg.go index a063ed9ab..0bddc22ce 100644 --- a/analysis/lang/bg/stop_words_bg.go +++ b/analysis/lang/bg/stop_words_bg.go @@ -1,8 +1,8 @@ package bg import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_bg" diff --git a/analysis/lang/ca/articles_ca.go b/analysis/lang/ca/articles_ca.go index 7d52cb165..09308f39f 100644 --- a/analysis/lang/ca/articles_ca.go +++ b/analysis/lang/ca/articles_ca.go @@ -1,8 +1,8 @@ package ca import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const ArticlesName = "articles_ca" diff --git a/analysis/lang/ca/elision_ca.go b/analysis/lang/ca/elision_ca.go index 201da0c78..46ee3c622 100644 --- a/analysis/lang/ca/elision_ca.go +++ b/analysis/lang/ca/elision_ca.go @@ -17,9 +17,9 @@ package ca import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/elision" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/elision" + "github.com/blevesearch/bleve/v2/registry" ) const ElisionName = "elision_ca" diff --git a/analysis/lang/ca/elision_ca_test.go b/analysis/lang/ca/elision_ca_test.go index 79a1be4ce..2a9d6a581 100644 --- a/analysis/lang/ca/elision_ca_test.go +++ b/analysis/lang/ca/elision_ca_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchElision(t *testing.T) { diff --git a/analysis/lang/ca/stop_filter_ca.go b/analysis/lang/ca/stop_filter_ca.go index 99f72da0f..2864a4267 100644 --- a/analysis/lang/ca/stop_filter_ca.go +++ b/analysis/lang/ca/stop_filter_ca.go @@ -15,9 +15,9 @@ package ca import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ca/stop_words_ca.go b/analysis/lang/ca/stop_words_ca.go index d88dfc316..93621df1f 100644 --- a/analysis/lang/ca/stop_words_ca.go +++ b/analysis/lang/ca/stop_words_ca.go @@ -1,8 +1,8 @@ package ca import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ca" diff --git a/analysis/lang/cjk/analyzer_cjk.go b/analysis/lang/cjk/analyzer_cjk.go index 5ea0661c2..d7c1142cf 100644 --- a/analysis/lang/cjk/analyzer_cjk.go +++ b/analysis/lang/cjk/analyzer_cjk.go @@ -15,11 +15,11 @@ package cjk import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "cjk" diff --git a/analysis/lang/cjk/analyzer_cjk_test.go b/analysis/lang/cjk/analyzer_cjk_test.go index b402ed783..afd895788 100644 --- a/analysis/lang/cjk/analyzer_cjk_test.go +++ b/analysis/lang/cjk/analyzer_cjk_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestCJKAnalyzer(t *testing.T) { diff --git a/analysis/lang/cjk/cjk_bigram.go b/analysis/lang/cjk/cjk_bigram.go index 8851e0c0f..fcb80151d 100644 --- a/analysis/lang/cjk/cjk_bigram.go +++ b/analysis/lang/cjk/cjk_bigram.go @@ -19,8 +19,8 @@ import ( "container/ring" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const BigramName = "cjk_bigram" diff --git a/analysis/lang/cjk/cjk_bigram_test.go b/analysis/lang/cjk/cjk_bigram_test.go index 9f5eff08f..d1b5d0008 100644 --- a/analysis/lang/cjk/cjk_bigram_test.go +++ b/analysis/lang/cjk/cjk_bigram_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestCJKBigramFilter(t *testing.T) { diff --git a/analysis/lang/cjk/cjk_width.go b/analysis/lang/cjk/cjk_width.go index 7191ea533..d5b15e74c 100644 --- a/analysis/lang/cjk/cjk_width.go +++ b/analysis/lang/cjk/cjk_width.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const WidthName = "cjk_width" diff --git a/analysis/lang/cjk/cjk_width_test.go b/analysis/lang/cjk/cjk_width_test.go index c0d4e2902..5533ae22f 100644 --- a/analysis/lang/cjk/cjk_width_test.go +++ b/analysis/lang/cjk/cjk_width_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestCJKWidthFilter(t *testing.T) { diff --git a/analysis/lang/ckb/analyzer_ckb.go b/analysis/lang/ckb/analyzer_ckb.go index da3d804e0..a71b0f82a 100644 --- a/analysis/lang/ckb/analyzer_ckb.go +++ b/analysis/lang/ckb/analyzer_ckb.go @@ -15,10 +15,10 @@ package ckb import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) const AnalyzerName = "ckb" diff --git a/analysis/lang/ckb/analyzer_ckb_test.go b/analysis/lang/ckb/analyzer_ckb_test.go index 666a30129..9e6adab8e 100644 --- a/analysis/lang/ckb/analyzer_ckb_test.go +++ b/analysis/lang/ckb/analyzer_ckb_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSoraniAnalyzer(t *testing.T) { diff --git a/analysis/lang/ckb/sorani_normalize.go b/analysis/lang/ckb/sorani_normalize.go index f64cedf53..a1d6d7378 100644 --- a/analysis/lang/ckb/sorani_normalize.go +++ b/analysis/lang/ckb/sorani_normalize.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_ckb" diff --git a/analysis/lang/ckb/sorani_normalize_test.go b/analysis/lang/ckb/sorani_normalize_test.go index fe10a5cb2..0fb0fcd60 100644 --- a/analysis/lang/ckb/sorani_normalize_test.go +++ b/analysis/lang/ckb/sorani_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestSoraniNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/ckb/sorani_stemmer_filter.go b/analysis/lang/ckb/sorani_stemmer_filter.go index 41787314c..c96b0a1b3 100644 --- a/analysis/lang/ckb/sorani_stemmer_filter.go +++ b/analysis/lang/ckb/sorani_stemmer_filter.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StemmerName = "stemmer_ckb" diff --git a/analysis/lang/ckb/sorani_stemmer_filter_test.go b/analysis/lang/ckb/sorani_stemmer_filter_test.go index e6dd7b177..c0d847c47 100644 --- a/analysis/lang/ckb/sorani_stemmer_filter_test.go +++ b/analysis/lang/ckb/sorani_stemmer_filter_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/single" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/single" ) func TestSoraniStemmerFilter(t *testing.T) { diff --git a/analysis/lang/ckb/stop_filter_ckb.go b/analysis/lang/ckb/stop_filter_ckb.go index a6ea259f3..7584935db 100644 --- a/analysis/lang/ckb/stop_filter_ckb.go +++ b/analysis/lang/ckb/stop_filter_ckb.go @@ -15,9 +15,9 @@ package ckb import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ckb/stop_words_ckb.go b/analysis/lang/ckb/stop_words_ckb.go index 707a3b167..e82b6a586 100644 --- a/analysis/lang/ckb/stop_words_ckb.go +++ b/analysis/lang/ckb/stop_words_ckb.go @@ -1,8 +1,8 @@ package ckb import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ckb" diff --git a/analysis/lang/cs/stop_filter_cs.go b/analysis/lang/cs/stop_filter_cs.go index 2267cea73..b63b7a040 100644 --- a/analysis/lang/cs/stop_filter_cs.go +++ b/analysis/lang/cs/stop_filter_cs.go @@ -15,9 +15,9 @@ package cs import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/cs/stop_words_cs.go b/analysis/lang/cs/stop_words_cs.go index 71f9c43ed..ad8ce9099 100644 --- a/analysis/lang/cs/stop_words_cs.go +++ b/analysis/lang/cs/stop_words_cs.go @@ -1,8 +1,8 @@ package cs import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_cs" diff --git a/analysis/lang/da/analyzer_da.go b/analysis/lang/da/analyzer_da.go index dca141779..5ee8428f3 100644 --- a/analysis/lang/da/analyzer_da.go +++ b/analysis/lang/da/analyzer_da.go @@ -15,10 +15,10 @@ package da import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) const AnalyzerName = "da" diff --git a/analysis/lang/da/analyzer_da_test.go b/analysis/lang/da/analyzer_da_test.go index d6a1c51a4..e22f32567 100644 --- a/analysis/lang/da/analyzer_da_test.go +++ b/analysis/lang/da/analyzer_da_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestDanishAnalyzer(t *testing.T) { diff --git a/analysis/lang/da/stemmer_da.go b/analysis/lang/da/stemmer_da.go index e40e623ab..ce09f33b7 100644 --- a/analysis/lang/da/stemmer_da.go +++ b/analysis/lang/da/stemmer_da.go @@ -15,8 +15,8 @@ package da import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/danish" diff --git a/analysis/lang/da/stop_filter_da.go b/analysis/lang/da/stop_filter_da.go index a146d0b43..e315491af 100644 --- a/analysis/lang/da/stop_filter_da.go +++ b/analysis/lang/da/stop_filter_da.go @@ -15,9 +15,9 @@ package da import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/da/stop_words_da.go b/analysis/lang/da/stop_words_da.go index 63a407a0c..39c5f6a03 100644 --- a/analysis/lang/da/stop_words_da.go +++ b/analysis/lang/da/stop_words_da.go @@ -1,8 +1,8 @@ package da import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_da" diff --git a/analysis/lang/de/analyzer_de.go b/analysis/lang/de/analyzer_de.go index dcf4e8e93..632ab8dfa 100644 --- a/analysis/lang/de/analyzer_de.go +++ b/analysis/lang/de/analyzer_de.go @@ -15,10 +15,10 @@ package de import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) const AnalyzerName = "de" diff --git a/analysis/lang/de/analyzer_de_test.go b/analysis/lang/de/analyzer_de_test.go index 18e2683b3..f404ded94 100644 --- a/analysis/lang/de/analyzer_de_test.go +++ b/analysis/lang/de/analyzer_de_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestGermanAnalyzer(t *testing.T) { diff --git a/analysis/lang/de/german_normalize.go b/analysis/lang/de/german_normalize.go index 370efcbec..84688f137 100644 --- a/analysis/lang/de/german_normalize.go +++ b/analysis/lang/de/german_normalize.go @@ -17,8 +17,8 @@ package de import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_de" diff --git a/analysis/lang/de/german_normalize_test.go b/analysis/lang/de/german_normalize_test.go index b95a7190e..81a60f5cc 100644 --- a/analysis/lang/de/german_normalize_test.go +++ b/analysis/lang/de/german_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestGermanNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/de/light_stemmer_de.go b/analysis/lang/de/light_stemmer_de.go index c1a093c5d..48bcf274d 100644 --- a/analysis/lang/de/light_stemmer_de.go +++ b/analysis/lang/de/light_stemmer_de.go @@ -17,8 +17,8 @@ package de import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const LightStemmerName = "stemmer_de_light" diff --git a/analysis/lang/de/stemmer_de_snowball.go b/analysis/lang/de/stemmer_de_snowball.go index efda0660b..35afdd96b 100644 --- a/analysis/lang/de/stemmer_de_snowball.go +++ b/analysis/lang/de/stemmer_de_snowball.go @@ -15,8 +15,8 @@ package de import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/german" diff --git a/analysis/lang/de/stemmer_de_test.go b/analysis/lang/de/stemmer_de_test.go index a319f7273..5810ec447 100644 --- a/analysis/lang/de/stemmer_de_test.go +++ b/analysis/lang/de/stemmer_de_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballGermanStemmer(t *testing.T) { diff --git a/analysis/lang/de/stop_filter_de.go b/analysis/lang/de/stop_filter_de.go index bcc423f00..b97d1a185 100644 --- a/analysis/lang/de/stop_filter_de.go +++ b/analysis/lang/de/stop_filter_de.go @@ -15,9 +15,9 @@ package de import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/de/stop_words_de.go b/analysis/lang/de/stop_words_de.go index b71c8f70b..83ea0b557 100644 --- a/analysis/lang/de/stop_words_de.go +++ b/analysis/lang/de/stop_words_de.go @@ -1,8 +1,8 @@ package de import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_de" diff --git a/analysis/lang/el/stop_filter_el.go b/analysis/lang/el/stop_filter_el.go index 652b8cb73..17bfd9f27 100644 --- a/analysis/lang/el/stop_filter_el.go +++ b/analysis/lang/el/stop_filter_el.go @@ -15,9 +15,9 @@ package el import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/el/stop_words_el.go b/analysis/lang/el/stop_words_el.go index 10755d280..1e8455631 100644 --- a/analysis/lang/el/stop_words_el.go +++ b/analysis/lang/el/stop_words_el.go @@ -1,8 +1,8 @@ package el import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_el" diff --git a/analysis/lang/en/analyzer_en.go b/analysis/lang/en/analyzer_en.go index 8402785f2..7a4ae5866 100644 --- a/analysis/lang/en/analyzer_en.go +++ b/analysis/lang/en/analyzer_en.go @@ -22,12 +22,12 @@ package en import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/token/porter" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/token/porter" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "en" diff --git a/analysis/lang/en/analyzer_en_test.go b/analysis/lang/en/analyzer_en_test.go index 09ab7f251..6db7c3000 100644 --- a/analysis/lang/en/analyzer_en_test.go +++ b/analysis/lang/en/analyzer_en_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestEnglishAnalyzer(t *testing.T) { diff --git a/analysis/lang/en/possessive_filter_en.go b/analysis/lang/en/possessive_filter_en.go index 2c06efd67..79c2489e2 100644 --- a/analysis/lang/en/possessive_filter_en.go +++ b/analysis/lang/en/possessive_filter_en.go @@ -17,8 +17,8 @@ package en import ( "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) // PossessiveName is the name PossessiveFilter is registered as diff --git a/analysis/lang/en/possessive_filter_en_test.go b/analysis/lang/en/possessive_filter_en_test.go index 9a19a13d7..c45cfc942 100644 --- a/analysis/lang/en/possessive_filter_en_test.go +++ b/analysis/lang/en/possessive_filter_en_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestEnglishPossessiveFilter(t *testing.T) { diff --git a/analysis/lang/en/stemmer_en_snowball.go b/analysis/lang/en/stemmer_en_snowball.go index 225bb0664..ab30b8b19 100644 --- a/analysis/lang/en/stemmer_en_snowball.go +++ b/analysis/lang/en/stemmer_en_snowball.go @@ -15,8 +15,8 @@ package en import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/english" diff --git a/analysis/lang/en/stemmer_en_test.go b/analysis/lang/en/stemmer_en_test.go index bc5016d07..7435d9895 100644 --- a/analysis/lang/en/stemmer_en_test.go +++ b/analysis/lang/en/stemmer_en_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballEnglishStemmer(t *testing.T) { diff --git a/analysis/lang/en/stop_filter_en.go b/analysis/lang/en/stop_filter_en.go index bfdb2c972..a3f91d226 100644 --- a/analysis/lang/en/stop_filter_en.go +++ b/analysis/lang/en/stop_filter_en.go @@ -15,9 +15,9 @@ package en import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/en/stop_words_en.go b/analysis/lang/en/stop_words_en.go index 6423cf2cb..9b6ca86a7 100644 --- a/analysis/lang/en/stop_words_en.go +++ b/analysis/lang/en/stop_words_en.go @@ -1,8 +1,8 @@ package en import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_en" diff --git a/analysis/lang/es/analyzer_es.go b/analysis/lang/es/analyzer_es.go index 8a3156a11..a260aae69 100644 --- a/analysis/lang/es/analyzer_es.go +++ b/analysis/lang/es/analyzer_es.go @@ -15,11 +15,11 @@ package es import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "es" diff --git a/analysis/lang/es/analyzer_es_test.go b/analysis/lang/es/analyzer_es_test.go index bb21c6766..ad3b1f650 100644 --- a/analysis/lang/es/analyzer_es_test.go +++ b/analysis/lang/es/analyzer_es_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSpanishAnalyzer(t *testing.T) { diff --git a/analysis/lang/es/light_stemmer_es.go b/analysis/lang/es/light_stemmer_es.go index 1dafdf91f..c1b4749ea 100644 --- a/analysis/lang/es/light_stemmer_es.go +++ b/analysis/lang/es/light_stemmer_es.go @@ -17,8 +17,8 @@ package es import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const LightStemmerName = "stemmer_es_light" diff --git a/analysis/lang/es/stemmer_es_snowball.go b/analysis/lang/es/stemmer_es_snowball.go index 9ee768a9d..883392856 100644 --- a/analysis/lang/es/stemmer_es_snowball.go +++ b/analysis/lang/es/stemmer_es_snowball.go @@ -15,8 +15,8 @@ package es import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/spanish" diff --git a/analysis/lang/es/stemmer_es_snowball_test.go b/analysis/lang/es/stemmer_es_snowball_test.go index d976fc821..053186584 100644 --- a/analysis/lang/es/stemmer_es_snowball_test.go +++ b/analysis/lang/es/stemmer_es_snowball_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballSpanishStemmer(t *testing.T) { diff --git a/analysis/lang/es/stop_filter_es.go b/analysis/lang/es/stop_filter_es.go index df3d44342..5c6639414 100644 --- a/analysis/lang/es/stop_filter_es.go +++ b/analysis/lang/es/stop_filter_es.go @@ -14,9 +14,9 @@ package es import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, diff --git a/analysis/lang/es/stop_words_es.go b/analysis/lang/es/stop_words_es.go index b699daf4f..0f1e51d93 100644 --- a/analysis/lang/es/stop_words_es.go +++ b/analysis/lang/es/stop_words_es.go @@ -1,8 +1,8 @@ package es import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_es" diff --git a/analysis/lang/eu/stop_filter_eu.go b/analysis/lang/eu/stop_filter_eu.go index 31521317c..03eb549b2 100644 --- a/analysis/lang/eu/stop_filter_eu.go +++ b/analysis/lang/eu/stop_filter_eu.go @@ -15,9 +15,9 @@ package eu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/eu/stop_words_eu.go b/analysis/lang/eu/stop_words_eu.go index dcb3f7b39..7a24efc9b 100644 --- a/analysis/lang/eu/stop_words_eu.go +++ b/analysis/lang/eu/stop_words_eu.go @@ -1,8 +1,8 @@ package eu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_eu" diff --git a/analysis/lang/fa/analyzer_fa.go b/analysis/lang/fa/analyzer_fa.go index d76dc0a5f..8dcf9d514 100644 --- a/analysis/lang/fa/analyzer_fa.go +++ b/analysis/lang/fa/analyzer_fa.go @@ -15,13 +15,13 @@ package fa import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/char/zerowidthnonjoiner" - "github.com/blevesearch/bleve/analysis/lang/ar" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/char/zerowidthnonjoiner" + "github.com/blevesearch/bleve/v2/analysis/lang/ar" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "fa" diff --git a/analysis/lang/fa/analyzer_fa_test.go b/analysis/lang/fa/analyzer_fa_test.go index 5529d6fed..f648261f9 100644 --- a/analysis/lang/fa/analyzer_fa_test.go +++ b/analysis/lang/fa/analyzer_fa_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestPersianAnalyzerVerbs(t *testing.T) { diff --git a/analysis/lang/fa/persian_normalize.go b/analysis/lang/fa/persian_normalize.go index 7230cbcfc..437bd435f 100644 --- a/analysis/lang/fa/persian_normalize.go +++ b/analysis/lang/fa/persian_normalize.go @@ -17,8 +17,8 @@ package fa import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_fa" diff --git a/analysis/lang/fa/persian_normalize_test.go b/analysis/lang/fa/persian_normalize_test.go index 720777992..4511cbaaf 100644 --- a/analysis/lang/fa/persian_normalize_test.go +++ b/analysis/lang/fa/persian_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestPersianNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/fa/stop_filter_fa.go b/analysis/lang/fa/stop_filter_fa.go index 6589b3248..0277a56a2 100644 --- a/analysis/lang/fa/stop_filter_fa.go +++ b/analysis/lang/fa/stop_filter_fa.go @@ -15,9 +15,9 @@ package fa import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/fa/stop_words_fa.go b/analysis/lang/fa/stop_words_fa.go index 0d8ce4099..624fd5271 100644 --- a/analysis/lang/fa/stop_words_fa.go +++ b/analysis/lang/fa/stop_words_fa.go @@ -1,8 +1,8 @@ package fa import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_fa" diff --git a/analysis/lang/fi/analyzer_fi.go b/analysis/lang/fi/analyzer_fi.go index 9482e6b36..5b73b0c90 100644 --- a/analysis/lang/fi/analyzer_fi.go +++ b/analysis/lang/fi/analyzer_fi.go @@ -15,11 +15,11 @@ package fi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "fi" diff --git a/analysis/lang/fi/analyzer_fi_test.go b/analysis/lang/fi/analyzer_fi_test.go index 035e7fdb5..45aa242de 100644 --- a/analysis/lang/fi/analyzer_fi_test.go +++ b/analysis/lang/fi/analyzer_fi_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFinishAnalyzer(t *testing.T) { diff --git a/analysis/lang/fi/stemmer_fi.go b/analysis/lang/fi/stemmer_fi.go index 14a6a1cbc..44d39020d 100644 --- a/analysis/lang/fi/stemmer_fi.go +++ b/analysis/lang/fi/stemmer_fi.go @@ -15,8 +15,8 @@ package fi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/finnish" diff --git a/analysis/lang/fi/stop_filter_fi.go b/analysis/lang/fi/stop_filter_fi.go index f3576a2be..0445d6942 100644 --- a/analysis/lang/fi/stop_filter_fi.go +++ b/analysis/lang/fi/stop_filter_fi.go @@ -15,9 +15,9 @@ package fi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/fi/stop_words_fi.go b/analysis/lang/fi/stop_words_fi.go index 7cf0c9c13..93824f4e2 100644 --- a/analysis/lang/fi/stop_words_fi.go +++ b/analysis/lang/fi/stop_words_fi.go @@ -1,8 +1,8 @@ package fi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_fi" diff --git a/analysis/lang/fr/analyzer_fr.go b/analysis/lang/fr/analyzer_fr.go index 9d9da1dd1..138eda8ae 100644 --- a/analysis/lang/fr/analyzer_fr.go +++ b/analysis/lang/fr/analyzer_fr.go @@ -15,11 +15,11 @@ package fr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "fr" diff --git a/analysis/lang/fr/analyzer_fr_test.go b/analysis/lang/fr/analyzer_fr_test.go index fe04bef6b..38f89e079 100644 --- a/analysis/lang/fr/analyzer_fr_test.go +++ b/analysis/lang/fr/analyzer_fr_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchAnalyzer(t *testing.T) { diff --git a/analysis/lang/fr/articles_fr.go b/analysis/lang/fr/articles_fr.go index 557409a2c..405729b81 100644 --- a/analysis/lang/fr/articles_fr.go +++ b/analysis/lang/fr/articles_fr.go @@ -1,8 +1,8 @@ package fr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const ArticlesName = "articles_fr" diff --git a/analysis/lang/fr/elision_fr.go b/analysis/lang/fr/elision_fr.go index 1663b6f14..739e2361f 100644 --- a/analysis/lang/fr/elision_fr.go +++ b/analysis/lang/fr/elision_fr.go @@ -17,9 +17,9 @@ package fr import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/elision" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/elision" + "github.com/blevesearch/bleve/v2/registry" ) const ElisionName = "elision_fr" diff --git a/analysis/lang/fr/elision_fr_test.go b/analysis/lang/fr/elision_fr_test.go index b940dd45e..19689ec66 100644 --- a/analysis/lang/fr/elision_fr_test.go +++ b/analysis/lang/fr/elision_fr_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchElision(t *testing.T) { diff --git a/analysis/lang/fr/light_stemmer_fr.go b/analysis/lang/fr/light_stemmer_fr.go index 6d13a22ab..d0e407641 100644 --- a/analysis/lang/fr/light_stemmer_fr.go +++ b/analysis/lang/fr/light_stemmer_fr.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const LightStemmerName = "stemmer_fr_light" diff --git a/analysis/lang/fr/light_stemmer_fr_test.go b/analysis/lang/fr/light_stemmer_fr_test.go index 45198cf56..a098b9702 100644 --- a/analysis/lang/fr/light_stemmer_fr_test.go +++ b/analysis/lang/fr/light_stemmer_fr_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchLightStemmer(t *testing.T) { diff --git a/analysis/lang/fr/minimal_stemmer_fr.go b/analysis/lang/fr/minimal_stemmer_fr.go index b76d6a891..93d954bf7 100644 --- a/analysis/lang/fr/minimal_stemmer_fr.go +++ b/analysis/lang/fr/minimal_stemmer_fr.go @@ -17,8 +17,8 @@ package fr import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const MinimalStemmerName = "stemmer_fr_min" diff --git a/analysis/lang/fr/minimal_stemmer_fr_test.go b/analysis/lang/fr/minimal_stemmer_fr_test.go index 6dc0c676c..fa17528f6 100644 --- a/analysis/lang/fr/minimal_stemmer_fr_test.go +++ b/analysis/lang/fr/minimal_stemmer_fr_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchMinimalStemmer(t *testing.T) { diff --git a/analysis/lang/fr/stemmer_fr_snowball.go b/analysis/lang/fr/stemmer_fr_snowball.go index e137ce211..275d66e96 100644 --- a/analysis/lang/fr/stemmer_fr_snowball.go +++ b/analysis/lang/fr/stemmer_fr_snowball.go @@ -15,8 +15,8 @@ package fr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/french" diff --git a/analysis/lang/fr/stemmer_fr_snowball_test.go b/analysis/lang/fr/stemmer_fr_snowball_test.go index aeafa4317..69e9f26c0 100644 --- a/analysis/lang/fr/stemmer_fr_snowball_test.go +++ b/analysis/lang/fr/stemmer_fr_snowball_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballFrenchStemmer(t *testing.T) { diff --git a/analysis/lang/fr/stop_filter_fr.go b/analysis/lang/fr/stop_filter_fr.go index fcacc4904..ac7abb10e 100644 --- a/analysis/lang/fr/stop_filter_fr.go +++ b/analysis/lang/fr/stop_filter_fr.go @@ -15,9 +15,9 @@ package fr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/fr/stop_words_fr.go b/analysis/lang/fr/stop_words_fr.go index f00266f00..c59757586 100644 --- a/analysis/lang/fr/stop_words_fr.go +++ b/analysis/lang/fr/stop_words_fr.go @@ -1,8 +1,8 @@ package fr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_fr" diff --git a/analysis/lang/ga/articles_ga.go b/analysis/lang/ga/articles_ga.go index 0b6863a62..4b859a563 100644 --- a/analysis/lang/ga/articles_ga.go +++ b/analysis/lang/ga/articles_ga.go @@ -1,8 +1,8 @@ package ga import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const ArticlesName = "articles_ga" diff --git a/analysis/lang/ga/elision_ga.go b/analysis/lang/ga/elision_ga.go index b8906c89f..30310014a 100644 --- a/analysis/lang/ga/elision_ga.go +++ b/analysis/lang/ga/elision_ga.go @@ -17,9 +17,9 @@ package ga import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/elision" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/elision" + "github.com/blevesearch/bleve/v2/registry" ) const ElisionName = "elision_ga" diff --git a/analysis/lang/ga/elision_ga_test.go b/analysis/lang/ga/elision_ga_test.go index 937f294d5..809a7c3ca 100644 --- a/analysis/lang/ga/elision_ga_test.go +++ b/analysis/lang/ga/elision_ga_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestFrenchElision(t *testing.T) { diff --git a/analysis/lang/ga/stop_filter_ga.go b/analysis/lang/ga/stop_filter_ga.go index 633621d3b..d58f55b53 100644 --- a/analysis/lang/ga/stop_filter_ga.go +++ b/analysis/lang/ga/stop_filter_ga.go @@ -15,9 +15,9 @@ package ga import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ga/stop_words_ga.go b/analysis/lang/ga/stop_words_ga.go index 12703be04..a3fc7ac4c 100644 --- a/analysis/lang/ga/stop_words_ga.go +++ b/analysis/lang/ga/stop_words_ga.go @@ -1,8 +1,8 @@ package ga import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ga" diff --git a/analysis/lang/gl/stop_filter_gl.go b/analysis/lang/gl/stop_filter_gl.go index 246897efa..753463df4 100644 --- a/analysis/lang/gl/stop_filter_gl.go +++ b/analysis/lang/gl/stop_filter_gl.go @@ -15,9 +15,9 @@ package gl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/gl/stop_words_gl.go b/analysis/lang/gl/stop_words_gl.go index 82a551c43..0d1fb5a0c 100644 --- a/analysis/lang/gl/stop_words_gl.go +++ b/analysis/lang/gl/stop_words_gl.go @@ -1,8 +1,8 @@ package gl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_gl" diff --git a/analysis/lang/hi/analyzer_hi.go b/analysis/lang/hi/analyzer_hi.go index e28d81ad9..717bb8143 100644 --- a/analysis/lang/hi/analyzer_hi.go +++ b/analysis/lang/hi/analyzer_hi.go @@ -15,12 +15,12 @@ package hi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/lang/in" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/lang/in" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "hi" diff --git a/analysis/lang/hi/analyzer_hi_test.go b/analysis/lang/hi/analyzer_hi_test.go index a56605447..a86aeefd8 100644 --- a/analysis/lang/hi/analyzer_hi_test.go +++ b/analysis/lang/hi/analyzer_hi_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestHindiAnalyzer(t *testing.T) { diff --git a/analysis/lang/hi/hindi_normalize.go b/analysis/lang/hi/hindi_normalize.go index bf2a210c4..182c6a101 100644 --- a/analysis/lang/hi/hindi_normalize.go +++ b/analysis/lang/hi/hindi_normalize.go @@ -17,8 +17,8 @@ package hi import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_hi" diff --git a/analysis/lang/hi/hindi_normalize_test.go b/analysis/lang/hi/hindi_normalize_test.go index daf01fa71..242008d86 100644 --- a/analysis/lang/hi/hindi_normalize_test.go +++ b/analysis/lang/hi/hindi_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestHindiNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/hi/hindi_stemmer_filter.go b/analysis/lang/hi/hindi_stemmer_filter.go index 06a304595..c1346db88 100644 --- a/analysis/lang/hi/hindi_stemmer_filter.go +++ b/analysis/lang/hi/hindi_stemmer_filter.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StemmerName = "stemmer_hi" diff --git a/analysis/lang/hi/hindi_stemmer_filter_test.go b/analysis/lang/hi/hindi_stemmer_filter_test.go index f17bc3316..bf5d92a80 100644 --- a/analysis/lang/hi/hindi_stemmer_filter_test.go +++ b/analysis/lang/hi/hindi_stemmer_filter_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestHindiStemmerFilter(t *testing.T) { diff --git a/analysis/lang/hi/stop_filter_hi.go b/analysis/lang/hi/stop_filter_hi.go index 2beccc590..d5598ad16 100644 --- a/analysis/lang/hi/stop_filter_hi.go +++ b/analysis/lang/hi/stop_filter_hi.go @@ -15,9 +15,9 @@ package hi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/hi/stop_words_hi.go b/analysis/lang/hi/stop_words_hi.go index f0300f0d0..1ffdec600 100644 --- a/analysis/lang/hi/stop_words_hi.go +++ b/analysis/lang/hi/stop_words_hi.go @@ -1,8 +1,8 @@ package hi import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_hi" diff --git a/analysis/lang/hu/analyzer_hu.go b/analysis/lang/hu/analyzer_hu.go index 6797a91e4..5935b7d41 100644 --- a/analysis/lang/hu/analyzer_hu.go +++ b/analysis/lang/hu/analyzer_hu.go @@ -15,11 +15,11 @@ package hu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "hu" diff --git a/analysis/lang/hu/analyzer_hu_test.go b/analysis/lang/hu/analyzer_hu_test.go index 4a14dff68..8745668c2 100644 --- a/analysis/lang/hu/analyzer_hu_test.go +++ b/analysis/lang/hu/analyzer_hu_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestHungarianAnalyzer(t *testing.T) { diff --git a/analysis/lang/hu/stemmer_hu.go b/analysis/lang/hu/stemmer_hu.go index b380818a0..e1a35c157 100644 --- a/analysis/lang/hu/stemmer_hu.go +++ b/analysis/lang/hu/stemmer_hu.go @@ -15,8 +15,8 @@ package hu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/hungarian" diff --git a/analysis/lang/hu/stop_filter_hu.go b/analysis/lang/hu/stop_filter_hu.go index a83fd4ccb..cafaf74ad 100644 --- a/analysis/lang/hu/stop_filter_hu.go +++ b/analysis/lang/hu/stop_filter_hu.go @@ -15,9 +15,9 @@ package hu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/hu/stop_words_hu.go b/analysis/lang/hu/stop_words_hu.go index fe45d55ea..3518538ae 100644 --- a/analysis/lang/hu/stop_words_hu.go +++ b/analysis/lang/hu/stop_words_hu.go @@ -1,8 +1,8 @@ package hu import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_hu" diff --git a/analysis/lang/hy/stop_filter_hy.go b/analysis/lang/hy/stop_filter_hy.go index a42743086..0601002ee 100644 --- a/analysis/lang/hy/stop_filter_hy.go +++ b/analysis/lang/hy/stop_filter_hy.go @@ -15,9 +15,9 @@ package hy import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/hy/stop_words_hy.go b/analysis/lang/hy/stop_words_hy.go index 6dc3db9b8..d2a105a88 100644 --- a/analysis/lang/hy/stop_words_hy.go +++ b/analysis/lang/hy/stop_words_hy.go @@ -1,8 +1,8 @@ package hy import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_hy" diff --git a/analysis/lang/id/stop_filter_id.go b/analysis/lang/id/stop_filter_id.go index 4bf44eed0..2568a5f21 100644 --- a/analysis/lang/id/stop_filter_id.go +++ b/analysis/lang/id/stop_filter_id.go @@ -15,9 +15,9 @@ package id import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/id/stop_words_id.go b/analysis/lang/id/stop_words_id.go index d802dcfce..97d02ac41 100644 --- a/analysis/lang/id/stop_words_id.go +++ b/analysis/lang/id/stop_words_id.go @@ -1,8 +1,8 @@ package id import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_id" diff --git a/analysis/lang/in/indic_normalize.go b/analysis/lang/in/indic_normalize.go index b865cee28..6c2ab2b5a 100644 --- a/analysis/lang/in/indic_normalize.go +++ b/analysis/lang/in/indic_normalize.go @@ -17,8 +17,8 @@ package in import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const NormalizeName = "normalize_in" diff --git a/analysis/lang/in/indic_normalize_test.go b/analysis/lang/in/indic_normalize_test.go index cd3c516f4..5789eb7b7 100644 --- a/analysis/lang/in/indic_normalize_test.go +++ b/analysis/lang/in/indic_normalize_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestIndicNormalizeFilter(t *testing.T) { diff --git a/analysis/lang/in/scripts.go b/analysis/lang/in/scripts.go index ad4b900ec..26446cb19 100644 --- a/analysis/lang/in/scripts.go +++ b/analysis/lang/in/scripts.go @@ -17,7 +17,7 @@ package in import ( "unicode" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" "github.com/willf/bitset" ) diff --git a/analysis/lang/it/analyzer_it.go b/analysis/lang/it/analyzer_it.go index 0ec9cee5d..f86d8b8dd 100644 --- a/analysis/lang/it/analyzer_it.go +++ b/analysis/lang/it/analyzer_it.go @@ -15,11 +15,11 @@ package it import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "it" diff --git a/analysis/lang/it/analyzer_it_test.go b/analysis/lang/it/analyzer_it_test.go index 6c56d4ca0..19b9d4dfe 100644 --- a/analysis/lang/it/analyzer_it_test.go +++ b/analysis/lang/it/analyzer_it_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestItalianAnalyzer(t *testing.T) { diff --git a/analysis/lang/it/articles_it.go b/analysis/lang/it/articles_it.go index bfd4bb48d..9bd0b6702 100644 --- a/analysis/lang/it/articles_it.go +++ b/analysis/lang/it/articles_it.go @@ -1,8 +1,8 @@ package it import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const ArticlesName = "articles_it" diff --git a/analysis/lang/it/elision_it.go b/analysis/lang/it/elision_it.go index 43bf4af7d..952608513 100644 --- a/analysis/lang/it/elision_it.go +++ b/analysis/lang/it/elision_it.go @@ -17,9 +17,9 @@ package it import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/elision" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/elision" + "github.com/blevesearch/bleve/v2/registry" ) const ElisionName = "elision_it" diff --git a/analysis/lang/it/elision_it_test.go b/analysis/lang/it/elision_it_test.go index 0e97a6786..b79610d7a 100644 --- a/analysis/lang/it/elision_it_test.go +++ b/analysis/lang/it/elision_it_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestItalianElision(t *testing.T) { diff --git a/analysis/lang/it/light_stemmer_it.go b/analysis/lang/it/light_stemmer_it.go index 67b90f0b8..daf63a191 100644 --- a/analysis/lang/it/light_stemmer_it.go +++ b/analysis/lang/it/light_stemmer_it.go @@ -17,8 +17,8 @@ package it import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const LightStemmerName = "stemmer_it_light" diff --git a/analysis/lang/it/light_stemmer_it_test.go b/analysis/lang/it/light_stemmer_it_test.go index e15e02a87..5122f1942 100644 --- a/analysis/lang/it/light_stemmer_it_test.go +++ b/analysis/lang/it/light_stemmer_it_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestItalianLightStemmer(t *testing.T) { diff --git a/analysis/lang/it/stemmer_it_snowball.go b/analysis/lang/it/stemmer_it_snowball.go index 04c6bd701..9faec48ff 100644 --- a/analysis/lang/it/stemmer_it_snowball.go +++ b/analysis/lang/it/stemmer_it_snowball.go @@ -15,8 +15,8 @@ package it import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/italian" diff --git a/analysis/lang/it/stemmer_it_snowball_test.go b/analysis/lang/it/stemmer_it_snowball_test.go index 844f2f543..134f2e026 100644 --- a/analysis/lang/it/stemmer_it_snowball_test.go +++ b/analysis/lang/it/stemmer_it_snowball_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballItalianStemmer(t *testing.T) { diff --git a/analysis/lang/it/stop_filter_it.go b/analysis/lang/it/stop_filter_it.go index ada11669c..79d459c18 100644 --- a/analysis/lang/it/stop_filter_it.go +++ b/analysis/lang/it/stop_filter_it.go @@ -15,9 +15,9 @@ package it import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/it/stop_words_it.go b/analysis/lang/it/stop_words_it.go index 5cca4bab3..10b3254dc 100644 --- a/analysis/lang/it/stop_words_it.go +++ b/analysis/lang/it/stop_words_it.go @@ -1,8 +1,8 @@ package it import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_it" diff --git a/analysis/lang/nl/analyzer_nl.go b/analysis/lang/nl/analyzer_nl.go index 69853a9e1..e8a195b2c 100644 --- a/analysis/lang/nl/analyzer_nl.go +++ b/analysis/lang/nl/analyzer_nl.go @@ -15,11 +15,11 @@ package nl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "nl" diff --git a/analysis/lang/nl/analyzer_nl_test.go b/analysis/lang/nl/analyzer_nl_test.go index 21e851c33..707655f01 100644 --- a/analysis/lang/nl/analyzer_nl_test.go +++ b/analysis/lang/nl/analyzer_nl_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestDutchAnalyzer(t *testing.T) { diff --git a/analysis/lang/nl/stemmer_nl.go b/analysis/lang/nl/stemmer_nl.go index 049d92160..b8c529517 100644 --- a/analysis/lang/nl/stemmer_nl.go +++ b/analysis/lang/nl/stemmer_nl.go @@ -15,8 +15,8 @@ package nl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/dutch" diff --git a/analysis/lang/nl/stop_filter_nl.go b/analysis/lang/nl/stop_filter_nl.go index 218f0f42c..75966731b 100644 --- a/analysis/lang/nl/stop_filter_nl.go +++ b/analysis/lang/nl/stop_filter_nl.go @@ -15,9 +15,9 @@ package nl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/nl/stop_words_nl.go b/analysis/lang/nl/stop_words_nl.go index 4adae1002..e68486199 100644 --- a/analysis/lang/nl/stop_words_nl.go +++ b/analysis/lang/nl/stop_words_nl.go @@ -1,8 +1,8 @@ package nl import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_nl" diff --git a/analysis/lang/no/analyzer_no.go b/analysis/lang/no/analyzer_no.go index 57d749eac..7876195c3 100644 --- a/analysis/lang/no/analyzer_no.go +++ b/analysis/lang/no/analyzer_no.go @@ -15,11 +15,11 @@ package no import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "no" diff --git a/analysis/lang/no/analyzer_no_test.go b/analysis/lang/no/analyzer_no_test.go index c73f5f731..b37cb4d1c 100644 --- a/analysis/lang/no/analyzer_no_test.go +++ b/analysis/lang/no/analyzer_no_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestNorwegianAnalyzer(t *testing.T) { diff --git a/analysis/lang/no/stemmer_no.go b/analysis/lang/no/stemmer_no.go index e61e02477..cf3fb37a1 100644 --- a/analysis/lang/no/stemmer_no.go +++ b/analysis/lang/no/stemmer_no.go @@ -15,8 +15,8 @@ package no import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/norwegian" diff --git a/analysis/lang/no/stop_filter_no.go b/analysis/lang/no/stop_filter_no.go index 093688fa7..72855bd8f 100644 --- a/analysis/lang/no/stop_filter_no.go +++ b/analysis/lang/no/stop_filter_no.go @@ -15,9 +15,9 @@ package no import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/no/stop_words_no.go b/analysis/lang/no/stop_words_no.go index bfca34846..b771091c5 100644 --- a/analysis/lang/no/stop_words_no.go +++ b/analysis/lang/no/stop_words_no.go @@ -1,8 +1,8 @@ package no import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_no" diff --git a/analysis/lang/pt/analyzer_pt.go b/analysis/lang/pt/analyzer_pt.go index 7f881d528..c8814028b 100644 --- a/analysis/lang/pt/analyzer_pt.go +++ b/analysis/lang/pt/analyzer_pt.go @@ -15,11 +15,11 @@ package pt import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "pt" diff --git a/analysis/lang/pt/analyzer_pt_test.go b/analysis/lang/pt/analyzer_pt_test.go index 691b48e5b..417e64066 100644 --- a/analysis/lang/pt/analyzer_pt_test.go +++ b/analysis/lang/pt/analyzer_pt_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestPortugueseAnalyzer(t *testing.T) { diff --git a/analysis/lang/pt/light_stemmer_pt.go b/analysis/lang/pt/light_stemmer_pt.go index 89f0d2ecc..cf3371cf3 100644 --- a/analysis/lang/pt/light_stemmer_pt.go +++ b/analysis/lang/pt/light_stemmer_pt.go @@ -17,8 +17,8 @@ package pt import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const LightStemmerName = "stemmer_pt_light" diff --git a/analysis/lang/pt/light_stemmer_pt_test.go b/analysis/lang/pt/light_stemmer_pt_test.go index 73e36a7d2..76b1435b5 100644 --- a/analysis/lang/pt/light_stemmer_pt_test.go +++ b/analysis/lang/pt/light_stemmer_pt_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestPortugueseLightStemmer(t *testing.T) { diff --git a/analysis/lang/pt/stop_filter_pt.go b/analysis/lang/pt/stop_filter_pt.go index db32025fb..7bdca2e61 100644 --- a/analysis/lang/pt/stop_filter_pt.go +++ b/analysis/lang/pt/stop_filter_pt.go @@ -15,9 +15,9 @@ package pt import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/pt/stop_words_pt.go b/analysis/lang/pt/stop_words_pt.go index a0d4995f1..e5c5ebba7 100644 --- a/analysis/lang/pt/stop_words_pt.go +++ b/analysis/lang/pt/stop_words_pt.go @@ -1,8 +1,8 @@ package pt import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_pt" diff --git a/analysis/lang/ro/analyzer_ro.go b/analysis/lang/ro/analyzer_ro.go index e29388155..24c7bffe8 100644 --- a/analysis/lang/ro/analyzer_ro.go +++ b/analysis/lang/ro/analyzer_ro.go @@ -15,11 +15,11 @@ package ro import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "ro" diff --git a/analysis/lang/ro/analyzer_ro_test.go b/analysis/lang/ro/analyzer_ro_test.go index ee8b88f80..0fe4645bd 100644 --- a/analysis/lang/ro/analyzer_ro_test.go +++ b/analysis/lang/ro/analyzer_ro_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestRomanianAnalyzer(t *testing.T) { diff --git a/analysis/lang/ro/stemmer_ro.go b/analysis/lang/ro/stemmer_ro.go index 3966215ff..b37ae878d 100644 --- a/analysis/lang/ro/stemmer_ro.go +++ b/analysis/lang/ro/stemmer_ro.go @@ -15,8 +15,8 @@ package ro import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/romanian" diff --git a/analysis/lang/ro/stop_filter_ro.go b/analysis/lang/ro/stop_filter_ro.go index a2f7f6dd9..ccd7e6bdd 100644 --- a/analysis/lang/ro/stop_filter_ro.go +++ b/analysis/lang/ro/stop_filter_ro.go @@ -15,9 +15,9 @@ package ro import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ro/stop_words_ro.go b/analysis/lang/ro/stop_words_ro.go index e7d62d414..4eb255a34 100644 --- a/analysis/lang/ro/stop_words_ro.go +++ b/analysis/lang/ro/stop_words_ro.go @@ -1,8 +1,8 @@ package ro import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ro" diff --git a/analysis/lang/ru/analyzer_ru.go b/analysis/lang/ru/analyzer_ru.go index d1b7688c0..3d591aff6 100644 --- a/analysis/lang/ru/analyzer_ru.go +++ b/analysis/lang/ru/analyzer_ru.go @@ -15,11 +15,11 @@ package ru import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "ru" diff --git a/analysis/lang/ru/analyzer_ru_test.go b/analysis/lang/ru/analyzer_ru_test.go index 6cda4a586..38534aff2 100644 --- a/analysis/lang/ru/analyzer_ru_test.go +++ b/analysis/lang/ru/analyzer_ru_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestRussianAnalyzer(t *testing.T) { diff --git a/analysis/lang/ru/stemmer_ru.go b/analysis/lang/ru/stemmer_ru.go index 47a90456b..6f051dc5e 100644 --- a/analysis/lang/ru/stemmer_ru.go +++ b/analysis/lang/ru/stemmer_ru.go @@ -15,8 +15,8 @@ package ru import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/russian" diff --git a/analysis/lang/ru/stemmer_ru_test.go b/analysis/lang/ru/stemmer_ru_test.go index 39949fcb0..8d44181cc 100644 --- a/analysis/lang/ru/stemmer_ru_test.go +++ b/analysis/lang/ru/stemmer_ru_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSnowballRussianStemmer(t *testing.T) { diff --git a/analysis/lang/ru/stop_filter_ru.go b/analysis/lang/ru/stop_filter_ru.go index 326fb9d56..e91f1fe2e 100644 --- a/analysis/lang/ru/stop_filter_ru.go +++ b/analysis/lang/ru/stop_filter_ru.go @@ -15,9 +15,9 @@ package ru import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/ru/stop_words_ru.go b/analysis/lang/ru/stop_words_ru.go index 0129f48c4..cca2f248c 100644 --- a/analysis/lang/ru/stop_words_ru.go +++ b/analysis/lang/ru/stop_words_ru.go @@ -1,8 +1,8 @@ package ru import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_ru" diff --git a/analysis/lang/sv/analyzer_sv.go b/analysis/lang/sv/analyzer_sv.go index f650158d4..7d987b323 100644 --- a/analysis/lang/sv/analyzer_sv.go +++ b/analysis/lang/sv/analyzer_sv.go @@ -15,11 +15,11 @@ package sv import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "sv" diff --git a/analysis/lang/sv/analyzer_sv_test.go b/analysis/lang/sv/analyzer_sv_test.go index 2d358b63e..a3bd5f161 100644 --- a/analysis/lang/sv/analyzer_sv_test.go +++ b/analysis/lang/sv/analyzer_sv_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestSwedishAnalyzer(t *testing.T) { diff --git a/analysis/lang/sv/stemmer_sv.go b/analysis/lang/sv/stemmer_sv.go index 247f11bb2..39265e7f4 100644 --- a/analysis/lang/sv/stemmer_sv.go +++ b/analysis/lang/sv/stemmer_sv.go @@ -15,8 +15,8 @@ package sv import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/swedish" diff --git a/analysis/lang/sv/stop_filter_sv.go b/analysis/lang/sv/stop_filter_sv.go index 46a533d17..6cd09baf9 100644 --- a/analysis/lang/sv/stop_filter_sv.go +++ b/analysis/lang/sv/stop_filter_sv.go @@ -15,9 +15,9 @@ package sv import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/sv/stop_words_sv.go b/analysis/lang/sv/stop_words_sv.go index b4022fd90..0943e6941 100644 --- a/analysis/lang/sv/stop_words_sv.go +++ b/analysis/lang/sv/stop_words_sv.go @@ -1,8 +1,8 @@ package sv import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_sv" diff --git a/analysis/lang/tr/analyzer_tr.go b/analysis/lang/tr/analyzer_tr.go index d52a1d5cc..64c6b3f8c 100644 --- a/analysis/lang/tr/analyzer_tr.go +++ b/analysis/lang/tr/analyzer_tr.go @@ -15,12 +15,12 @@ package tr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" - "github.com/blevesearch/bleve/analysis/token/apostrophe" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/analysis/token/apostrophe" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" ) const AnalyzerName = "tr" diff --git a/analysis/lang/tr/analyzer_tr_test.go b/analysis/lang/tr/analyzer_tr_test.go index fe8980938..3c4592b6e 100644 --- a/analysis/lang/tr/analyzer_tr_test.go +++ b/analysis/lang/tr/analyzer_tr_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestTurkishAnalyzer(t *testing.T) { diff --git a/analysis/lang/tr/stemmer_tr.go b/analysis/lang/tr/stemmer_tr.go index ba3034e1a..fa4590631 100644 --- a/analysis/lang/tr/stemmer_tr.go +++ b/analysis/lang/tr/stemmer_tr.go @@ -15,8 +15,8 @@ package tr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/snowballstem" "github.com/blevesearch/snowballstem/turkish" diff --git a/analysis/lang/tr/stop_filter_tr.go b/analysis/lang/tr/stop_filter_tr.go index 5b616eb9c..d096d7139 100644 --- a/analysis/lang/tr/stop_filter_tr.go +++ b/analysis/lang/tr/stop_filter_tr.go @@ -15,9 +15,9 @@ package tr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/token/stop" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/token/stop" + "github.com/blevesearch/bleve/v2/registry" ) func StopTokenFilterConstructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) { diff --git a/analysis/lang/tr/stop_words_tr.go b/analysis/lang/tr/stop_words_tr.go index f96fb07ed..8d0cdc5f0 100644 --- a/analysis/lang/tr/stop_words_tr.go +++ b/analysis/lang/tr/stop_words_tr.go @@ -1,8 +1,8 @@ package tr import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const StopName = "stop_tr" diff --git a/analysis/token/apostrophe/apostrophe.go b/analysis/token/apostrophe/apostrophe.go index 40b3f1368..4ab47bf26 100644 --- a/analysis/token/apostrophe/apostrophe.go +++ b/analysis/token/apostrophe/apostrophe.go @@ -17,8 +17,8 @@ package apostrophe import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "apostrophe" diff --git a/analysis/token/apostrophe/apostrophe_test.go b/analysis/token/apostrophe/apostrophe_test.go index 2688db652..b704dc723 100644 --- a/analysis/token/apostrophe/apostrophe_test.go +++ b/analysis/token/apostrophe/apostrophe_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestApostropheFilter(t *testing.T) { diff --git a/analysis/token/camelcase/camelcase.go b/analysis/token/camelcase/camelcase.go index 42b7483c6..0f6685cc0 100644 --- a/analysis/token/camelcase/camelcase.go +++ b/analysis/token/camelcase/camelcase.go @@ -18,8 +18,8 @@ import ( "bytes" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "camelCase" diff --git a/analysis/token/camelcase/camelcase_test.go b/analysis/token/camelcase/camelcase_test.go index 8b7c20cbb..9220bc582 100644 --- a/analysis/token/camelcase/camelcase_test.go +++ b/analysis/token/camelcase/camelcase_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestCamelCaseFilter(t *testing.T) { diff --git a/analysis/token/camelcase/parser.go b/analysis/token/camelcase/parser.go index ff4ce2fea..2d93fc4f7 100644 --- a/analysis/token/camelcase/parser.go +++ b/analysis/token/camelcase/parser.go @@ -15,7 +15,7 @@ package camelcase import ( - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func (p *Parser) buildTokenFromTerm(buffer []rune) *analysis.Token { diff --git a/analysis/token/compound/dict.go b/analysis/token/compound/dict.go index 7596e7711..e5065df4d 100644 --- a/analysis/token/compound/dict.go +++ b/analysis/token/compound/dict.go @@ -19,8 +19,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "dict_compound" diff --git a/analysis/token/compound/dict_test.go b/analysis/token/compound/dict_test.go index 4c3d5b7a4..8d9b093da 100644 --- a/analysis/token/compound/dict_test.go +++ b/analysis/token/compound/dict_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenmap" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenmap" + "github.com/blevesearch/bleve/v2/registry" ) func TestStopWordsFilter(t *testing.T) { diff --git a/analysis/token/edgengram/edgengram.go b/analysis/token/edgengram/edgengram.go index 1628193df..9e079c6c3 100644 --- a/analysis/token/edgengram/edgengram.go +++ b/analysis/token/edgengram/edgengram.go @@ -19,8 +19,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "edge_ngram" diff --git a/analysis/token/edgengram/edgengram_test.go b/analysis/token/edgengram/edgengram_test.go index 1be4db387..cb206a553 100644 --- a/analysis/token/edgengram/edgengram_test.go +++ b/analysis/token/edgengram/edgengram_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestEdgeNgramFilter(t *testing.T) { diff --git a/analysis/token/elision/elision.go b/analysis/token/elision/elision.go index 702a4389b..909d24121 100644 --- a/analysis/token/elision/elision.go +++ b/analysis/token/elision/elision.go @@ -18,8 +18,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "elision" diff --git a/analysis/token/elision/elision_test.go b/analysis/token/elision/elision_test.go index 73d2eb2b2..ed580b0c1 100644 --- a/analysis/token/elision/elision_test.go +++ b/analysis/token/elision/elision_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenmap" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenmap" + "github.com/blevesearch/bleve/v2/registry" ) func TestElisionFilter(t *testing.T) { diff --git a/analysis/token/keyword/keyword.go b/analysis/token/keyword/keyword.go index c39c40bea..49aa55d49 100644 --- a/analysis/token/keyword/keyword.go +++ b/analysis/token/keyword/keyword.go @@ -17,8 +17,8 @@ package keyword import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "keyword_marker" diff --git a/analysis/token/keyword/keyword_test.go b/analysis/token/keyword/keyword_test.go index de241f0f0..8b789f16d 100644 --- a/analysis/token/keyword/keyword_test.go +++ b/analysis/token/keyword/keyword_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestKeyWordMarkerFilter(t *testing.T) { diff --git a/analysis/token/length/length.go b/analysis/token/length/length.go index 485a79813..6b5cdd84b 100644 --- a/analysis/token/length/length.go +++ b/analysis/token/length/length.go @@ -18,8 +18,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "length" diff --git a/analysis/token/length/length_test.go b/analysis/token/length/length_test.go index 5f0fa80e6..b3cb06428 100644 --- a/analysis/token/length/length_test.go +++ b/analysis/token/length/length_test.go @@ -17,7 +17,7 @@ package length import ( "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestLengthFilter(t *testing.T) { diff --git a/analysis/token/lowercase/lowercase.go b/analysis/token/lowercase/lowercase.go index adb740c3e..a1b6dbd05 100644 --- a/analysis/token/lowercase/lowercase.go +++ b/analysis/token/lowercase/lowercase.go @@ -21,8 +21,8 @@ import ( "unicode" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) // Name is the name used to register LowerCaseFilter in the bleve registry diff --git a/analysis/token/lowercase/lowercase_test.go b/analysis/token/lowercase/lowercase_test.go index 771f61028..95fd2af5f 100644 --- a/analysis/token/lowercase/lowercase_test.go +++ b/analysis/token/lowercase/lowercase_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestLowerCaseFilter(t *testing.T) { diff --git a/analysis/token/ngram/ngram.go b/analysis/token/ngram/ngram.go index abab0aefc..ba99d9d42 100644 --- a/analysis/token/ngram/ngram.go +++ b/analysis/token/ngram/ngram.go @@ -19,8 +19,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "ngram" diff --git a/analysis/token/ngram/ngram_test.go b/analysis/token/ngram/ngram_test.go index aac12bf5f..877c881f5 100644 --- a/analysis/token/ngram/ngram_test.go +++ b/analysis/token/ngram/ngram_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestNgramFilter(t *testing.T) { diff --git a/analysis/token/porter/porter.go b/analysis/token/porter/porter.go index 4cd08d99c..95af0fa72 100644 --- a/analysis/token/porter/porter.go +++ b/analysis/token/porter/porter.go @@ -17,8 +17,8 @@ package porter import ( "bytes" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/blevesearch/go-porterstemmer" ) diff --git a/analysis/token/porter/porter_test.go b/analysis/token/porter/porter_test.go index abacd3bfa..3e0a79fe5 100644 --- a/analysis/token/porter/porter_test.go +++ b/analysis/token/porter/porter_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestPorterStemmer(t *testing.T) { diff --git a/analysis/token/reverse/reverse.go b/analysis/token/reverse/reverse.go index 671ed8992..f02e6cdf0 100644 --- a/analysis/token/reverse/reverse.go +++ b/analysis/token/reverse/reverse.go @@ -18,8 +18,8 @@ import ( "unicode" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) // Name is the name used to register ReverseFilter in the bleve registry diff --git a/analysis/token/reverse/reverse_test.go b/analysis/token/reverse/reverse_test.go index 8e84ab983..4bb7626a5 100644 --- a/analysis/token/reverse/reverse_test.go +++ b/analysis/token/reverse/reverse_test.go @@ -18,7 +18,7 @@ import ( "bytes" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestReverseFilter(t *testing.T) { diff --git a/analysis/token/shingle/shingle.go b/analysis/token/shingle/shingle.go index a1e6a6c68..59b8ddbfa 100644 --- a/analysis/token/shingle/shingle.go +++ b/analysis/token/shingle/shingle.go @@ -18,8 +18,8 @@ import ( "container/ring" "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "shingle" diff --git a/analysis/token/shingle/shingle_test.go b/analysis/token/shingle/shingle_test.go index 64406cb62..b545056c4 100644 --- a/analysis/token/shingle/shingle_test.go +++ b/analysis/token/shingle/shingle_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestShingleFilter(t *testing.T) { diff --git a/analysis/token/snowball/snowball.go b/analysis/token/snowball/snowball.go index 6a672c2b2..79b233b28 100644 --- a/analysis/token/snowball/snowball.go +++ b/analysis/token/snowball/snowball.go @@ -17,8 +17,8 @@ package snowball import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "github.com/kljensen/snowball" ) diff --git a/analysis/token/snowball/snowball_test.go b/analysis/token/snowball/snowball_test.go index 80c2f6f47..a80534721 100644 --- a/analysis/token/snowball/snowball_test.go +++ b/analysis/token/snowball/snowball_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestSnowballStemmer(t *testing.T) { diff --git a/analysis/token/stop/stop.go b/analysis/token/stop/stop.go index cca2d8e01..bf4b98db1 100644 --- a/analysis/token/stop/stop.go +++ b/analysis/token/stop/stop.go @@ -24,8 +24,8 @@ package stop import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "stop_tokens" diff --git a/analysis/token/stop/stop_test.go b/analysis/token/stop/stop_test.go index 24c941edc..f63c5620d 100644 --- a/analysis/token/stop/stop_test.go +++ b/analysis/token/stop/stop_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenmap" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenmap" + "github.com/blevesearch/bleve/v2/registry" ) func TestStopWordsFilter(t *testing.T) { diff --git a/analysis/token/truncate/truncate.go b/analysis/token/truncate/truncate.go index be9570d92..faf65b705 100644 --- a/analysis/token/truncate/truncate.go +++ b/analysis/token/truncate/truncate.go @@ -18,8 +18,8 @@ import ( "fmt" "unicode/utf8" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "truncate_token" diff --git a/analysis/token/truncate/truncate_test.go b/analysis/token/truncate/truncate_test.go index 88c25c432..083e277c9 100644 --- a/analysis/token/truncate/truncate_test.go +++ b/analysis/token/truncate/truncate_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestTruncateTokenFilter(t *testing.T) { diff --git a/analysis/token/unicodenorm/unicodenorm.go b/analysis/token/unicodenorm/unicodenorm.go index c03bac98a..01b191bc2 100644 --- a/analysis/token/unicodenorm/unicodenorm.go +++ b/analysis/token/unicodenorm/unicodenorm.go @@ -17,8 +17,8 @@ package unicodenorm import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" "golang.org/x/text/unicode/norm" ) diff --git a/analysis/token/unicodenorm/unicodenorm_test.go b/analysis/token/unicodenorm/unicodenorm_test.go index 7f5bfc4e9..0ff2bd8f4 100644 --- a/analysis/token/unicodenorm/unicodenorm_test.go +++ b/analysis/token/unicodenorm/unicodenorm_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) // the following tests come from the lucene diff --git a/analysis/token/unique/unique.go b/analysis/token/unique/unique.go index c60e8c979..6fbc663de 100644 --- a/analysis/token/unique/unique.go +++ b/analysis/token/unique/unique.go @@ -15,8 +15,8 @@ package unique import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "unique" diff --git a/analysis/token/unique/unique_test.go b/analysis/token/unique/unique_test.go index 216d8f1fa..bc17130ad 100644 --- a/analysis/token/unique/unique_test.go +++ b/analysis/token/unique/unique_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestUniqueTermFilter(t *testing.T) { diff --git a/analysis/tokenizer/character/character.go b/analysis/tokenizer/character/character.go index dcac9247a..9c4f7e44b 100644 --- a/analysis/tokenizer/character/character.go +++ b/analysis/tokenizer/character/character.go @@ -17,7 +17,7 @@ package character import ( "unicode/utf8" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) type IsTokenRune func(r rune) bool diff --git a/analysis/tokenizer/character/character_test.go b/analysis/tokenizer/character/character_test.go index 2c7e4531f..30d00e8f4 100644 --- a/analysis/tokenizer/character/character_test.go +++ b/analysis/tokenizer/character/character_test.go @@ -19,7 +19,7 @@ import ( "testing" "unicode" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestCharacterTokenizer(t *testing.T) { diff --git a/analysis/tokenizer/exception/exception.go b/analysis/tokenizer/exception/exception.go index f73872a99..11023e855 100644 --- a/analysis/tokenizer/exception/exception.go +++ b/analysis/tokenizer/exception/exception.go @@ -31,8 +31,8 @@ import ( "regexp" "strings" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "exception" diff --git a/analysis/tokenizer/exception/exception_test.go b/analysis/tokenizer/exception/exception_test.go index a679abf06..1c4acb047 100644 --- a/analysis/tokenizer/exception/exception_test.go +++ b/analysis/tokenizer/exception/exception_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - _ "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) func TestExceptionsTokenizer(t *testing.T) { diff --git a/analysis/tokenizer/letter/letter.go b/analysis/tokenizer/letter/letter.go index 49045c907..96a2a664b 100644 --- a/analysis/tokenizer/letter/letter.go +++ b/analysis/tokenizer/letter/letter.go @@ -17,9 +17,9 @@ package letter import ( "unicode" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/character" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/character" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "letter" diff --git a/analysis/tokenizer/regexp/regexp.go b/analysis/tokenizer/regexp/regexp.go index c3401d825..61bac6ca6 100644 --- a/analysis/tokenizer/regexp/regexp.go +++ b/analysis/tokenizer/regexp/regexp.go @@ -19,8 +19,8 @@ import ( "regexp" "strconv" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "regexp" diff --git a/analysis/tokenizer/regexp/regexp_test.go b/analysis/tokenizer/regexp/regexp_test.go index bd6de66b7..cfad9158b 100644 --- a/analysis/tokenizer/regexp/regexp_test.go +++ b/analysis/tokenizer/regexp/regexp_test.go @@ -19,7 +19,7 @@ import ( "regexp" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestBoundary(t *testing.T) { diff --git a/analysis/tokenizer/single/single.go b/analysis/tokenizer/single/single.go index 18b2b1af9..a3eac7899 100644 --- a/analysis/tokenizer/single/single.go +++ b/analysis/tokenizer/single/single.go @@ -15,8 +15,8 @@ package single import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "single" diff --git a/analysis/tokenizer/single/single_test.go b/analysis/tokenizer/single/single_test.go index 5f3b68d74..7cc134ce3 100644 --- a/analysis/tokenizer/single/single_test.go +++ b/analysis/tokenizer/single/single_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestSingleTokenTokenizer(t *testing.T) { diff --git a/analysis/tokenizer/unicode/unicode.go b/analysis/tokenizer/unicode/unicode.go index 39e38b453..ca3cfe76c 100644 --- a/analysis/tokenizer/unicode/unicode.go +++ b/analysis/tokenizer/unicode/unicode.go @@ -17,8 +17,8 @@ package unicode import ( "github.com/blevesearch/segment" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "unicode" diff --git a/analysis/tokenizer/unicode/unicode_test.go b/analysis/tokenizer/unicode/unicode_test.go index f793b972f..0e0cfd4cc 100644 --- a/analysis/tokenizer/unicode/unicode_test.go +++ b/analysis/tokenizer/unicode/unicode_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" "github.com/blevesearch/segment" ) diff --git a/analysis/tokenizer/web/web.go b/analysis/tokenizer/web/web.go index 8542bc1c4..545ccd9d6 100644 --- a/analysis/tokenizer/web/web.go +++ b/analysis/tokenizer/web/web.go @@ -18,10 +18,10 @@ import ( "regexp" "strings" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/exception" - "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/exception" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "web" diff --git a/analysis/tokenizer/web/web_test.go b/analysis/tokenizer/web/web_test.go index 16e0da9ba..d5dbcce93 100644 --- a/analysis/tokenizer/web/web_test.go +++ b/analysis/tokenizer/web/web_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) func TestWeb(t *testing.T) { diff --git a/analysis/tokenizer/whitespace/whitespace.go b/analysis/tokenizer/whitespace/whitespace.go index 504545a1f..06134c771 100644 --- a/analysis/tokenizer/whitespace/whitespace.go +++ b/analysis/tokenizer/whitespace/whitespace.go @@ -17,9 +17,9 @@ package whitespace import ( "unicode" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/character" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/character" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "whitespace" diff --git a/analysis/tokenizer/whitespace/whitespace_test.go b/analysis/tokenizer/whitespace/whitespace_test.go index 1165ed923..6bd6b54ab 100644 --- a/analysis/tokenizer/whitespace/whitespace_test.go +++ b/analysis/tokenizer/whitespace/whitespace_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/tokenizer/character" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/character" ) func TestBoundary(t *testing.T) { diff --git a/analysis/tokenmap/custom.go b/analysis/tokenmap/custom.go index 9b86ce575..ae08d3e17 100644 --- a/analysis/tokenmap/custom.go +++ b/analysis/tokenmap/custom.go @@ -28,8 +28,8 @@ package tokenmap import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "custom" diff --git a/builder.go b/builder.go index de00c97b6..dbb7e3ed4 100644 --- a/builder.go +++ b/builder.go @@ -18,10 +18,10 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/mapping" + index "github.com/blevesearch/bleve_index_api" ) type builderImpl struct { diff --git a/cmd/bleve/cmd/check.go b/cmd/bleve/cmd/check.go index 370ece983..ca4f286ed 100644 --- a/cmd/bleve/cmd/check.go +++ b/cmd/bleve/cmd/check.go @@ -18,7 +18,7 @@ import ( "fmt" "log" - "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/v2" "github.com/spf13/cobra" ) @@ -100,7 +100,7 @@ func checkField(index bleve.Index, fieldName string) (int, error) { func getDictionary(index bleve.Index, field string) (map[string]uint64, error) { rv := make(map[string]uint64) - i, _, err := index.Advanced() + i, err := index.Advanced() if err != nil { log.Fatal(err) } diff --git a/cmd/bleve/cmd/create.go b/cmd/bleve/cmd/create.go index a5ef3d5bb..3827c6429 100644 --- a/cmd/bleve/cmd/create.go +++ b/cmd/bleve/cmd/create.go @@ -19,8 +19,8 @@ import ( "fmt" "io/ioutil" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/mapping" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/dictionary.go b/cmd/bleve/cmd/dictionary.go index 72a58238d..3f42d122a 100644 --- a/cmd/bleve/cmd/dictionary.go +++ b/cmd/bleve/cmd/dictionary.go @@ -29,7 +29,7 @@ var dictionaryCmd = &cobra.Command{ if len(args) < 2 { return fmt.Errorf("must specify field") } - i, _, err := idx.Advanced() + i, err := idx.Advanced() if err != nil { return fmt.Errorf("error getting index: %v", err) } diff --git a/cmd/bleve/cmd/dump.go b/cmd/bleve/cmd/dump.go index bd44fd672..db76eeb4b 100644 --- a/cmd/bleve/cmd/dump.go +++ b/cmd/bleve/cmd/dump.go @@ -17,7 +17,7 @@ package cmd import ( "fmt" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/index/upsidedown" "github.com/spf13/cobra" ) @@ -29,7 +29,7 @@ var dumpCmd = &cobra.Command{ Short: "dumps the contents of the index", Long: `The dump command will dump (possibly a section of) the index.`, RunE: func(cmd *cobra.Command, args []string) error { - i, _, err := idx.Advanced() + i, err := idx.Advanced() if err != nil { return fmt.Errorf("error getting index: %v", err) } @@ -37,8 +37,12 @@ var dumpCmd = &cobra.Command{ if err != nil { return fmt.Errorf("error getting index reader: %v", err) } + upsideDownReader, ok := r.(*upsidedown.IndexReader) + if !ok { + return fmt.Errorf("dump is only supported by index type upsidedown") + } - dumpChan := r.DumpAll() + dumpChan := upsideDownReader.DumpAll() for rowOrErr := range dumpChan { switch rowOrErr := rowOrErr.(type) { case error: diff --git a/cmd/bleve/cmd/dumpDoc.go b/cmd/bleve/cmd/dumpDoc.go index 368e1756a..4473ab66f 100644 --- a/cmd/bleve/cmd/dumpDoc.go +++ b/cmd/bleve/cmd/dumpDoc.go @@ -17,7 +17,7 @@ package cmd import ( "fmt" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/index/upsidedown" "github.com/spf13/cobra" ) @@ -31,7 +31,7 @@ var dumpDocCmd = &cobra.Command{ return fmt.Errorf("must specify docid") } - i, _, err := idx.Advanced() + i, err := idx.Advanced() if err != nil { return fmt.Errorf("error getting index: %v", err) } @@ -39,8 +39,12 @@ var dumpDocCmd = &cobra.Command{ if err != nil { return fmt.Errorf("error getting index reader: %v", err) } + upsideDownReader, ok := r.(*upsidedown.IndexReader) + if !ok { + return fmt.Errorf("dump doc is only supported by index type upsidedown") + } - dumpChan := r.DumpDoc(args[1]) + dumpChan := upsideDownReader.DumpDoc(args[1]) for rowOrErr := range dumpChan { switch rowOrErr := rowOrErr.(type) { case error: diff --git a/cmd/bleve/cmd/dumpFields.go b/cmd/bleve/cmd/dumpFields.go index 31fa00c80..0021ff92e 100644 --- a/cmd/bleve/cmd/dumpFields.go +++ b/cmd/bleve/cmd/dumpFields.go @@ -17,7 +17,7 @@ package cmd import ( "fmt" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/index/upsidedown" "github.com/spf13/cobra" ) @@ -27,7 +27,7 @@ var dumpFieldsCmd = &cobra.Command{ Short: "dump only the field rows", Long: `The fields sub-command of dump will only dump the field rows.`, RunE: func(cmd *cobra.Command, args []string) error { - i, _, err := idx.Advanced() + i, err := idx.Advanced() if err != nil { return fmt.Errorf("error getting index: %v", err) } @@ -35,8 +35,12 @@ var dumpFieldsCmd = &cobra.Command{ if err != nil { return fmt.Errorf("error getting index reader: %v", err) } + upsideDownReader, ok := r.(*upsidedown.IndexReader) + if !ok { + return fmt.Errorf("dump fields is only supported by index type upsidedown") + } - dumpChan := r.DumpFields() + dumpChan := upsideDownReader.DumpFields() for rowOrErr := range dumpChan { switch rowOrErr := rowOrErr.(type) { case error: diff --git a/cmd/bleve/cmd/fields.go b/cmd/bleve/cmd/fields.go index 6ff40aff4..11b369f0c 100644 --- a/cmd/bleve/cmd/fields.go +++ b/cmd/bleve/cmd/fields.go @@ -26,7 +26,7 @@ var fieldsCmd = &cobra.Command{ Short: "lists the fields in this index", Long: `The fields command will list the fields used in this index.`, RunE: func(cmd *cobra.Command, args []string) error { - i, _, err := idx.Advanced() + i, err := idx.Advanced() if err != nil { return fmt.Errorf("error getting index: %v", err) } diff --git a/cmd/bleve/cmd/query.go b/cmd/bleve/cmd/query.go index 6e1bd0943..e1b4beceb 100644 --- a/cmd/bleve/cmd/query.go +++ b/cmd/bleve/cmd/query.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/search/query" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/search/query" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/registry.go b/cmd/bleve/cmd/registry.go index ff2db88f1..9d5fc3f4e 100644 --- a/cmd/bleve/cmd/registry.go +++ b/cmd/bleve/cmd/registry.go @@ -18,7 +18,7 @@ import ( "fmt" "sort" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/registry" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/root.go b/cmd/bleve/cmd/root.go index 8dcf165b2..37a6735da 100644 --- a/cmd/bleve/cmd/root.go +++ b/cmd/bleve/cmd/root.go @@ -19,7 +19,7 @@ import ( "os" "strconv" - "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/v2" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/scorch.go b/cmd/bleve/cmd/scorch.go index 781db7031..d8991512c 100644 --- a/cmd/bleve/cmd/scorch.go +++ b/cmd/bleve/cmd/scorch.go @@ -15,7 +15,7 @@ package cmd import ( - "github.com/blevesearch/bleve/cmd/bleve/cmd/scorch" + "github.com/blevesearch/bleve/v2/cmd/bleve/cmd/scorch" ) // make scorch command-line tool a bleve sub-command diff --git a/cmd/bleve/cmd/scorch/ascii.go b/cmd/bleve/cmd/scorch/ascii.go index 34fb1ed70..f6bdaeccd 100644 --- a/cmd/bleve/cmd/scorch/ascii.go +++ b/cmd/bleve/cmd/scorch/ascii.go @@ -18,7 +18,7 @@ import ( "fmt" "strconv" - "github.com/blevesearch/bleve/index/scorch/mergeplan" + "github.com/blevesearch/bleve/v2/index/scorch/mergeplan" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/scorch/root.go b/cmd/bleve/cmd/scorch/root.go index b27992edc..5e2a44139 100644 --- a/cmd/bleve/cmd/scorch/root.go +++ b/cmd/bleve/cmd/scorch/root.go @@ -18,7 +18,7 @@ import ( "fmt" "os" - "github.com/blevesearch/bleve/index/scorch" + "github.com/blevesearch/bleve/v2/index/scorch" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/cmd/scorch/snapshot.go b/cmd/bleve/cmd/scorch/snapshot.go index 3dee55895..db8e1c51d 100644 --- a/cmd/bleve/cmd/scorch/snapshot.go +++ b/cmd/bleve/cmd/scorch/snapshot.go @@ -18,7 +18,7 @@ import ( "fmt" "strconv" - seg "github.com/blevesearch/bleve/index/scorch/segment" + seg "github.com/blevesearch/scorch_segment_api" "github.com/spf13/cobra" ) diff --git a/cmd/bleve/gendocs.go b/cmd/bleve/gendocs.go index 4634132a2..433dd78af 100644 --- a/cmd/bleve/gendocs.go +++ b/cmd/bleve/gendocs.go @@ -19,7 +19,7 @@ package main import ( "fmt" - "github.com/blevesearch/bleve/cmd/bleve/cmd" + "github.com/blevesearch/bleve/v2/cmd/bleve/cmd" "github.com/spf13/cobra/doc" ) diff --git a/cmd/bleve/main.go b/cmd/bleve/main.go index ecc82c189..64e627984 100644 --- a/cmd/bleve/main.go +++ b/cmd/bleve/main.go @@ -15,10 +15,10 @@ package main import ( - "github.com/blevesearch/bleve/cmd/bleve/cmd" + "github.com/blevesearch/bleve/v2/cmd/bleve/cmd" // to support standard set of build tags - _ "github.com/blevesearch/bleve/config" + _ "github.com/blevesearch/bleve/v2/config" ) func main() { diff --git a/config.go b/config.go index 99f2e081f..0622b359d 100644 --- a/config.go +++ b/config.go @@ -20,14 +20,11 @@ import ( "log" "time" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight/highlighter/html" - - // force import of scorch so its accessible by default - _ "github.com/blevesearch/bleve/index/scorch" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight/highlighter/html" + index "github.com/blevesearch/bleve_index_api" ) var bleveExpVar = expvar.NewMap("bleve") @@ -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)) diff --git a/config/config.go b/config/config.go index 5ed2d9c3f..04f9fa0c3 100644 --- a/config/config.go +++ b/config/config.go @@ -16,100 +16,100 @@ package config import ( // token maps - _ "github.com/blevesearch/bleve/analysis/tokenmap" + _ "github.com/blevesearch/bleve/v2/analysis/tokenmap" // fragment formatters - _ "github.com/blevesearch/bleve/search/highlight/format/ansi" - _ "github.com/blevesearch/bleve/search/highlight/format/html" + _ "github.com/blevesearch/bleve/v2/search/highlight/format/ansi" + _ "github.com/blevesearch/bleve/v2/search/highlight/format/html" // fragmenters - _ "github.com/blevesearch/bleve/search/highlight/fragmenter/simple" + _ "github.com/blevesearch/bleve/v2/search/highlight/fragmenter/simple" // highlighters - _ "github.com/blevesearch/bleve/search/highlight/highlighter/ansi" - _ "github.com/blevesearch/bleve/search/highlight/highlighter/html" - _ "github.com/blevesearch/bleve/search/highlight/highlighter/simple" + _ "github.com/blevesearch/bleve/v2/search/highlight/highlighter/ansi" + _ "github.com/blevesearch/bleve/v2/search/highlight/highlighter/html" + _ "github.com/blevesearch/bleve/v2/search/highlight/highlighter/simple" // char filters - _ "github.com/blevesearch/bleve/analysis/char/asciifolding" - _ "github.com/blevesearch/bleve/analysis/char/html" - _ "github.com/blevesearch/bleve/analysis/char/regexp" - _ "github.com/blevesearch/bleve/analysis/char/zerowidthnonjoiner" + _ "github.com/blevesearch/bleve/v2/analysis/char/asciifolding" + _ "github.com/blevesearch/bleve/v2/analysis/char/html" + _ "github.com/blevesearch/bleve/v2/analysis/char/regexp" + _ "github.com/blevesearch/bleve/v2/analysis/char/zerowidthnonjoiner" // analyzers - _ "github.com/blevesearch/bleve/analysis/analyzer/custom" - _ "github.com/blevesearch/bleve/analysis/analyzer/keyword" - _ "github.com/blevesearch/bleve/analysis/analyzer/simple" - _ "github.com/blevesearch/bleve/analysis/analyzer/standard" - _ "github.com/blevesearch/bleve/analysis/analyzer/web" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/custom" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/keyword" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/simple" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/web" // token filters - _ "github.com/blevesearch/bleve/analysis/token/apostrophe" - _ "github.com/blevesearch/bleve/analysis/token/camelcase" - _ "github.com/blevesearch/bleve/analysis/token/compound" - _ "github.com/blevesearch/bleve/analysis/token/edgengram" - _ "github.com/blevesearch/bleve/analysis/token/elision" - _ "github.com/blevesearch/bleve/analysis/token/keyword" - _ "github.com/blevesearch/bleve/analysis/token/length" - _ "github.com/blevesearch/bleve/analysis/token/lowercase" - _ "github.com/blevesearch/bleve/analysis/token/ngram" - _ "github.com/blevesearch/bleve/analysis/token/reverse" - _ "github.com/blevesearch/bleve/analysis/token/shingle" - _ "github.com/blevesearch/bleve/analysis/token/stop" - _ "github.com/blevesearch/bleve/analysis/token/truncate" - _ "github.com/blevesearch/bleve/analysis/token/unicodenorm" - _ "github.com/blevesearch/bleve/analysis/token/unique" + _ "github.com/blevesearch/bleve/v2/analysis/token/apostrophe" + _ "github.com/blevesearch/bleve/v2/analysis/token/camelcase" + _ "github.com/blevesearch/bleve/v2/analysis/token/compound" + _ "github.com/blevesearch/bleve/v2/analysis/token/edgengram" + _ "github.com/blevesearch/bleve/v2/analysis/token/elision" + _ "github.com/blevesearch/bleve/v2/analysis/token/keyword" + _ "github.com/blevesearch/bleve/v2/analysis/token/length" + _ "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + _ "github.com/blevesearch/bleve/v2/analysis/token/ngram" + _ "github.com/blevesearch/bleve/v2/analysis/token/reverse" + _ "github.com/blevesearch/bleve/v2/analysis/token/shingle" + _ "github.com/blevesearch/bleve/v2/analysis/token/stop" + _ "github.com/blevesearch/bleve/v2/analysis/token/truncate" + _ "github.com/blevesearch/bleve/v2/analysis/token/unicodenorm" + _ "github.com/blevesearch/bleve/v2/analysis/token/unique" // tokenizers - _ "github.com/blevesearch/bleve/analysis/tokenizer/exception" - _ "github.com/blevesearch/bleve/analysis/tokenizer/regexp" - _ "github.com/blevesearch/bleve/analysis/tokenizer/single" - _ "github.com/blevesearch/bleve/analysis/tokenizer/unicode" - _ "github.com/blevesearch/bleve/analysis/tokenizer/web" - _ "github.com/blevesearch/bleve/analysis/tokenizer/whitespace" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/exception" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/regexp" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/single" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/web" + _ "github.com/blevesearch/bleve/v2/analysis/tokenizer/whitespace" // date time parsers - _ "github.com/blevesearch/bleve/analysis/datetime/flexible" - _ "github.com/blevesearch/bleve/analysis/datetime/optional" + _ "github.com/blevesearch/bleve/v2/analysis/datetime/flexible" + _ "github.com/blevesearch/bleve/v2/analysis/datetime/optional" // languages - _ "github.com/blevesearch/bleve/analysis/lang/ar" - _ "github.com/blevesearch/bleve/analysis/lang/bg" - _ "github.com/blevesearch/bleve/analysis/lang/ca" - _ "github.com/blevesearch/bleve/analysis/lang/cjk" - _ "github.com/blevesearch/bleve/analysis/lang/ckb" - _ "github.com/blevesearch/bleve/analysis/lang/cs" - _ "github.com/blevesearch/bleve/analysis/lang/da" - _ "github.com/blevesearch/bleve/analysis/lang/de" - _ "github.com/blevesearch/bleve/analysis/lang/el" - _ "github.com/blevesearch/bleve/analysis/lang/en" - _ "github.com/blevesearch/bleve/analysis/lang/es" - _ "github.com/blevesearch/bleve/analysis/lang/eu" - _ "github.com/blevesearch/bleve/analysis/lang/fa" - _ "github.com/blevesearch/bleve/analysis/lang/fi" - _ "github.com/blevesearch/bleve/analysis/lang/fr" - _ "github.com/blevesearch/bleve/analysis/lang/ga" - _ "github.com/blevesearch/bleve/analysis/lang/gl" - _ "github.com/blevesearch/bleve/analysis/lang/hi" - _ "github.com/blevesearch/bleve/analysis/lang/hu" - _ "github.com/blevesearch/bleve/analysis/lang/hy" - _ "github.com/blevesearch/bleve/analysis/lang/id" - _ "github.com/blevesearch/bleve/analysis/lang/in" - _ "github.com/blevesearch/bleve/analysis/lang/it" - _ "github.com/blevesearch/bleve/analysis/lang/nl" - _ "github.com/blevesearch/bleve/analysis/lang/no" - _ "github.com/blevesearch/bleve/analysis/lang/pt" - _ "github.com/blevesearch/bleve/analysis/lang/ro" - _ "github.com/blevesearch/bleve/analysis/lang/ru" - _ "github.com/blevesearch/bleve/analysis/lang/sv" - _ "github.com/blevesearch/bleve/analysis/lang/tr" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ar" + _ "github.com/blevesearch/bleve/v2/analysis/lang/bg" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ca" + _ "github.com/blevesearch/bleve/v2/analysis/lang/cjk" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ckb" + _ "github.com/blevesearch/bleve/v2/analysis/lang/cs" + _ "github.com/blevesearch/bleve/v2/analysis/lang/da" + _ "github.com/blevesearch/bleve/v2/analysis/lang/de" + _ "github.com/blevesearch/bleve/v2/analysis/lang/el" + _ "github.com/blevesearch/bleve/v2/analysis/lang/en" + _ "github.com/blevesearch/bleve/v2/analysis/lang/es" + _ "github.com/blevesearch/bleve/v2/analysis/lang/eu" + _ "github.com/blevesearch/bleve/v2/analysis/lang/fa" + _ "github.com/blevesearch/bleve/v2/analysis/lang/fi" + _ "github.com/blevesearch/bleve/v2/analysis/lang/fr" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ga" + _ "github.com/blevesearch/bleve/v2/analysis/lang/gl" + _ "github.com/blevesearch/bleve/v2/analysis/lang/hi" + _ "github.com/blevesearch/bleve/v2/analysis/lang/hu" + _ "github.com/blevesearch/bleve/v2/analysis/lang/hy" + _ "github.com/blevesearch/bleve/v2/analysis/lang/id" + _ "github.com/blevesearch/bleve/v2/analysis/lang/in" + _ "github.com/blevesearch/bleve/v2/analysis/lang/it" + _ "github.com/blevesearch/bleve/v2/analysis/lang/nl" + _ "github.com/blevesearch/bleve/v2/analysis/lang/no" + _ "github.com/blevesearch/bleve/v2/analysis/lang/pt" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ro" + _ "github.com/blevesearch/bleve/v2/analysis/lang/ru" + _ "github.com/blevesearch/bleve/v2/analysis/lang/sv" + _ "github.com/blevesearch/bleve/v2/analysis/lang/tr" // kv stores - _ "github.com/blevesearch/bleve/index/store/boltdb" - _ "github.com/blevesearch/bleve/index/store/goleveldb" - _ "github.com/blevesearch/bleve/index/store/gtreap" - _ "github.com/blevesearch/bleve/index/store/moss" + _ "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" + _ "github.com/blevesearch/bleve/v2/index/upsidedown/store/goleveldb" + _ "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + _ "github.com/blevesearch/bleve/v2/index/upsidedown/store/moss" // index types - _ "github.com/blevesearch/bleve/index/upsidedown" + _ "github.com/blevesearch/bleve/v2/index/upsidedown" ) diff --git a/config/config_cznicb.go b/config/config_cznicb.go deleted file mode 100644 index 7fe0a770f..000000000 --- a/config/config_cznicb.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build cznicb full - -package config - -import ( - _ "github.com/blevesearch/blevex/cznicb" -) diff --git a/config/config_icu.go b/config/config_icu.go deleted file mode 100644 index ff5a81d7a..000000000 --- a/config/config_icu.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build icu full - -package config - -import ( - _ "github.com/blevesearch/blevex/lang/th" -) diff --git a/config/config_kagome.go b/config/config_kagome.go deleted file mode 100644 index ffe692564..000000000 --- a/config/config_kagome.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build kagome full - -package config - -import ( - _ "github.com/blevesearch/blevex/lang/ja" -) diff --git a/config/config_leveldb.go b/config/config_leveldb.go deleted file mode 100644 index 16ac8f413..000000000 --- a/config/config_leveldb.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build leveldb full - -package config - -import ( - _ "github.com/blevesearch/blevex/leveldb" -) diff --git a/config/config_libstemmer.go b/config/config_libstemmer.go deleted file mode 100644 index e11b6154f..000000000 --- a/config/config_libstemmer.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build libstemmer full - -package config - -import ( - _ "github.com/blevesearch/blevex/lang/da" - _ "github.com/blevesearch/blevex/lang/de" - _ "github.com/blevesearch/blevex/lang/en" - _ "github.com/blevesearch/blevex/lang/es" - _ "github.com/blevesearch/blevex/lang/fi" - _ "github.com/blevesearch/blevex/lang/fr" - _ "github.com/blevesearch/blevex/lang/hu" - _ "github.com/blevesearch/blevex/lang/it" - _ "github.com/blevesearch/blevex/lang/nl" - _ "github.com/blevesearch/blevex/lang/no" - _ "github.com/blevesearch/blevex/lang/pt" - _ "github.com/blevesearch/blevex/lang/ro" - _ "github.com/blevesearch/blevex/lang/ru" - _ "github.com/blevesearch/blevex/lang/sv" - _ "github.com/blevesearch/blevex/lang/th" - _ "github.com/blevesearch/blevex/lang/tr" -) diff --git a/config/config_rocksdb.go b/config/config_rocksdb.go deleted file mode 100644 index e9b2d0827..000000000 --- a/config/config_rocksdb.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build rocksdb full - -package config - -import ( - _ "github.com/blevesearch/blevex/rocksdb" -) diff --git a/config_disk.go b/config_disk.go index d03bceb40..ccfd6da8c 100644 --- a/config_disk.go +++ b/config_disk.go @@ -16,7 +16,7 @@ package bleve -import "github.com/blevesearch/bleve/index/store/boltdb" +import "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" // in normal environments we configure boltdb as the default storage func initDisk() { diff --git a/document/document.go b/document/document.go index 6ac17b9ab..1a6050f0a 100644 --- a/document/document.go +++ b/document/document.go @@ -18,7 +18,8 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeDocument int @@ -29,14 +30,14 @@ func init() { } type Document struct { - ID string `json:"id"` + id string `json:"id"` Fields []Field `json:"fields"` CompositeFields []*CompositeField } func NewDocument(id string) *Document { return &Document{ - ID: id, + id: id, Fields: make([]Field, 0), CompositeFields: make([]*CompositeField, 0), } @@ -44,7 +45,7 @@ func NewDocument(id string) *Document { func (d *Document) Size() int { sizeInBytes := reflectStaticSizeDocument + size.SizeOfPtr + - len(d.ID) + len(d.id) for _, entry := range d.Fields { sizeInBytes += entry.Size() @@ -82,7 +83,7 @@ func (d *Document) GoString() string { } compositeFields += fmt.Sprintf("%#v", field) } - return fmt.Sprintf("&document.Document{ID:%s, Fields: %s, CompositeFields: %s}", d.ID, fields, compositeFields) + return fmt.Sprintf("&document.Document{ID:%s, Fields: %s, CompositeFields: %s}", d.ID(), fields, compositeFields) } func (d *Document) NumPlainTextBytes() uint64 { @@ -99,3 +100,31 @@ func (d *Document) NumPlainTextBytes() uint64 { } return rv } + +func (d *Document) ID() string { + return d.id +} + +func (d *Document) SetID(id string) { + d.id = id +} + +func (d *Document) AddIDField() { + d.AddField(NewTextFieldCustom("_id", nil, []byte(d.ID()), index.IndexField|index.StoreField, nil)) +} + +func (d *Document) VisitFields(visitor index.FieldVisitor) { + for _, f := range d.Fields { + visitor(f) + } +} + +func (d *Document) VisitComposite(visitor index.CompositeFieldVisitor) { + for _, f := range d.CompositeFields { + visitor(f) + } +} + +func (d *Document) HasComposite() bool { + return len(d.CompositeFields) > 0 +} diff --git a/document/document_test.go b/document/document_test.go index 7db862aed..22aff7a9f 100644 --- a/document/document_test.go +++ b/document/document_test.go @@ -67,7 +67,7 @@ func TestDocumentNumPlainTextBytes(t *testing.T) { for _, test := range tests { actual := test.doc.NumPlainTextBytes() if actual != test.num { - t.Errorf("expected doc '%s' to have %d plain text bytes, got %d", test.doc.ID, test.num, actual) + t.Errorf("expected doc '%s' to have %d plain text bytes, got %d", test.doc.ID(), test.num, actual) } } } diff --git a/document/field.go b/document/field.go index 2fe916698..eb104e2df 100644 --- a/document/field.go +++ b/document/field.go @@ -15,7 +15,7 @@ package document import ( - "github.com/blevesearch/bleve/analysis" + index "github.com/blevesearch/bleve_index_api" ) type Field interface { @@ -28,8 +28,8 @@ type Field interface { // arrays, ArrayPositions returns 2 indices used to resolve "doc2" value in // "doc1", then "field" in "doc2". ArrayPositions() []uint64 - Options() IndexingOptions - Analyze() (int, analysis.TokenFrequencies) + Options() index.FieldIndexingOptions + Analyze() Value() []byte // NumPlainTextBytes should return the number of plain text bytes @@ -38,4 +38,8 @@ type Field interface { NumPlainTextBytes() uint64 Size() int + + EncodedFieldType() byte + AnalyzedLength() int + AnalyzedTokenFrequencies() index.TokenFrequencies } diff --git a/document/field_boolean.go b/document/field_boolean.go index 6864b16f4..fdf3cc0e5 100644 --- a/document/field_boolean.go +++ b/document/field_boolean.go @@ -18,8 +18,9 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeBooleanField int @@ -29,14 +30,16 @@ func init() { reflectStaticSizeBooleanField = int(reflect.TypeOf(f).Size()) } -const DefaultBooleanIndexingOptions = StoreField | IndexField | DocValues +const DefaultBooleanIndexingOptions = index.StoreField | index.IndexField | index.DocValues type BooleanField struct { name string arrayPositions []uint64 - options IndexingOptions + options index.FieldIndexingOptions value []byte numPlainTextBytes uint64 + length int + frequencies index.TokenFrequencies } func (b *BooleanField) Size() int { @@ -54,11 +57,11 @@ func (b *BooleanField) ArrayPositions() []uint64 { return b.arrayPositions } -func (b *BooleanField) Options() IndexingOptions { +func (b *BooleanField) Options() index.FieldIndexingOptions { return b.options } -func (b *BooleanField) Analyze() (int, analysis.TokenFrequencies) { +func (b *BooleanField) Analyze() { tokens := make(analysis.TokenStream, 0) tokens = append(tokens, &analysis.Token{ Start: 0, @@ -68,9 +71,8 @@ func (b *BooleanField) Analyze() (int, analysis.TokenFrequencies) { Type: analysis.Boolean, }) - fieldLength := len(tokens) - tokenFreqs := analysis.TokenFrequency(tokens, b.arrayPositions, b.options.IncludeTermVectors()) - return fieldLength, tokenFreqs + b.length = len(tokens) + b.frequencies = analysis.TokenFrequency(tokens, b.arrayPositions, b.options) } func (b *BooleanField) Value() []byte { @@ -92,6 +94,18 @@ func (b *BooleanField) NumPlainTextBytes() uint64 { return b.numPlainTextBytes } +func (b *BooleanField) EncodedFieldType() byte { + return 'b' +} + +func (b *BooleanField) AnalyzedLength() int { + return b.length +} + +func (b *BooleanField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return b.frequencies +} + func NewBooleanFieldFromBytes(name string, arrayPositions []uint64, value []byte) *BooleanField { return &BooleanField{ name: name, @@ -106,7 +120,7 @@ func NewBooleanField(name string, arrayPositions []uint64, b bool) *BooleanField return NewBooleanFieldWithIndexingOptions(name, arrayPositions, b, DefaultNumericIndexingOptions) } -func NewBooleanFieldWithIndexingOptions(name string, arrayPositions []uint64, b bool, options IndexingOptions) *BooleanField { +func NewBooleanFieldWithIndexingOptions(name string, arrayPositions []uint64, b bool, options index.FieldIndexingOptions) *BooleanField { numPlainTextBytes := 5 v := []byte("F") if b { diff --git a/document/field_composite.go b/document/field_composite.go index a8285880f..8c47643f5 100644 --- a/document/field_composite.go +++ b/document/field_composite.go @@ -17,8 +17,8 @@ package document import ( "reflect" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeCompositeField int @@ -28,30 +28,30 @@ func init() { reflectStaticSizeCompositeField = int(reflect.TypeOf(cf).Size()) } -const DefaultCompositeIndexingOptions = IndexField +const DefaultCompositeIndexingOptions = index.IndexField type CompositeField struct { name string includedFields map[string]bool excludedFields map[string]bool defaultInclude bool - options IndexingOptions + options index.FieldIndexingOptions totalLength int - compositeFrequencies analysis.TokenFrequencies + compositeFrequencies index.TokenFrequencies } func NewCompositeField(name string, defaultInclude bool, include []string, exclude []string) *CompositeField { return NewCompositeFieldWithIndexingOptions(name, defaultInclude, include, exclude, DefaultCompositeIndexingOptions) } -func NewCompositeFieldWithIndexingOptions(name string, defaultInclude bool, include []string, exclude []string, options IndexingOptions) *CompositeField { +func NewCompositeFieldWithIndexingOptions(name string, defaultInclude bool, include []string, exclude []string, options index.FieldIndexingOptions) *CompositeField { rv := &CompositeField{ name: name, options: options, defaultInclude: defaultInclude, includedFields: make(map[string]bool, len(include)), excludedFields: make(map[string]bool, len(exclude)), - compositeFrequencies: make(analysis.TokenFrequencies), + compositeFrequencies: make(index.TokenFrequencies), } for _, i := range include { @@ -87,12 +87,11 @@ func (c *CompositeField) ArrayPositions() []uint64 { return []uint64{} } -func (c *CompositeField) Options() IndexingOptions { +func (c *CompositeField) Options() index.FieldIndexingOptions { return c.options } -func (c *CompositeField) Analyze() (int, analysis.TokenFrequencies) { - return c.totalLength, c.compositeFrequencies +func (c *CompositeField) Analyze() { } func (c *CompositeField) Value() []byte { @@ -116,9 +115,21 @@ func (c *CompositeField) includesField(field string) bool { return shouldInclude } -func (c *CompositeField) Compose(field string, length int, freq analysis.TokenFrequencies) { +func (c *CompositeField) Compose(field string, length int, freq index.TokenFrequencies) { if c.includesField(field) { c.totalLength += length c.compositeFrequencies.MergeAll(field, freq) } } + +func (c *CompositeField) EncodedFieldType() byte { + return 'c' +} + +func (c *CompositeField) AnalyzedLength() int { + return c.totalLength +} + +func (c *CompositeField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return c.compositeFrequencies +} diff --git a/document/field_datetime.go b/document/field_datetime.go index 583b44cde..650640550 100644 --- a/document/field_datetime.go +++ b/document/field_datetime.go @@ -20,9 +20,10 @@ import ( "reflect" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeDateTimeField int @@ -32,7 +33,7 @@ func init() { reflectStaticSizeDateTimeField = int(reflect.TypeOf(f).Size()) } -const DefaultDateTimeIndexingOptions = StoreField | IndexField | DocValues +const DefaultDateTimeIndexingOptions = index.StoreField | index.IndexField | index.DocValues const DefaultDateTimePrecisionStep uint = 4 var MinTimeRepresentable = time.Unix(0, math.MinInt64) @@ -41,9 +42,11 @@ var MaxTimeRepresentable = time.Unix(0, math.MaxInt64) type DateTimeField struct { name string arrayPositions []uint64 - options IndexingOptions + options index.FieldIndexingOptions value numeric.PrefixCoded numPlainTextBytes uint64 + length int + frequencies index.TokenFrequencies } func (n *DateTimeField) Size() int { @@ -60,11 +63,23 @@ func (n *DateTimeField) ArrayPositions() []uint64 { return n.arrayPositions } -func (n *DateTimeField) Options() IndexingOptions { +func (n *DateTimeField) Options() index.FieldIndexingOptions { return n.options } -func (n *DateTimeField) Analyze() (int, analysis.TokenFrequencies) { +func (n *DateTimeField) EncodedFieldType() byte { + return 'd' +} + +func (n *DateTimeField) AnalyzedLength() int { + return n.length +} + +func (n *DateTimeField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return n.frequencies +} + +func (n *DateTimeField) Analyze() { tokens := make(analysis.TokenStream, 0) tokens = append(tokens, &analysis.Token{ Start: 0, @@ -95,9 +110,8 @@ func (n *DateTimeField) Analyze() (int, analysis.TokenFrequencies) { } } - fieldLength := len(tokens) - tokenFreqs := analysis.TokenFrequency(tokens, n.arrayPositions, n.options.IncludeTermVectors()) - return fieldLength, tokenFreqs + n.length = len(tokens) + n.frequencies = analysis.TokenFrequency(tokens, n.arrayPositions, n.options) } func (n *DateTimeField) Value() []byte { @@ -134,7 +148,7 @@ func NewDateTimeField(name string, arrayPositions []uint64, dt time.Time) (*Date return NewDateTimeFieldWithIndexingOptions(name, arrayPositions, dt, DefaultDateTimeIndexingOptions) } -func NewDateTimeFieldWithIndexingOptions(name string, arrayPositions []uint64, dt time.Time, options IndexingOptions) (*DateTimeField, error) { +func NewDateTimeFieldWithIndexingOptions(name string, arrayPositions []uint64, dt time.Time, options index.FieldIndexingOptions) (*DateTimeField, error) { if canRepresent(dt) { dtInt64 := dt.UnixNano() prefixCoded := numeric.MustNewPrefixCodedInt64(dtInt64, 0) diff --git a/document/field_geopoint.go b/document/field_geopoint.go index 91fe23f96..89de4e3bf 100644 --- a/document/field_geopoint.go +++ b/document/field_geopoint.go @@ -18,10 +18,11 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/geo" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeGeoPointField int @@ -36,9 +37,11 @@ var GeoPrecisionStep uint = 9 type GeoPointField struct { name string arrayPositions []uint64 - options IndexingOptions + options index.FieldIndexingOptions value numeric.PrefixCoded numPlainTextBytes uint64 + length int + frequencies index.TokenFrequencies } func (n *GeoPointField) Size() int { @@ -55,11 +58,23 @@ func (n *GeoPointField) ArrayPositions() []uint64 { return n.arrayPositions } -func (n *GeoPointField) Options() IndexingOptions { +func (n *GeoPointField) Options() index.FieldIndexingOptions { return n.options } -func (n *GeoPointField) Analyze() (int, analysis.TokenFrequencies) { +func (n *GeoPointField) EncodedFieldType() byte { + return 'g' +} + +func (n *GeoPointField) AnalyzedLength() int { + return n.length +} + +func (n *GeoPointField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return n.frequencies +} + +func (n *GeoPointField) Analyze() { tokens := make(analysis.TokenStream, 0) tokens = append(tokens, &analysis.Token{ Start: 0, @@ -90,9 +105,8 @@ func (n *GeoPointField) Analyze() (int, analysis.TokenFrequencies) { } } - fieldLength := len(tokens) - tokenFreqs := analysis.TokenFrequency(tokens, n.arrayPositions, n.options.IncludeTermVectors()) - return fieldLength, tokenFreqs + n.length = len(tokens) + n.frequencies = analysis.TokenFrequency(tokens, n.arrayPositions, n.options) } func (n *GeoPointField) Value() []byte { @@ -137,7 +151,7 @@ func NewGeoPointField(name string, arrayPositions []uint64, lon, lat float64) *G return NewGeoPointFieldWithIndexingOptions(name, arrayPositions, lon, lat, DefaultNumericIndexingOptions) } -func NewGeoPointFieldWithIndexingOptions(name string, arrayPositions []uint64, lon, lat float64, options IndexingOptions) *GeoPointField { +func NewGeoPointFieldWithIndexingOptions(name string, arrayPositions []uint64, lon, lat float64, options index.FieldIndexingOptions) *GeoPointField { mhash := geo.MortonHash(lon, lat) prefixCoded := numeric.MustNewPrefixCodedInt64(int64(mhash), 0) return &GeoPointField{ diff --git a/document/field_geopoint_test.go b/document/field_geopoint_test.go index d705ac709..286026482 100644 --- a/document/field_geopoint_test.go +++ b/document/field_geopoint_test.go @@ -4,7 +4,9 @@ import "testing" func TestGeoPointField(t *testing.T) { gf := NewGeoPointField("loc", []uint64{}, 0.0015, 0.0015) - numTokens, tokenFreqs := gf.Analyze() + gf.Analyze() + numTokens := gf.AnalyzedLength() + tokenFreqs := gf.AnalyzedTokenFrequencies() if numTokens != 8 { t.Errorf("expected 8 tokens, got %d", numTokens) } diff --git a/document/field_numeric.go b/document/field_numeric.go index 46c685e84..a54b082b4 100644 --- a/document/field_numeric.go +++ b/document/field_numeric.go @@ -18,9 +18,10 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeNumericField int @@ -30,16 +31,18 @@ func init() { reflectStaticSizeNumericField = int(reflect.TypeOf(f).Size()) } -const DefaultNumericIndexingOptions = StoreField | IndexField | DocValues +const DefaultNumericIndexingOptions = index.StoreField | index.IndexField | index.DocValues const DefaultPrecisionStep uint = 4 type NumericField struct { name string arrayPositions []uint64 - options IndexingOptions + options index.FieldIndexingOptions value numeric.PrefixCoded numPlainTextBytes uint64 + length int + frequencies index.TokenFrequencies } func (n *NumericField) Size() int { @@ -56,11 +59,23 @@ func (n *NumericField) ArrayPositions() []uint64 { return n.arrayPositions } -func (n *NumericField) Options() IndexingOptions { +func (n *NumericField) Options() index.FieldIndexingOptions { return n.options } -func (n *NumericField) Analyze() (int, analysis.TokenFrequencies) { +func (n *NumericField) EncodedFieldType() byte { + return 'n' +} + +func (n *NumericField) AnalyzedLength() int { + return n.length +} + +func (n *NumericField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return n.frequencies +} + +func (n *NumericField) Analyze() { tokens := make(analysis.TokenStream, 0) tokens = append(tokens, &analysis.Token{ Start: 0, @@ -91,9 +106,8 @@ func (n *NumericField) Analyze() (int, analysis.TokenFrequencies) { } } - fieldLength := len(tokens) - tokenFreqs := analysis.TokenFrequency(tokens, n.arrayPositions, n.options.IncludeTermVectors()) - return fieldLength, tokenFreqs + n.length = len(tokens) + n.frequencies = analysis.TokenFrequency(tokens, n.arrayPositions, n.options) } func (n *NumericField) Value() []byte { @@ -130,7 +144,7 @@ func NewNumericField(name string, arrayPositions []uint64, number float64) *Nume return NewNumericFieldWithIndexingOptions(name, arrayPositions, number, DefaultNumericIndexingOptions) } -func NewNumericFieldWithIndexingOptions(name string, arrayPositions []uint64, number float64, options IndexingOptions) *NumericField { +func NewNumericFieldWithIndexingOptions(name string, arrayPositions []uint64, number float64, options index.FieldIndexingOptions) *NumericField { numberInt64 := numeric.Float64ToInt64(number) prefixCoded := numeric.MustNewPrefixCodedInt64(numberInt64, 0) return &NumericField{ diff --git a/document/field_numeric_test.go b/document/field_numeric_test.go index 5134f8ea6..5f36d6875 100644 --- a/document/field_numeric_test.go +++ b/document/field_numeric_test.go @@ -20,7 +20,9 @@ import ( func TestNumericField(t *testing.T) { nf := NewNumericField("age", []uint64{}, 3.4) - numTokens, tokenFreqs := nf.Analyze() + nf.Analyze() + numTokens := nf.AnalyzedLength() + tokenFreqs := nf.AnalyzedTokenFrequencies() if numTokens != 16 { t.Errorf("expected 16 tokens") } diff --git a/document/field_text.go b/document/field_text.go index 6bd74c712..924de532c 100644 --- a/document/field_text.go +++ b/document/field_text.go @@ -18,8 +18,9 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) var reflectStaticSizeTextField int @@ -29,15 +30,17 @@ func init() { reflectStaticSizeTextField = int(reflect.TypeOf(f).Size()) } -const DefaultTextIndexingOptions = IndexField | DocValues +const DefaultTextIndexingOptions = index.IndexField | index.DocValues type TextField struct { name string arrayPositions []uint64 - options IndexingOptions + options index.FieldIndexingOptions analyzer *analysis.Analyzer value []byte numPlainTextBytes uint64 + length int + frequencies index.TokenFrequencies } func (t *TextField) Size() int { @@ -55,11 +58,23 @@ func (t *TextField) ArrayPositions() []uint64 { return t.arrayPositions } -func (t *TextField) Options() IndexingOptions { +func (t *TextField) Options() index.FieldIndexingOptions { return t.options } -func (t *TextField) Analyze() (int, analysis.TokenFrequencies) { +func (t *TextField) EncodedFieldType() byte { + return 't' +} + +func (t *TextField) AnalyzedLength() int { + return t.length +} + +func (t *TextField) AnalyzedTokenFrequencies() index.TokenFrequencies { + return t.frequencies +} + +func (t *TextField) Analyze() { var tokens analysis.TokenStream if t.analyzer != nil { bytesToAnalyze := t.Value() @@ -81,9 +96,8 @@ func (t *TextField) Analyze() (int, analysis.TokenFrequencies) { }, } } - fieldLength := len(tokens) // number of tokens in this doc field - tokenFreqs := analysis.TokenFrequency(tokens, t.arrayPositions, t.options.IncludeTermVectors()) - return fieldLength, tokenFreqs + t.length = len(tokens) // number of tokens in this doc field + t.frequencies = analysis.TokenFrequency(tokens, t.arrayPositions, t.options) } func (t *TextField) Analyzer() *analysis.Analyzer { @@ -94,6 +108,10 @@ func (t *TextField) Value() []byte { return t.value } +func (t *TextField) Text() string { + return string(t.value) +} + func (t *TextField) GoString() string { return fmt.Sprintf("&document.TextField{Name:%s, Options: %s, Analyzer: %v, Value: %s, ArrayPositions: %v}", t.name, t.options, t.analyzer, t.value, t.arrayPositions) } @@ -106,7 +124,7 @@ func NewTextField(name string, arrayPositions []uint64, value []byte) *TextField return NewTextFieldWithIndexingOptions(name, arrayPositions, value, DefaultTextIndexingOptions) } -func NewTextFieldWithIndexingOptions(name string, arrayPositions []uint64, value []byte, options IndexingOptions) *TextField { +func NewTextFieldWithIndexingOptions(name string, arrayPositions []uint64, value []byte, options index.FieldIndexingOptions) *TextField { return &TextField{ name: name, arrayPositions: arrayPositions, @@ -127,7 +145,7 @@ func NewTextFieldWithAnalyzer(name string, arrayPositions []uint64, value []byte } } -func NewTextFieldCustom(name string, arrayPositions []uint64, value []byte, options IndexingOptions, analyzer *analysis.Analyzer) *TextField { +func NewTextFieldCustom(name string, arrayPositions []uint64, value []byte, options index.FieldIndexingOptions, analyzer *analysis.Analyzer) *TextField { return &TextField{ name: name, arrayPositions: arrayPositions, diff --git a/document/indexing_options.go b/document/indexing_options.go deleted file mode 100644 index 44498a8e9..000000000 --- a/document/indexing_options.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package document - -type IndexingOptions int - -const ( - IndexField IndexingOptions = 1 << iota - StoreField - IncludeTermVectors - DocValues -) - -func (o IndexingOptions) IsIndexed() bool { - return o&IndexField != 0 -} - -func (o IndexingOptions) IsStored() bool { - return o&StoreField != 0 -} - -func (o IndexingOptions) IncludeTermVectors() bool { - return o&IncludeTermVectors != 0 -} - -func (o IndexingOptions) IncludeDocValues() bool { - return o&DocValues != 0 -} - -func (o IndexingOptions) String() string { - rv := "" - if o.IsIndexed() { - rv += "INDEXED" - } - if o.IsStored() { - if rv != "" { - rv += ", " - } - rv += "STORE" - } - if o.IncludeTermVectors() { - if rv != "" { - rv += ", " - } - rv += "TV" - } - if o.IncludeDocValues() { - if rv != "" { - rv += ", " - } - rv += "DV" - } - return rv -} diff --git a/document/indexing_options_test.go b/document/indexing_options_test.go deleted file mode 100644 index d88c41070..000000000 --- a/document/indexing_options_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package document - -import ( - "testing" -) - -func TestIndexingOptions(t *testing.T) { - tests := []struct { - options IndexingOptions - isIndexed bool - isStored bool - includeTermVectors bool - docValues bool - }{ - { - options: IndexField | StoreField | IncludeTermVectors, - isIndexed: true, - isStored: true, - includeTermVectors: true, - docValues: false, - }, - { - options: IndexField | IncludeTermVectors, - isIndexed: true, - isStored: false, - includeTermVectors: true, - docValues: false, - }, - { - options: StoreField | IncludeTermVectors, - isIndexed: false, - isStored: true, - includeTermVectors: true, - docValues: false, - }, - { - options: IndexField, - isIndexed: true, - isStored: false, - includeTermVectors: false, - docValues: false, - }, - { - options: StoreField, - isIndexed: false, - isStored: true, - includeTermVectors: false, - docValues: false, - }, - { - options: DocValues, - isIndexed: false, - isStored: false, - includeTermVectors: false, - docValues: true, - }, - { - options: IndexField | StoreField | IncludeTermVectors | DocValues, - isIndexed: true, - isStored: true, - includeTermVectors: true, - docValues: true, - }, - } - - for _, test := range tests { - actuallyIndexed := test.options.IsIndexed() - if actuallyIndexed != test.isIndexed { - t.Errorf("expected indexed to be %v, got %v for %d", test.isIndexed, actuallyIndexed, test.options) - } - actuallyStored := test.options.IsStored() - if actuallyStored != test.isStored { - t.Errorf("expected stored to be %v, got %v for %d", test.isStored, actuallyStored, test.options) - } - actuallyIncludeTermVectors := test.options.IncludeTermVectors() - if actuallyIncludeTermVectors != test.includeTermVectors { - t.Errorf("expected includeTermVectors to be %v, got %v for %d", test.includeTermVectors, actuallyIncludeTermVectors, test.options) - } - actuallyDocValues := test.options.IncludeDocValues() - if actuallyDocValues != test.docValues { - t.Errorf("expected docValue to be %v, got %v for %d", test.docValues, actuallyDocValues, test.options) - } - } -} diff --git a/error.go b/error.go index 7402dfcf4..7dd21194c 100644 --- a/error.go +++ b/error.go @@ -20,7 +20,6 @@ const ( ErrorIndexPathDoesNotExist ErrorIndexMetaMissing ErrorIndexMetaCorrupt - ErrorUnknownStorageType ErrorIndexClosed ErrorAliasMulti ErrorAliasEmpty @@ -42,7 +41,6 @@ var errorMessages = map[Error]string{ ErrorIndexPathDoesNotExist: "cannot open index, path does not exist", ErrorIndexMetaMissing: "cannot open index, metadata missing", ErrorIndexMetaCorrupt: "cannot open index, metadata corrupt", - ErrorUnknownStorageType: "unknown storage type", ErrorIndexClosed: "index is closed", ErrorAliasMulti: "cannot perform single index operation on multiple index alias", ErrorAliasEmpty: "cannot perform operation on empty alias", diff --git a/examples_test.go b/examples_test.go index 3290f2431..a624b2605 100644 --- a/examples_test.go +++ b/examples_test.go @@ -20,9 +20,9 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight/highlighter/ansi" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight/highlighter/ansi" ) var indexMapping mapping.IndexMapping @@ -449,6 +449,7 @@ func ExampleSearchRequest_SortByCustom() { Field: "Age", Missing: search.SortFieldMissingFirst, }, + &search.SortDocID{}, }) searchResults, err := exampleIndex.Search(searchRequest) if err != nil { diff --git a/geo/geo.go b/geo/geo.go index b18ace433..55eace1df 100644 --- a/geo/geo.go +++ b/geo/geo.go @@ -18,7 +18,7 @@ import ( "fmt" "math" - "github.com/blevesearch/bleve/numeric" + "github.com/blevesearch/bleve/v2/numeric" ) // GeoBits is the number of bits used for a single geo point diff --git a/go.mod b/go.mod index 6300aea17..3ba4ec654 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,20 @@ -module github.com/blevesearch/bleve +module github.com/blevesearch/bleve/v2 go 1.13 require ( github.com/RoaringBitmap/roaring v0.4.23 - github.com/blevesearch/blevex v1.0.0 + github.com/blevesearch/bleve_index_api v1.0.0 github.com/blevesearch/go-porterstemmer v1.0.3 + github.com/blevesearch/scorch_segment_api v1.0.0 github.com/blevesearch/segment v0.9.0 github.com/blevesearch/snowballstem v0.9.0 - github.com/blevesearch/zap/v11 v11.0.14 - github.com/blevesearch/zap/v12 v12.0.14 - github.com/blevesearch/zap/v13 v13.0.6 - github.com/blevesearch/zap/v14 v14.0.5 - github.com/blevesearch/zap/v15 v15.0.3 + github.com/blevesearch/upsidedown_store_api v1.0.1 + github.com/blevesearch/zapx/v11 v11.1.10 + github.com/blevesearch/zapx/v12 v12.1.10 + github.com/blevesearch/zapx/v13 v13.1.10 + github.com/blevesearch/zapx/v14 v14.1.10 + github.com/blevesearch/zapx/v15 v15.1.10 github.com/couchbase/moss v0.1.0 github.com/couchbase/vellum v1.0.2 github.com/golang/protobuf v1.3.2 diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..f411283ba --- /dev/null +++ b/go.sum @@ -0,0 +1,128 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/RoaringBitmap/roaring v0.4.23 h1:gpyfd12QohbqhFO4NVDUdoPOCXsyahYRQhINmlHxKeo= +github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/blevesearch/bleve_index_api v1.0.0 h1:Ds3XeuTxjXCkG6pgIwWDRyooJKNIuOKemnN0N0IkhTU= +github.com/blevesearch/bleve_index_api v1.0.0/go.mod h1:fiwKS0xLEm+gBRgv5mumf0dhgFr2mDgZah1pqv1c1M4= +github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo= +github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M= +github.com/blevesearch/mmap-go v1.0.2 h1:JtMHb+FgQCTTYIhtMvimw15dJwu1Y5lrZDMOFXVWPk0= +github.com/blevesearch/mmap-go v1.0.2/go.mod h1:ol2qBqYaOUsGdm7aRMRrYGgPvnwLe6Y+7LMvAB5IbSA= +github.com/blevesearch/scorch_segment_api v1.0.0 h1:BUkCPWDg2gimTEyVDXf85I2buqqt4lh28uaVMiJsIYk= +github.com/blevesearch/scorch_segment_api v1.0.0/go.mod h1:KgRYmlfYC27NeM6cXOHx8LBgq7jn0atpV8mVWoBKBng= +github.com/blevesearch/segment v0.9.0 h1:5lG7yBCx98or7gK2cHMKPukPZ/31Kag7nONpoBt22Ac= +github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ= +github.com/blevesearch/snowballstem v0.9.0 h1:lMQ189YspGP6sXvZQ4WZ+MLawfV8wOmPoD/iWeNXm8s= +github.com/blevesearch/snowballstem v0.9.0/go.mod h1:PivSj3JMc8WuaFkTSRDW2SlrulNWPl4ABg1tC/hlgLs= +github.com/blevesearch/upsidedown_store_api v1.0.1 h1:1SYRwyoFLwG3sj0ed89RLtM15amfX2pXlYbFOnF8zNU= +github.com/blevesearch/upsidedown_store_api v1.0.1/go.mod h1:MQDVGpHZrpe3Uy26zJBf/a8h0FZY6xJbthIMm8myH2Q= +github.com/blevesearch/zapx/v11 v11.1.10 h1:8Eo3rXiHsVSP9Sk+4StrrwLrj9vyulhMVPmxTf8ZuDg= +github.com/blevesearch/zapx/v11 v11.1.10/go.mod h1:DTjbcBqrr/Uo82UBilDC8lEew42gN/OcIyiTNFtSijc= +github.com/blevesearch/zapx/v12 v12.1.10 h1:sqR+/0Z4dSTovApRqLA1HnilMtQer7a4UvPrNmPzlTM= +github.com/blevesearch/zapx/v12 v12.1.10/go.mod h1:14NmKnPrnKAIyiEJM566k/Jk+FQpuiflT5d3uaaK3MI= +github.com/blevesearch/zapx/v13 v13.1.10 h1:zCneEVRJDXwtDfSwh+33Dxguliv192vCK283zdGH4Sw= +github.com/blevesearch/zapx/v13 v13.1.10/go.mod h1:YsVY6YGpTEAlJOMjdL7EsdBLvjWd8kPa2gwJDNpqLJo= +github.com/blevesearch/zapx/v14 v14.1.10 h1:nD0vw2jxKogJFfA5WyoS4wNwZlVby3Aq8aW7CZi6YIw= +github.com/blevesearch/zapx/v14 v14.1.10/go.mod h1:hsULl5eJSxs5NEfBsmeT9qrqdCP+/ecpVZKt60M4V64= +github.com/blevesearch/zapx/v15 v15.1.10 h1:kZR3b9jO9l6s2B5UHI+1N1llLzJ4nYikkXQTMrDl1vQ= +github.com/blevesearch/zapx/v15 v15.1.10/go.mod h1:4ypq25bwtSQKzwEF1UERyIhmGTbMT3brY/n4NC5gRnM= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/couchbase/ghistogram v0.1.0 h1:b95QcQTCzjTUocDXp/uMgSNQi8oj1tGwnJ4bODWZnps= +github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k= +github.com/couchbase/moss v0.1.0 h1:HCL+xxHUwmOaL44kMM/gU08OW6QGCui1WVFO58bjhNI= +github.com/couchbase/moss v0.1.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37grCIubs= +github.com/couchbase/vellum v1.0.2 h1:BrbP0NKiyDdndMPec8Jjhy0U47CZ0Lgx3xUC2r9rZqw= +github.com/couchbase/vellum v1.0.2/go.mod h1:FcwrEivFpNi24R3jLOs3n+fs5RnuQnQqCLBJ1uAg1W4= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/kljensen/snowball v0.6.0 h1:6DZLCcZeL0cLfodx+Md4/OLC6b/bfurWUOUGs1ydfOU= +github.com/kljensen/snowball v0.6.0/go.mod h1:27N7E8fVU5H68RlUmnWwZCfxgt4POBJfENGMvNRhldw= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= +github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= +github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= +github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM= +github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= +github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/tinylib/msgp v1.1.0 h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU= +github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= +github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/http/debug.go b/http/debug.go index 99997f4a8..292a5392a 100644 --- a/http/debug.go +++ b/http/debug.go @@ -18,7 +18,7 @@ import ( "fmt" "net/http" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/index/upsidedown" ) // DebugDocumentHandler allows you to debug the index content @@ -57,7 +57,7 @@ func (h *DebugDocumentHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques docID = h.DocIDLookup(req) } - internalIndex, _, err := index.Advanced() + internalIndex, err := index.Advanced() if err != nil { showError(w, req, fmt.Sprintf("error getting index: %v", err), 500) return @@ -67,9 +67,14 @@ func (h *DebugDocumentHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques showError(w, req, fmt.Sprintf("error operning index reader: %v", err), 500) return } + upsideDownReader, ok := internalIndexReader.(*upsidedown.IndexReader) + if !ok { + showError(w, req, fmt.Sprintf("dump is only supported by index type upsidedown"), 500) + return + } var rv []interface{} - rowChan := internalIndexReader.DumpDoc(docID) + rowChan := upsideDownReader.DumpDoc(docID) for row := range rowChan { switch row := row.(type) { case error: diff --git a/http/doc_get.go b/http/doc_get.go index 7d174d790..6115433cd 100644 --- a/http/doc_get.go +++ b/http/doc_get.go @@ -16,10 +16,9 @@ package http import ( "fmt" + index "github.com/blevesearch/bleve_index_api" "net/http" "time" - - "github.com/blevesearch/bleve/document" ) type DocGetHandler struct { @@ -43,8 +42,8 @@ func (h *DocGetHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { if indexName == "" { indexName = h.defaultIndexName } - index := IndexByName(indexName) - if index == nil { + idx := IndexByName(indexName) + if idx == nil { showError(w, req, fmt.Sprintf("no such index '%s'", indexName), 404) return } @@ -59,7 +58,7 @@ func (h *DocGetHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - doc, err := index.Document(docID) + doc, err := idx.Document(docID) if err != nil { showError(w, req, fmt.Sprintf("error deleting document '%s': %v", docID, err), 500) return @@ -76,17 +75,18 @@ func (h *DocGetHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ID: docID, Fields: map[string]interface{}{}, } - for _, field := range doc.Fields { + + doc.VisitFields(func(field index.Field) { var newval interface{} switch field := field.(type) { - case *document.TextField: - newval = string(field.Value()) - case *document.NumericField: + case index.TextField: + newval = field.Text() + case index.NumericField: n, err := field.Number() if err == nil { newval = n } - case *document.DateTimeField: + case index.DateTimeField: d, err := field.DateTime() if err == nil { newval = d.Format(time.RFC3339Nano) @@ -106,7 +106,7 @@ func (h *DocGetHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } else { rv.Fields[field.Name()] = newval } - } + }) mustEncode(w, rv) } diff --git a/http/index_create.go b/http/index_create.go index 387cf8cbb..609e14f51 100644 --- a/http/index_create.go +++ b/http/index_create.go @@ -21,7 +21,7 @@ import ( "net/http" "os" - "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/v2" ) type CreateIndexHandler struct { diff --git a/http/index_get.go b/http/index_get.go index 88181702f..443c357e1 100644 --- a/http/index_get.go +++ b/http/index_get.go @@ -18,7 +18,7 @@ import ( "fmt" "net/http" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2/mapping" ) type GetIndexHandler struct { diff --git a/http/registry.go b/http/registry.go index 63a2a17e7..3bacb3b1b 100644 --- a/http/registry.go +++ b/http/registry.go @@ -18,7 +18,7 @@ import ( "fmt" "sync" - "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/v2" ) var indexNameMapping map[string]bleve.Index diff --git a/http/search.go b/http/search.go index e2bd09df7..c5f77ad35 100644 --- a/http/search.go +++ b/http/search.go @@ -20,8 +20,8 @@ import ( "io/ioutil" "net/http" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/search/query" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/search/query" ) // SearchHandler can handle search requests sent over HTTP diff --git a/index.go b/index.go index 974358b81..e08271e51 100644 --- a/index.go +++ b/index.go @@ -16,12 +16,12 @@ package bleve import ( "context" + "github.com/blevesearch/bleve/v2/index/upsidedown" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/size" + index "github.com/blevesearch/bleve_index_api" ) // A Batch groups together multiple Index and Delete @@ -71,7 +71,7 @@ func (b *Batch) TotalDocsSize() uint64 { // batch which skips the mapping. NOTE: the bleve Index is not updated // until the batch is executed. func (b *Batch) IndexAdvanced(doc *document.Document) (err error) { - if doc.ID == "" { + if doc.ID() == "" { return ErrorEmptyID } b.internal.Update(doc) @@ -216,7 +216,7 @@ type Index interface { // Document returns specified document or nil if the document is not // indexed or stored. - Document(id string) (*document.Document, error) + Document(id string) (index.Document, error) // DocCount returns the number of documents in the index. DocCount() (uint64, error) @@ -245,9 +245,8 @@ type Index interface { // SetName lets you assign your own logical name to this index SetName(string) - // Advanced returns the indexer and data store, exposing lower level - // methods to enumerate records and access data. - Advanced() (index.Index, store.KVStore, error) + // Advanced returns the internal index implementation + Advanced() (index.Index, error) } // New index at the specified path, must not exist. @@ -263,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, diff --git a/index/analysis.go b/index/analysis.go deleted file mode 100644 index 82883af01..000000000 --- a/index/analysis.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2015 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package index - -import ( - "reflect" - - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/size" -) - -var reflectStaticSizeAnalysisResult int - -func init() { - var ar AnalysisResult - reflectStaticSizeAnalysisResult = int(reflect.TypeOf(ar).Size()) -} - -type IndexRow interface { - KeySize() int - KeyTo([]byte) (int, error) - Key() []byte - - ValueSize() int - ValueTo([]byte) (int, error) - Value() []byte -} - -type AnalysisResult struct { - DocID string - Rows []IndexRow - - // scorch - Document *document.Document - Analyzed []analysis.TokenFrequencies - Length []int -} - -func (a *AnalysisResult) Size() int { - rv := reflectStaticSizeAnalysisResult - for _, analyzedI := range a.Analyzed { - rv += analyzedI.Size() - } - rv += len(a.Length) * size.SizeOfInt - return rv -} - -type AnalysisWork struct { - i Index - d *document.Document - rc chan *AnalysisResult -} - -func NewAnalysisWork(i Index, d *document.Document, rc chan *AnalysisResult) *AnalysisWork { - return &AnalysisWork{ - i: i, - d: d, - rc: rc, - } -} - -type AnalysisQueue struct { - queue chan *AnalysisWork - done chan struct{} -} - -func (q *AnalysisQueue) Queue(work *AnalysisWork) { - q.queue <- work -} - -func (q *AnalysisQueue) Close() { - close(q.done) -} - -func NewAnalysisQueue(numWorkers int) *AnalysisQueue { - rv := AnalysisQueue{ - queue: make(chan *AnalysisWork), - done: make(chan struct{}), - } - for i := 0; i < numWorkers; i++ { - go AnalysisWorker(rv) - } - return &rv -} - -func AnalysisWorker(q AnalysisQueue) { - // read work off the queue - for { - select { - case <-q.done: - return - case w := <-q.queue: - r := w.i.Analyze(w.d) - w.rc <- r - } - } -} diff --git a/index/index.go b/index/index.go deleted file mode 100644 index 551f8de84..000000000 --- a/index/index.go +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package index - -import ( - "bytes" - "encoding/json" - "fmt" - "reflect" - - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/size" -) - -var reflectStaticSizeTermFieldDoc int -var reflectStaticSizeTermFieldVector int - -func init() { - var tfd TermFieldDoc - reflectStaticSizeTermFieldDoc = int(reflect.TypeOf(tfd).Size()) - var tfv TermFieldVector - reflectStaticSizeTermFieldVector = int(reflect.TypeOf(tfv).Size()) -} - -var ErrorUnknownStorageType = fmt.Errorf("unknown storage type") - -type Index interface { - Open() error - Close() error - - Update(doc *document.Document) error - Delete(id string) error - Batch(batch *Batch) error - - SetInternal(key, val []byte) error - DeleteInternal(key []byte) error - - // Reader returns a low-level accessor on the index data. Close it to - // release associated resources. - Reader() (IndexReader, error) - - Stats() json.Marshaler - StatsMap() map[string]interface{} - - Analyze(d *document.Document) *AnalysisResult - - Advanced() (store.KVStore, error) -} - -type DocumentFieldTermVisitor func(field string, term []byte) - -type IndexReader interface { - TermFieldReader(term []byte, field string, includeFreq, includeNorm, includeTermVectors bool) (TermFieldReader, error) - - // DocIDReader returns an iterator over all doc ids - // The caller must close returned instance to release associated resources. - DocIDReaderAll() (DocIDReader, error) - - DocIDReaderOnly(ids []string) (DocIDReader, error) - - FieldDict(field string) (FieldDict, error) - - // FieldDictRange is currently defined to include the start and end terms - FieldDictRange(field string, startTerm []byte, endTerm []byte) (FieldDict, error) - FieldDictPrefix(field string, termPrefix []byte) (FieldDict, error) - - Document(id string) (*document.Document, error) - DocumentVisitFieldTerms(id IndexInternalID, fields []string, visitor DocumentFieldTermVisitor) error - - DocValueReader(fields []string) (DocValueReader, error) - - Fields() ([]string, error) - - GetInternal(key []byte) ([]byte, error) - - DocCount() (uint64, error) - - ExternalID(id IndexInternalID) (string, error) - InternalID(id string) (IndexInternalID, error) - - DumpAll() chan interface{} - DumpDoc(id string) chan interface{} - DumpFields() chan interface{} - - Close() error -} - -// The Regexp interface defines the subset of the regexp.Regexp API -// methods that are used by bleve indexes, allowing callers to pass in -// alternate implementations. -type Regexp interface { - FindStringIndex(s string) (loc []int) - - LiteralPrefix() (prefix string, complete bool) - - String() string -} - -type IndexReaderRegexp interface { - FieldDictRegexp(field string, regex string) (FieldDict, error) -} - -type IndexReaderFuzzy interface { - FieldDictFuzzy(field string, term string, fuzziness int, prefix string) (FieldDict, error) -} - -type IndexReaderOnly interface { - FieldDictOnly(field string, onlyTerms [][]byte, includeCount bool) (FieldDict, error) -} - -type IndexReaderContains interface { - FieldDictContains(field string) (FieldDictContains, error) -} - -// FieldTerms contains the terms used by a document, keyed by field -type FieldTerms map[string][]string - -// FieldsNotYetCached returns a list of fields not yet cached out of a larger list of fields -func (f FieldTerms) FieldsNotYetCached(fields []string) []string { - rv := make([]string, 0, len(fields)) - for _, field := range fields { - if _, ok := f[field]; !ok { - rv = append(rv, field) - } - } - return rv -} - -// Merge will combine two FieldTerms -// it assumes that the terms lists are complete (thus do not need to be merged) -// field terms from the other list always replace the ones in the receiver -func (f FieldTerms) Merge(other FieldTerms) { - for field, terms := range other { - f[field] = terms - } -} - -type TermFieldVector struct { - Field string - ArrayPositions []uint64 - Pos uint64 - Start uint64 - End uint64 -} - -func (tfv *TermFieldVector) Size() int { - return reflectStaticSizeTermFieldVector + size.SizeOfPtr + - len(tfv.Field) + len(tfv.ArrayPositions)*size.SizeOfUint64 -} - -// IndexInternalID is an opaque document identifier interal to the index impl -type IndexInternalID []byte - -func (id IndexInternalID) Equals(other IndexInternalID) bool { - return id.Compare(other) == 0 -} - -func (id IndexInternalID) Compare(other IndexInternalID) int { - return bytes.Compare(id, other) -} - -type TermFieldDoc struct { - Term string - ID IndexInternalID - Freq uint64 - Norm float64 - Vectors []*TermFieldVector -} - -func (tfd *TermFieldDoc) Size() int { - sizeInBytes := reflectStaticSizeTermFieldDoc + size.SizeOfPtr + - len(tfd.Term) + len(tfd.ID) - - for _, entry := range tfd.Vectors { - sizeInBytes += entry.Size() - } - - return sizeInBytes -} - -// Reset allows an already allocated TermFieldDoc to be reused -func (tfd *TermFieldDoc) Reset() *TermFieldDoc { - // remember the []byte used for the ID - id := tfd.ID - vectors := tfd.Vectors - // idiom to copy over from empty TermFieldDoc (0 allocations) - *tfd = TermFieldDoc{} - // reuse the []byte already allocated (and reset len to 0) - tfd.ID = id[:0] - tfd.Vectors = vectors[:0] - return tfd -} - -// TermFieldReader is the interface exposing the enumeration of documents -// containing a given term in a given field. Documents are returned in byte -// lexicographic order over their identifiers. -type TermFieldReader interface { - // Next returns the next document containing the term in this field, or nil - // when it reaches the end of the enumeration. The preAlloced TermFieldDoc - // is optional, and when non-nil, will be used instead of allocating memory. - Next(preAlloced *TermFieldDoc) (*TermFieldDoc, error) - - // Advance resets the enumeration at specified document or its immediate - // follower. - Advance(ID IndexInternalID, preAlloced *TermFieldDoc) (*TermFieldDoc, error) - - // Count returns the number of documents contains the term in this field. - Count() uint64 - Close() error - - Size() int -} - -type DictEntry struct { - Term string - Count uint64 -} - -type FieldDict interface { - Next() (*DictEntry, error) - Close() error -} - -type FieldDictContains interface { - Contains(key []byte) (bool, error) -} - -// DocIDReader is the interface exposing enumeration of documents identifiers. -// Close the reader to release associated resources. -type DocIDReader interface { - // Next returns the next document internal identifier in the natural - // index order, nil when the end of the sequence is reached. - Next() (IndexInternalID, error) - - // Advance resets the iteration to the first internal identifier greater than - // or equal to ID. If ID is smaller than the start of the range, the iteration - // will start there instead. If ID is greater than or equal to the end of - // the range, Next() call will return io.EOF. - Advance(ID IndexInternalID) (IndexInternalID, error) - - Size() int - - Close() error -} - -type BatchCallback func(error) - -type Batch struct { - IndexOps map[string]*document.Document - InternalOps map[string][]byte - persistedCallback BatchCallback -} - -func NewBatch() *Batch { - return &Batch{ - IndexOps: make(map[string]*document.Document), - InternalOps: make(map[string][]byte), - } -} - -func (b *Batch) Update(doc *document.Document) { - b.IndexOps[doc.ID] = doc -} - -func (b *Batch) Delete(id string) { - b.IndexOps[id] = nil -} - -func (b *Batch) SetInternal(key, val []byte) { - b.InternalOps[string(key)] = val -} - -func (b *Batch) DeleteInternal(key []byte) { - b.InternalOps[string(key)] = nil -} - -func (b *Batch) SetPersistedCallback(f BatchCallback) { - b.persistedCallback = f -} - -func (b *Batch) PersistedCallback() BatchCallback { - return b.persistedCallback -} - -func (b *Batch) String() string { - rv := fmt.Sprintf("Batch (%d ops, %d internal ops)\n", len(b.IndexOps), len(b.InternalOps)) - for k, v := range b.IndexOps { - if v != nil { - rv += fmt.Sprintf("\tINDEX - '%s'\n", k) - } else { - rv += fmt.Sprintf("\tDELETE - '%s'\n", k) - } - } - for k, v := range b.InternalOps { - if v != nil { - rv += fmt.Sprintf("\tSET INTERNAL - '%s'\n", k) - } else { - rv += fmt.Sprintf("\tDELETE INTERNAL - '%s'\n", k) - } - } - return rv -} - -func (b *Batch) Reset() { - b.IndexOps = make(map[string]*document.Document) - b.InternalOps = make(map[string][]byte) - b.persistedCallback = nil -} - -func (b *Batch) Merge(o *Batch) { - for k, v := range o.IndexOps { - b.IndexOps[k] = v - } - for k, v := range o.InternalOps { - b.InternalOps[k] = v - } -} - -func (b *Batch) TotalDocSize() int { - var s int - for k, v := range b.IndexOps { - if v != nil { - s += v.Size() + size.SizeOfString - } - s += len(k) - } - return s -} - -// Optimizable represents an optional interface that implementable by -// optimizable resources (e.g., TermFieldReaders, Searchers). These -// optimizable resources are provided the same OptimizableContext -// instance, so that they can coordinate via dynamic interface -// casting. -type Optimizable interface { - Optimize(kind string, octx OptimizableContext) (OptimizableContext, error) -} - -// Represents a result of optimization -- see the Finish() method. -type Optimized interface{} - -type OptimizableContext interface { - // Once all the optimzable resources have been provided the same - // OptimizableContext instance, the optimization preparations are - // finished or completed via the Finish() method. - // - // Depending on the optimization being performed, the Finish() - // method might return a non-nil Optimized instance. For example, - // the Optimized instance might represent an optimized - // TermFieldReader instance. - Finish() (Optimized, error) -} - -type DocValueReader interface { - VisitDocValues(id IndexInternalID, visitor DocumentFieldTermVisitor) error -} - -// IndexBuilder is an interface supported by some index schemes -// to allow direct write-only index building -type IndexBuilder interface { - Index(doc *document.Document) error - Close() error -} diff --git a/index/scorch/builder.go b/index/scorch/builder.go index 1f4b41d63..455c53578 100644 --- a/index/scorch/builder.go +++ b/index/scorch/builder.go @@ -21,9 +21,8 @@ import ( "sync" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" bolt "go.etcd.io/bbolt" ) @@ -40,7 +39,7 @@ type Builder struct { mergeMax int batch *index.Batch internal map[string][]byte - segPlugin segment.Plugin + segPlugin SegmentPlugin } func NewBuilder(config map[string]interface{}) (*Builder, error) { @@ -117,7 +116,7 @@ func (o *Builder) parseConfig(config map[string]interface{}) (err error) { // Index will place the document into the index. // It is invalid to index the same document multiple times. -func (o *Builder) Index(doc *document.Document) error { +func (o *Builder) Index(doc index.Document) error { o.m.Lock() defer o.m.Unlock() @@ -135,14 +134,14 @@ func (o *Builder) maybeFlushBatchLOCKED(moreThan int) error { } func (o *Builder) executeBatchLOCKED(batch *index.Batch) (err error) { - analysisResults := make([]*index.AnalysisResult, 0, len(batch.IndexOps)) + analysisResults := make([]index.Document, 0, len(batch.IndexOps)) for _, doc := range batch.IndexOps { if doc != nil { // insert _id field - doc.AddField(document.NewTextFieldCustom("_id", nil, []byte(doc.ID), document.IndexField|document.StoreField, nil)) + doc.AddIDField() // perform analysis directly - analysisResult := analyze(doc) - analysisResults = append(analysisResults, analysisResult) + analyze(doc) + analysisResults = append(analysisResults, doc) } } diff --git a/index/scorch/builder_test.go b/index/scorch/builder_test.go index 1d0ce7160..aaff060e9 100644 --- a/index/scorch/builder_test.go +++ b/index/scorch/builder_test.go @@ -20,8 +20,8 @@ import ( "os" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestBuilder(t *testing.T) { diff --git a/config/config_cld2.go b/index/scorch/empty.go similarity index 55% rename from config/config_cld2.go rename to index/scorch/empty.go index 15f74756e..7bda01aa4 100644 --- a/config/config_cld2.go +++ b/index/scorch/empty.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Couchbase, Inc. +// Copyright (c) 2020 Couchbase, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,10 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build cld2 full +package scorch -package config +import segment "github.com/blevesearch/scorch_segment_api" -import ( - _ "github.com/blevesearch/blevex/detectlang" -) +type emptyPostingsIterator struct{} + +func (e *emptyPostingsIterator) Next() (segment.Posting, error) { + return nil, nil +} + +func (e *emptyPostingsIterator) Advance(uint64) (segment.Posting, error) { + return nil, nil +} + +func (e *emptyPostingsIterator) Size() int { + return 0 +} + +var anEmptyPostingsIterator = &emptyPostingsIterator{} diff --git a/index/scorch/event_test.go b/index/scorch/event_test.go index 9d39332e9..ed1dd4d95 100644 --- a/index/scorch/event_test.go +++ b/index/scorch/event_test.go @@ -17,8 +17,8 @@ package scorch import ( "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestEventBatchIntroductionStart(t *testing.T) { diff --git a/index/scorch/field_dict_test.go b/index/scorch/field_dict_test.go index 8cffe9e62..6bca8e348 100644 --- a/index/scorch/field_dict_test.go +++ b/index/scorch/field_dict_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestIndexFieldDict(t *testing.T) { @@ -62,8 +62,8 @@ func TestIndexFieldDict(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextFieldWithAnalyzer("name", []uint64{}, []byte("test test test"), testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("prefix", []uint64{}, []byte("bob cat cats catting dog doggy zoo"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("prefix", []uint64{}, []byte("bob cat cats catting dog doggy zoo"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) diff --git a/index/scorch/int.go b/index/scorch/int.go new file mode 100644 index 000000000..4fa6d7f71 --- /dev/null +++ b/index/scorch/int.go @@ -0,0 +1,92 @@ +// Copyright 2014 The Cockroach Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +// implied. See the License for the specific language governing +// permissions and limitations under the License. + +// This code originated from: +// https://github.com/cockroachdb/cockroach/blob/2dd65dde5d90c157f4b93f92502ca1063b904e1d/pkg/util/encoding/encoding.go + +// Modified to not use pkg/errors + +package scorch + +import "fmt" + +const ( + // intMin is chosen such that the range of int tags does not overlap the + // ascii character set that is frequently used in testing. + intMin = 0x80 // 128 + intMaxWidth = 8 + intZero = intMin + intMaxWidth // 136 + intSmall = intMax - intZero - intMaxWidth // 109 + // intMax is the maximum int tag value. + intMax = 0xfd // 253 +) + +// encodeUvarintAscending encodes the uint64 value using a variable length +// (length-prefixed) representation. The length is encoded as a single +// byte indicating the number of encoded bytes (-8) to follow. See +// EncodeVarintAscending for rationale. The encoded bytes are appended to the +// supplied buffer and the final buffer is returned. +func encodeUvarintAscending(b []byte, v uint64) []byte { + switch { + case v <= intSmall: + return append(b, intZero+byte(v)) + case v <= 0xff: + return append(b, intMax-7, byte(v)) + case v <= 0xffff: + return append(b, intMax-6, byte(v>>8), byte(v)) + case v <= 0xffffff: + return append(b, intMax-5, byte(v>>16), byte(v>>8), byte(v)) + case v <= 0xffffffff: + return append(b, intMax-4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) + case v <= 0xffffffffff: + return append(b, intMax-3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), + byte(v)) + case v <= 0xffffffffffff: + return append(b, intMax-2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), + byte(v>>8), byte(v)) + case v <= 0xffffffffffffff: + return append(b, intMax-1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), + byte(v>>16), byte(v>>8), byte(v)) + default: + return append(b, intMax, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), + byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) + } +} + +// decodeUvarintAscending decodes a varint encoded uint64 from the input +// buffer. The remainder of the input buffer and the decoded uint64 +// are returned. +func decodeUvarintAscending(b []byte) ([]byte, uint64, error) { + if len(b) == 0 { + return nil, 0, fmt.Errorf("insufficient bytes to decode uvarint value") + } + length := int(b[0]) - intZero + b = b[1:] // skip length byte + if length <= intSmall { + return b, uint64(length), nil + } + length -= intSmall + if length < 0 || length > 8 { + return nil, 0, fmt.Errorf("invalid uvarint length of %d", length) + } else if len(b) < length { + return nil, 0, fmt.Errorf("insufficient bytes to decode uvarint value: %q", b) + } + var v uint64 + // It is faster to range over the elements in a slice than to index + // into the slice on each loop iteration. + for _, t := range b[:length] { + v = (v << 8) | uint64(t) + } + return b[length:], v, nil +} diff --git a/index/scorch/segment/int_test.go b/index/scorch/int_test.go similarity index 61% rename from index/scorch/segment/int_test.go rename to index/scorch/int_test.go index 449f4a07e..2a469a175 100644 --- a/index/scorch/segment/int_test.go +++ b/index/scorch/int_test.go @@ -17,11 +17,10 @@ // Modified to only test the parts we borrowed -package segment +package scorch import ( "bytes" - "encoding/binary" "math" "testing" ) @@ -32,7 +31,7 @@ type testCaseUint64 struct { } func TestEncodeDecodeUvarint(t *testing.T) { - testBasicEncodeDecodeUint64(EncodeUvarintAscending, DecodeUvarintAscending, false, t) + testBasicEncodeDecodeUint64(encodeUvarintAscending, decodeUvarintAscending, false, t) testCases := []testCaseUint64{ {0, []byte{0x88}}, {1, []byte{0x89}}, @@ -41,7 +40,7 @@ func TestEncodeDecodeUvarint(t *testing.T) { {1 << 8, []byte{0xf7, 0x01, 0x00}}, {math.MaxUint64, []byte{0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, } - testCustomEncodeUint64(testCases, EncodeUvarintAscending, t) + testCustomEncodeUint64(testCases, encodeUvarintAscending, t) } func testBasicEncodeDecodeUint64( @@ -94,74 +93,4 @@ func testCustomEncodeUint64( t.Errorf("expected [% x]; got [% x] (value: %d)", test.expEnc, enc, test.value) } } -} - -func BenchmarkUvarint(b *testing.B) { - n, buf := generateCommonUvarints(64, 512) - - reader := bytes.NewReader(buf) - seen := 0 - - b.ResetTimer() - - for i := 0; i < b.N; i = i + 1 { - if seen >= n { - reader.Reset(buf) - seen = 0 - } - - _, _ = binary.ReadUvarint(reader) - seen = seen + 1 - } -} - -func BenchmarkMemUvarintReader(b *testing.B) { - n, buf := generateCommonUvarints(64, 512) - - reader := &MemUvarintReader{S: buf} - seen := 0 - - b.ResetTimer() - - for i := 0; i < b.N; i = i + 1 { - if seen >= n { - reader.Reset(buf) - seen = 0 - } - - _, _ = reader.ReadUvarint() - seen = seen + 1 - } -} - -// generate some common, encoded uvarint's that we might see as -// freq-norm's or locations. -func generateCommonUvarints(maxFreq, maxFieldLen int) (n int, rv []byte) { - buf := make([]byte, binary.MaxVarintLen64) - - var out bytes.Buffer - - encode := func(val uint64) { - bufLen := binary.PutUvarint(buf, val) - out.Write(buf[:bufLen]) - n = n + 1 - } - - for i := 1; i < maxFreq; i = i * 2 { // Common freqHasLoc's. - freqHasLocs := uint64(i << 1) - encode(freqHasLocs) - encode(freqHasLocs | 0x01) // 0'th LSB encodes whether there are locations. - } - - encodeNorm := func(fieldLen int) { - norm := float32(1.0 / math.Sqrt(float64(fieldLen))) - normUint64 := uint64(math.Float32bits(float32(norm))) - encode(normUint64) - } - - for i := 1; i < maxFieldLen; i = i * 2 { // Common norm's. - encodeNorm(i) - } - - return n, out.Bytes() -} +} \ No newline at end of file diff --git a/index/scorch/introducer.go b/index/scorch/introducer.go index 7770c41c5..4f71048fd 100644 --- a/index/scorch/introducer.go +++ b/index/scorch/introducer.go @@ -19,8 +19,8 @@ import ( "sync/atomic" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" ) type segmentIntroduction struct { diff --git a/index/scorch/merge.go b/index/scorch/merge.go index 56c0953f4..5cd41ae8a 100644 --- a/index/scorch/merge.go +++ b/index/scorch/merge.go @@ -24,8 +24,8 @@ import ( "time" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index/scorch/mergeplan" - "github.com/blevesearch/bleve/index/scorch/segment" + "github.com/blevesearch/bleve/v2/index/scorch/mergeplan" + segment "github.com/blevesearch/scorch_segment_api" ) func (s *Scorch) mergerLoop() { diff --git a/index/scorch/merge_test.go b/index/scorch/merge_test.go index 41f6892e7..b3783c6c3 100644 --- a/index/scorch/merge_test.go +++ b/index/scorch/merge_test.go @@ -19,8 +19,8 @@ import ( "sync/atomic" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestObsoleteSegmentMergeIntroduction(t *testing.T) { diff --git a/index/scorch/optimize.go b/index/scorch/optimize.go index 658354cd7..8575613b5 100644 --- a/index/scorch/optimize.go +++ b/index/scorch/optimize.go @@ -17,8 +17,8 @@ package scorch import ( "fmt" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" "sync/atomic" ) @@ -174,9 +174,9 @@ OUTER: var docNum1HitLastOk bool for _, tfr := range o.tfrs { - if _, ok := tfr.iterators[i].(*segment.EmptyPostingsIterator); ok { + if _, ok := tfr.iterators[i].(*emptyPostingsIterator); ok { // An empty postings iterator means the entire AND is empty. - oTFR.iterators[i] = segment.AnEmptyPostingsIterator + oTFR.iterators[i] = anEmptyPostingsIterator continue OUTER } @@ -193,7 +193,7 @@ OUTER: if docNum1HitLastOk && docNum1HitLast != docNum1Hit { // The docNum1Hit doesn't match the previous // docNum1HitLast, so the entire AND is empty. - oTFR.iterators[i] = segment.AnEmptyPostingsIterator + oTFR.iterators[i] = anEmptyPostingsIterator continue OUTER } @@ -205,7 +205,7 @@ OUTER: if itr.ActualBitmap() == nil { // An empty actual bitmap means the entire AND is empty. - oTFR.iterators[i] = segment.AnEmptyPostingsIterator + oTFR.iterators[i] = anEmptyPostingsIterator continue OUTER } @@ -221,14 +221,14 @@ OUTER: if !bm.Contains(uint32(docNum1HitLast)) { // The docNum1Hit isn't in one of our actual // bitmaps, so the entire AND is empty. - oTFR.iterators[i] = segment.AnEmptyPostingsIterator + oTFR.iterators[i] = anEmptyPostingsIterator continue OUTER } } // The actual bitmaps and docNum1Hits all contain or have // the same 1-hit docNum, so that's our AND'ed result. - oTFR.iterators[i] = segment.NewUnadornedPostingsIteratorFrom1Hit(docNum1HitLast) + oTFR.iterators[i] = newUnadornedPostingsIteratorFrom1Hit(docNum1HitLast) continue OUTER } @@ -236,13 +236,13 @@ OUTER: if len(actualBMs) == 0 { // If we've collected no actual bitmaps at this point, // then the entire AND is empty. - oTFR.iterators[i] = segment.AnEmptyPostingsIterator + oTFR.iterators[i] = anEmptyPostingsIterator continue OUTER } if len(actualBMs) == 1 { // If we've only 1 actual bitmap, then that's our result. - oTFR.iterators[i] = segment.NewUnadornedPostingsIteratorFromBitmap(actualBMs[0]) + oTFR.iterators[i] = newUnadornedPostingsIteratorFromBitmap(actualBMs[0]) continue OUTER } @@ -254,7 +254,7 @@ OUTER: bm.And(actualBM) } - oTFR.iterators[i] = segment.NewUnadornedPostingsIteratorFromBitmap(bm) + oTFR.iterators[i] = newUnadornedPostingsIteratorFromBitmap(bm) } atomic.AddUint64(&o.snapshot.parent.stats.TotTermSearchersStarted, uint64(1)) @@ -369,7 +369,7 @@ func (o *OptimizeTFRDisjunctionUnadorned) Finish() (rv index.Optimized, err erro bm.AddMany(docNums) - oTFR.iterators[i] = segment.NewUnadornedPostingsIteratorFromBitmap(bm) + oTFR.iterators[i] = newUnadornedPostingsIteratorFromBitmap(bm) } atomic.AddUint64(&o.snapshot.parent.stats.TotTermSearchersStarted, uint64(1)) diff --git a/index/scorch/persister.go b/index/scorch/persister.go index 498378a4f..d58a4b8e7 100644 --- a/index/scorch/persister.go +++ b/index/scorch/persister.go @@ -30,8 +30,8 @@ import ( "time" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" bolt "go.etcd.io/bbolt" ) @@ -429,12 +429,12 @@ func (s *Scorch) persistSnapshotMaybeMerge(snapshot *IndexSnapshot) ( } func prepareBoltSnapshot(snapshot *IndexSnapshot, tx *bolt.Tx, path string, - segPlugin segment.Plugin) ([]string, map[uint64]string, error) { + segPlugin SegmentPlugin) ([]string, map[uint64]string, error) { snapshotsBucket, err := tx.CreateBucketIfNotExists(boltSnapshotsBucket) if err != nil { return nil, nil, err } - newSnapshotKey := segment.EncodeUvarintAscending(nil, snapshot.epoch) + newSnapshotKey := encodeUvarintAscending(nil, snapshot.epoch) snapshotBucket, err := snapshotsBucket.CreateBucketIfNotExists(newSnapshotKey) if err != nil { return nil, nil, err @@ -474,7 +474,7 @@ func prepareBoltSnapshot(snapshot *IndexSnapshot, tx *bolt.Tx, path string, // first ensure that each segment in this snapshot has been persisted for _, segmentSnapshot := range snapshot.segment { - snapshotSegmentKey := segment.EncodeUvarintAscending(nil, segmentSnapshot.id) + snapshotSegmentKey := encodeUvarintAscending(nil, segmentSnapshot.id) snapshotSegmentBucket, err := snapshotBucket.CreateBucketIfNotExists(snapshotSegmentKey) if err != nil { return nil, nil, err @@ -628,7 +628,7 @@ func (s *Scorch) loadFromBolt() error { foundRoot := false c := snapshots.Cursor() for k, _ := c.Last(); k != nil; k, _ = c.Prev() { - _, snapshotEpoch, err := segment.DecodeUvarintAscending(k) + _, snapshotEpoch, err := decodeUvarintAscending(k) if err != nil { log.Printf("unable to parse segment epoch %x, continuing", k) continue @@ -680,7 +680,7 @@ func (s *Scorch) LoadSnapshot(epoch uint64) (rv *IndexSnapshot, err error) { if snapshots == nil { return nil } - snapshotKey := segment.EncodeUvarintAscending(nil, epoch) + snapshotKey := encodeUvarintAscending(nil, epoch) snapshot := snapshots.Bucket(snapshotKey) if snapshot == nil { return fmt.Errorf("snapshot with epoch: %v - doesn't exist", epoch) @@ -744,7 +744,7 @@ func (s *Scorch) loadSnapshot(snapshot *bolt.Bucket) (*IndexSnapshot, error) { _ = rv.DecRef() return nil, fmt.Errorf("failed to load segment: %v", err) } - _, segmentSnapshot.id, err = segment.DecodeUvarintAscending(k) + _, segmentSnapshot.id, err = decodeUvarintAscending(k) if err != nil { _ = rv.DecRef() return nil, fmt.Errorf("failed to decode segment id: %v", err) @@ -865,7 +865,7 @@ func (s *Scorch) removeOldBoltSnapshots() (numRemoved int, err error) { } for _, epochToRemove := range epochsToRemove { - k := segment.EncodeUvarintAscending(nil, epochToRemove) + k := encodeUvarintAscending(nil, epochToRemove) err = snapshots.DeleteBucket(k) if err == bolt.ErrBucketNotFound { err = nil @@ -941,7 +941,7 @@ func (s *Scorch) RootBoltSnapshotEpochs() ([]uint64, error) { } sc := snapshots.Cursor() for sk, _ := sc.Last(); sk != nil; sk, _ = sc.Prev() { - _, snapshotEpoch, err := segment.DecodeUvarintAscending(sk) + _, snapshotEpoch, err := decodeUvarintAscending(sk) if err != nil { continue } diff --git a/index/scorch/reader_test.go b/index/scorch/reader_test.go index a1d612b5f..e1bca049c 100644 --- a/index/scorch/reader_test.go +++ b/index/scorch/reader_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestIndexReader(t *testing.T) { @@ -63,7 +63,7 @@ func TestIndexReader(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextFieldWithAnalyzer("name", []uint64{}, []byte("test test test"), testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -258,7 +258,7 @@ func TestIndexDocIdReader(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextField("name", []uint64{}, []byte("test test test"))) - doc.AddField(document.NewTextFieldWithIndexingOptions("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) diff --git a/index/scorch/segment/regexp.go b/index/scorch/regexp.go similarity index 75% rename from index/scorch/segment/regexp.go rename to index/scorch/regexp.go index 3a31f4149..6c43d99e2 100644 --- a/index/scorch/segment/regexp.go +++ b/index/scorch/regexp.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Couchbase, Inc. +// Copyright (c) 2020 Couchbase, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package segment +package scorch import ( "regexp/syntax" @@ -20,7 +20,7 @@ import ( "github.com/couchbase/vellum/regexp" ) -func ParseRegexp(pattern string) (a *regexp.Regexp, prefixBeg, prefixEnd []byte, err error) { +func parseRegexp(pattern string) (a *regexp.Regexp, prefixBeg, prefixEnd []byte, err error) { // TODO: potential optimization where syntax.Regexp supports a Simplify() API? parsed, err := syntax.Parse(pattern, syntax.Perl) @@ -33,10 +33,10 @@ func ParseRegexp(pattern string) (a *regexp.Regexp, prefixBeg, prefixEnd []byte, return nil, nil, nil, err } - prefix := LiteralPrefix(parsed) + prefix := literalPrefix(parsed) if prefix != "" { prefixBeg := []byte(prefix) - prefixEnd := IncrementBytes(prefixBeg) + prefixEnd := calculateExclusiveEndFromPrefix(prefixBeg) return re, prefixBeg, prefixEnd, nil } @@ -44,7 +44,7 @@ func ParseRegexp(pattern string) (a *regexp.Regexp, prefixBeg, prefixEnd []byte, } // Returns the literal prefix given the parse tree for a regexp -func LiteralPrefix(s *syntax.Regexp) string { +func literalPrefix(s *syntax.Regexp) string { // traverse the left-most branch in the parse tree as long as the // node represents a concatenation for s != nil && s.Op == syntax.OpConcat { @@ -61,15 +61,3 @@ func LiteralPrefix(s *syntax.Regexp) string { return "" // no literal prefix } - -func IncrementBytes(in []byte) []byte { - rv := make([]byte, len(in)) - copy(rv, in) - for i := len(rv) - 1; i >= 0; i-- { - rv[i] = rv[i] + 1 - if rv[i] != 0 { - return rv // didn't overflow, so stop - } - } - return nil // overflowed -} diff --git a/index/scorch/segment/regexp_test.go b/index/scorch/regexp_test.go similarity index 94% rename from index/scorch/segment/regexp_test.go rename to index/scorch/regexp_test.go index 887476b28..305b20ce4 100644 --- a/index/scorch/segment/regexp_test.go +++ b/index/scorch/regexp_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Couchbase, Inc. +// Copyright (c) 2020 Couchbase, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package segment +package scorch import ( "regexp/syntax" @@ -49,7 +49,7 @@ func TestLiteralPrefix(t *testing.T) { t.Fatalf("expected no syntax.Parse error, got: %v", err) } - got := LiteralPrefix(s) + got := literalPrefix(s) if test.expected != got { t.Fatalf("test: %d, %+v, got: %s", i, test, got) } diff --git a/index/scorch/rollback.go b/index/scorch/rollback.go index 7cc87bdea..067220e6f 100644 --- a/index/scorch/rollback.go +++ b/index/scorch/rollback.go @@ -19,7 +19,6 @@ import ( "log" "os" - "github.com/blevesearch/bleve/index/scorch/segment" bolt "go.etcd.io/bbolt" ) @@ -71,7 +70,7 @@ func RollbackPoints(path string) ([]*RollbackPoint, error) { c1 := snapshots.Cursor() for k, _ := c1.Last(); k != nil; k, _ = c1.Prev() { - _, snapshotEpoch, err := segment.DecodeUvarintAscending(k) + _, snapshotEpoch, err := decodeUvarintAscending(k) if err != nil { log.Printf("RollbackPoints:"+ " unable to parse segment epoch %x, continuing", k) @@ -154,7 +153,7 @@ func Rollback(path string, to *RollbackPoint) error { } sc := snapshots.Cursor() for sk, _ := sc.Last(); sk != nil && !found; sk, _ = sc.Prev() { - _, snapshotEpoch, err := segment.DecodeUvarintAscending(sk) + _, snapshotEpoch, err := decodeUvarintAscending(sk) if err != nil { continue } @@ -195,7 +194,7 @@ func Rollback(path string, to *RollbackPoint) error { return nil } for _, epoch := range eligibleEpochs { - k := segment.EncodeUvarintAscending(nil, epoch) + k := encodeUvarintAscending(nil, epoch) if err != nil { continue } diff --git a/index/scorch/rollback_test.go b/index/scorch/rollback_test.go index e137e0f09..183e5347c 100644 --- a/index/scorch/rollback_test.go +++ b/index/scorch/rollback_test.go @@ -17,8 +17,8 @@ package scorch import ( "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" ) func TestIndexRollback(t *testing.T) { diff --git a/index/scorch/scorch.go b/index/scorch/scorch.go index fccff67ab..99c345bee 100644 --- a/index/scorch/scorch.go +++ b/index/scorch/scorch.go @@ -24,12 +24,9 @@ import ( "time" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/registry" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" bolt "go.etcd.io/bbolt" ) @@ -75,7 +72,7 @@ type Scorch struct { forceMergeRequestCh chan *mergerCtrl - segPlugin segment.Plugin + segPlugin SegmentPlugin } type internalStats struct { @@ -293,7 +290,7 @@ func (s *Scorch) Close() (err error) { return } -func (s *Scorch) Update(doc *document.Document) error { +func (s *Scorch) Update(doc index.Document) error { b := index.NewBatch() b.Update(doc) return s.Batch(b) @@ -313,7 +310,7 @@ func (s *Scorch) Batch(batch *index.Batch) (err error) { s.fireEvent(EventKindBatchIntroduction, time.Since(start)) }() - resultChan := make(chan *index.AnalysisResult, len(batch.IndexOps)) + resultChan := make(chan index.Document, len(batch.IndexOps)) var numUpdates uint64 var numDeletes uint64 @@ -322,7 +319,7 @@ func (s *Scorch) Batch(batch *index.Batch) (err error) { for docID, doc := range batch.IndexOps { if doc != nil { // insert _id field - doc.AddField(document.NewTextFieldCustom("_id", nil, []byte(doc.ID), document.IndexField|document.StoreField, nil)) + doc.AddIDField() numUpdates++ numPlainTextBytes += doc.NumPlainTextBytes() } else { @@ -335,18 +332,21 @@ func (s *Scorch) Batch(batch *index.Batch) (err error) { if numUpdates > 0 { go func() { - for _, doc := range batch.IndexOps { + for k := range batch.IndexOps { + doc := batch.IndexOps[k] if doc != nil { - aw := index.NewAnalysisWork(s, doc, resultChan) // put the work on the queue - s.analysisQueue.Queue(aw) + s.analysisQueue.Queue(func() { + analyze(doc) + resultChan <- doc + }) } } }() } // wait for analysis result - analysisResults := make([]*index.AnalysisResult, int(numUpdates)) + analysisResults := make([]index.Document, int(numUpdates)) var itemsDeQueued uint64 var totalAnalysisSize int for itemsDeQueued < numUpdates { @@ -566,37 +566,19 @@ func (s *Scorch) StatsMap() map[string]interface{} { return m } -func (s *Scorch) Analyze(d *document.Document) *index.AnalysisResult { - return analyze(d) -} - -func analyze(d *document.Document) *index.AnalysisResult { - rv := &index.AnalysisResult{ - Document: d, - Analyzed: make([]analysis.TokenFrequencies, len(d.Fields)+len(d.CompositeFields)), - Length: make([]int, len(d.Fields)+len(d.CompositeFields)), - } - - for i, field := range d.Fields { +func analyze(d index.Document) { + d.VisitFields(func(field index.Field) { if field.Options().IsIndexed() { - fieldLength, tokenFreqs := field.Analyze() - rv.Analyzed[i] = tokenFreqs - rv.Length[i] = fieldLength + field.Analyze() - if len(d.CompositeFields) > 0 && field.Name() != "_id" { + if d.HasComposite() && field.Name() != "_id" { // see if any of the composite fields need this - for _, compositeField := range d.CompositeFields { - compositeField.Compose(field.Name(), fieldLength, tokenFreqs) - } + d.VisitComposite(func(cf index.CompositeField) { + cf.Compose(field.Name(), field.AnalyzedLength(), field.AnalyzedTokenFrequencies()) + }) } } - } - - return rv -} - -func (s *Scorch) Advanced() (store.KVStore, error) { - return nil, nil + }) } func (s *Scorch) AddEligibleForRemoval(epoch uint64) { diff --git a/index/scorch/scorch_test.go b/index/scorch/scorch_test.go index 5f0ec1b75..38cd70e63 100644 --- a/index/scorch/scorch_test.go +++ b/index/scorch/scorch_test.go @@ -28,14 +28,14 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/analyzer/keyword" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - regexpTokenizer "github.com/blevesearch/bleve/analysis/tokenizer/regexp" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/mergeplan" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/analyzer/keyword" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + regexpTokenizer "github.com/blevesearch/bleve/v2/analysis/tokenizer/regexp" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/scorch/mergeplan" + "github.com/blevesearch/bleve/v2/mapping" ) func init() { @@ -754,7 +754,7 @@ func TestIndexInsertWithStore(t *testing.T) { } doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -788,11 +788,14 @@ func TestIndexInsertWithStore(t *testing.T) { } }() - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) + + if len(storedDoc.Fields) != 1 { t.Errorf("expected 1 stored field, got %d", len(storedDoc.Fields)) } @@ -1138,9 +1141,9 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { } doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - df, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + df, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -1172,11 +1175,13 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { t.Error(err) } - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) + err = indexReader.Close() if err != nil { t.Error(err) @@ -1228,8 +1233,8 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { // now update the document, but omit one of the fields doc = document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testup"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 36.99, document.IndexField|document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testup"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 36.99, index.IndexField|index.StoreField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1250,11 +1255,13 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { } // should only get 2 fields back now though - storedDoc, err = indexReader2.Document("1") + storedDocInt, err = indexReader2.Document("1") if err != nil { t.Error(err) } + storedDoc = storedDocInt.(*document.Document) + err = indexReader2.Close() if err != nil { t.Error(err) @@ -1344,9 +1351,9 @@ func TestIndexInsertFields(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -1418,9 +1425,9 @@ func TestIndexUpdateComposites(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1428,9 +1435,9 @@ func TestIndexUpdateComposites(t *testing.T) { // now lets update it doc = document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testupdated"), document.IndexField|document.StoreField)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("misterupdated"), document.IndexField|document.StoreField)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testupdated"), index.IndexField|index.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("misterupdated"), index.IndexField|index.StoreField)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1448,10 +1455,11 @@ func TestIndexUpdateComposites(t *testing.T) { }() // make sure new values are in index - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) if len(storedDoc.Fields) != 2 { t.Errorf("expected 2 stored field, got %d", len(storedDoc.Fields)) } @@ -1500,9 +1508,9 @@ func TestIndexTermReaderCompositeFields(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1540,7 +1548,7 @@ func TestIndexTermReaderCompositeFields(t *testing.T) { } } -func TestIndexDocumentVisitFieldTerms(t *testing.T) { +func TestIndexDocValueReader(t *testing.T) { cfg := CreateConfig("TestIndexDocumentVisitFieldTerms") err := InitTest(cfg) if err != nil { @@ -1570,8 +1578,8 @@ func TestIndexDocumentVisitFieldTerms(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1588,29 +1596,34 @@ func TestIndexDocumentVisitFieldTerms(t *testing.T) { } }() - fieldTerms := make(index.FieldTerms) + actualFieldTerms := make(fieldTerms) internalID, err := indexReader.InternalID("1") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(internalID, []string{"name", "title"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + dvr, err := indexReader.DocValueReader([]string{"name", "title"}) + if err != nil { + t.Error(err) + } + + err = dvr.VisitDocValues(internalID, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms := index.FieldTerms{ + expectedFieldTerms := fieldTerms{ "name": []string{"test"}, "title": []string{"mister"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } } -func TestFieldTermsConcurrent(t *testing.T) { +func TestDocValueReaderConcurrent(t *testing.T) { cfg := CreateConfig("TestFieldTermsConcurrent") // setting path to empty string disables persistence/merging @@ -1681,9 +1694,11 @@ func TestFieldTermsConcurrent(t *testing.T) { if err != nil { t.Fatal(err) } - err = r.DocumentVisitFieldTerms(docNumber, - []string{fmt.Sprintf("f%d", rand.Intn(100))}, - func(field string, term []byte) {}) + dvr, err := r.DocValueReader([]string{fmt.Sprintf("f%d", rand.Intn(100))}) + if err != nil { + t.Fatal(err) + } + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) {}) if err != nil { t.Fatal(err) } @@ -1729,7 +1744,7 @@ func TestConcurrentUpdate(t *testing.T) { wg.Add(1) go func(i int) { doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions(strconv.Itoa(i), []uint64{}, []byte(strconv.Itoa(i)), document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions(strconv.Itoa(i), []uint64{}, []byte(strconv.Itoa(i)), index.StoreField)) err := idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1751,11 +1766,13 @@ func TestConcurrentUpdate(t *testing.T) { } }() - doc, err := r.Document("1") + docInt, err := r.Document("1") if err != nil { log.Fatal(err) } + doc := docInt.(*document.Document) + if len(doc.Fields) > 2 { t.Errorf("expected no more than 2 fields, found %d", len(doc.Fields)) } @@ -1796,7 +1813,7 @@ func TestLargeField(t *testing.T) { } d := document.NewDocument("large") - f := document.NewTextFieldWithIndexingOptions("desc", nil, largeFieldValue, document.IndexField|document.StoreField) + f := document.NewTextFieldWithIndexingOptions("desc", nil, largeFieldValue, index.IndexField|index.StoreField) d.AddField(f) err = idx.Update(d) @@ -1828,7 +1845,7 @@ Mechanism[edit] This section needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (July 2013) There are three characteristics of liquids which are relevant to the discussion of a BLEVE:`) -func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { +func TestIndexDocValueReaderWithMultipleDocs(t *testing.T) { cfg := CreateConfig("TestIndexDocumentVisitFieldTermsWithMultipleDocs") err := InitTest(cfg) if err != nil { @@ -1858,8 +1875,8 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { @@ -1871,23 +1888,29 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { t.Error(err) } - fieldTerms := make(index.FieldTerms) + actualFieldTerms := make(fieldTerms) docNumber, err := indexReader.InternalID("1") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(docNumber, []string{"name", "title"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + + dvr, err := indexReader.DocValueReader([]string{"name", "title"}) + if err != nil { + t.Fatal(err) + } + + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms := index.FieldTerms{ + expectedFieldTerms := fieldTerms{ "name": []string{"test"}, "title": []string{"mister"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } err = indexReader.Close() if err != nil { @@ -1895,8 +1918,8 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { } doc2 := document.NewDocument("2") - doc2.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test2"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc2.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister2"), document.IndexField|document.StoreField|document.IncludeTermVectors)) + doc2.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test2"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc2.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister2"), index.IndexField|index.StoreField|index.IncludeTermVectors)) err = idx.Update(doc2) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1906,23 +1929,29 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { t.Error(err) } - fieldTerms = make(index.FieldTerms) + actualFieldTerms = make(fieldTerms) docNumber, err = indexReader.InternalID("2") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(docNumber, []string{"name", "title"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + + dvr, err = indexReader.DocValueReader([]string{"name", "title"}) + if err != nil { + t.Fatal(err) + } + + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms = index.FieldTerms{ + expectedFieldTerms = fieldTerms{ "name": []string{"test2"}, "title": []string{"mister2"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } err = indexReader.Close() if err != nil { @@ -1930,8 +1959,8 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { } doc3 := document.NewDocument("3") - doc3.AddField(document.NewTextFieldWithIndexingOptions("name3", []uint64{}, []byte("test3"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc3.AddField(document.NewTextFieldWithIndexingOptions("title3", []uint64{}, []byte("mister3"), document.IndexField|document.StoreField|document.IncludeTermVectors)) + doc3.AddField(document.NewTextFieldWithIndexingOptions("name3", []uint64{}, []byte("test3"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc3.AddField(document.NewTextFieldWithIndexingOptions("title3", []uint64{}, []byte("mister3"), index.IndexField|index.StoreField|index.IncludeTermVectors)) err = idx.Update(doc3) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1941,42 +1970,54 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { t.Error(err) } - fieldTerms = make(index.FieldTerms) + actualFieldTerms = make(fieldTerms) docNumber, err = indexReader.InternalID("3") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(docNumber, []string{"name3", "title3"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + + dvr, err = indexReader.DocValueReader([]string{"name3", "title3"}) + if err != nil { + t.Fatal(err) + } + + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms = index.FieldTerms{ + expectedFieldTerms = fieldTerms{ "name3": []string{"test3"}, "title3": []string{"mister3"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } - fieldTerms = make(index.FieldTerms) + actualFieldTerms = make(fieldTerms) docNumber, err = indexReader.InternalID("1") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(docNumber, []string{"name", "title"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + + dvr, err = indexReader.DocValueReader([]string{"name", "title"}) + if err != nil { + t.Fatal(err) + } + + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms = index.FieldTerms{ + expectedFieldTerms = fieldTerms{ "name": []string{"test"}, "title": []string{"mister"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } err = indexReader.Close() if err != nil { @@ -1985,7 +2026,7 @@ func TestIndexDocumentVisitFieldTermsWithMultipleDocs(t *testing.T) { } -func TestIndexDocumentVisitFieldTermsWithMultipleFieldOptions(t *testing.T) { +func TestIndexDocValueReaderWithMultipleFieldOptions(t *testing.T) { cfg := CreateConfig("TestIndexDocumentVisitFieldTermsWithMultipleFieldOptions") err := InitTest(cfg) if err != nil { @@ -2016,7 +2057,7 @@ func TestIndexDocumentVisitFieldTermsWithMultipleFieldOptions(t *testing.T) { // mix of field options, this exercises the run time/ on the fly un inverting of // doc values for custom options enabled field like designation, dept. - options := document.IndexField | document.StoreField | document.IncludeTermVectors + options := index.IndexField | index.StoreField | index.IncludeTermVectors doc := document.NewDocument("1") doc.AddField(document.NewTextField("name", []uint64{}, []byte("test"))) // default doc value persisted doc.AddField(document.NewTextField("title", []uint64{}, []byte("mister"))) // default doc value persisted @@ -2033,24 +2074,30 @@ func TestIndexDocumentVisitFieldTermsWithMultipleFieldOptions(t *testing.T) { t.Error(err) } - fieldTerms := make(index.FieldTerms) + actualFieldTerms := make(fieldTerms) docNumber, err := indexReader.InternalID("1") if err != nil { t.Fatal(err) } - err = indexReader.DocumentVisitFieldTerms(docNumber, []string{"name", "designation", "dept"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + + dvr, err := indexReader.DocValueReader([]string{"name", "designation", "dept"}) + if err != nil { + t.Fatal(err) + } + + err = dvr.VisitDocValues(docNumber, func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms := index.FieldTerms{ + expectedFieldTerms := fieldTerms{ "name": []string{"test"}, "designation": []string{"engineer"}, "dept": []string{"bleve"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } err = indexReader.Close() if err != nil { @@ -2464,3 +2511,26 @@ func TestIndexSeekBackwardsStats(t *testing.T) { idx.(*Scorch).stats.TotTermSearchersFinished) } } + +// fieldTerms contains the terms used by a document, keyed by field +type fieldTerms map[string][]string + +// FieldsNotYetCached returns a list of fields not yet cached out of a larger list of fields +func (f fieldTerms) FieldsNotYetCached(fields []string) []string { + rv := make([]string, 0, len(fields)) + for _, field := range fields { + if _, ok := f[field]; !ok { + rv = append(rv, field) + } + } + return rv +} + +// Merge will combine two fieldTerms +// it assumes that the terms lists are complete (thus do not need to be merged) +// field terms from the other list always replace the ones in the receiver +func (f fieldTerms) Merge(other fieldTerms) { + for field, terms := range other { + f[field] = terms + } +} \ No newline at end of file diff --git a/index/scorch/segment/empty.go b/index/scorch/segment/empty.go deleted file mode 100644 index 340db73a6..000000000 --- a/index/scorch/segment/empty.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2017 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package segment - -import ( - "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/couchbase/vellum" -) - -type EmptySegment struct{} - -func (e *EmptySegment) Dictionary(field string) (TermDictionary, error) { - return &EmptyDictionary{}, nil -} - -func (e *EmptySegment) VisitDocument(num uint64, visitor DocumentFieldValueVisitor) error { - return nil -} - -func (e *EmptySegment) DocID(num uint64) ([]byte, error) { - return nil, nil -} - -func (e *EmptySegment) Count() uint64 { - return 0 -} - -func (e *EmptySegment) DocNumbers([]string) (*roaring.Bitmap, error) { - r := roaring.NewBitmap() - return r, nil -} - -func (e *EmptySegment) Fields() []string { - return []string{} -} - -func (e *EmptySegment) Close() error { - return nil -} - -func (e *EmptySegment) Size() uint64 { - return 0 -} - -func (e *EmptySegment) AddRef() { -} - -func (e *EmptySegment) DecRef() error { - return nil -} - -type EmptyDictionary struct{} - -func (e *EmptyDictionary) PostingsList(term []byte, - except *roaring.Bitmap, prealloc PostingsList) (PostingsList, error) { - return &EmptyPostingsList{}, nil -} - -func (e *EmptyDictionary) Iterator() DictionaryIterator { - return &EmptyDictionaryIterator{} -} - -func (e *EmptyDictionary) PrefixIterator(prefix string) DictionaryIterator { - return &EmptyDictionaryIterator{} -} - -func (e *EmptyDictionary) RangeIterator(start, end string) DictionaryIterator { - return &EmptyDictionaryIterator{} -} - -func (e *EmptyDictionary) AutomatonIterator(a vellum.Automaton, - startKeyInclusive, endKeyExclusive []byte) DictionaryIterator { - return &EmptyDictionaryIterator{} -} - -func (e *EmptyDictionary) OnlyIterator(onlyTerms [][]byte, - includeCount bool) DictionaryIterator { - return &EmptyDictionaryIterator{} -} - -func (e *EmptyDictionary) Contains(key []byte) (bool, error) { - return false, nil -} - -type EmptyDictionaryIterator struct{} - -func (e *EmptyDictionaryIterator) Next() (*index.DictEntry, error) { - return nil, nil -} - -func (e *EmptyDictionaryIterator) Contains(key []byte) (bool, error) { - return false, nil -} - -type EmptyPostingsList struct{} - -func (e *EmptyPostingsList) Iterator(includeFreq, includeNorm, includeLocations bool, - prealloc PostingsIterator) PostingsIterator { - return &EmptyPostingsIterator{} -} - -func (e *EmptyPostingsList) Size() int { - return 0 -} - -func (e *EmptyPostingsList) Count() uint64 { - return 0 -} - -type EmptyPostingsIterator struct{} - -func (e *EmptyPostingsIterator) Next() (Posting, error) { - return nil, nil -} - -func (e *EmptyPostingsIterator) Advance(uint64) (Posting, error) { - return nil, nil -} - -func (e *EmptyPostingsIterator) Size() int { - return 0 -} - -var AnEmptyPostingsIterator = &EmptyPostingsIterator{} diff --git a/index/scorch/segment/int.go b/index/scorch/segment/int.go deleted file mode 100644 index 55299d8f7..000000000 --- a/index/scorch/segment/int.go +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2014 The Cockroach Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -// implied. See the License for the specific language governing -// permissions and limitations under the License. - -// This code originated from: -// https://github.com/cockroachdb/cockroach/blob/2dd65dde5d90c157f4b93f92502ca1063b904e1d/pkg/util/encoding/encoding.go - -// Modified to not use pkg/errors - -package segment - -import ( - "errors" - "fmt" -) - -const ( - MaxVarintSize = 9 - - // IntMin is chosen such that the range of int tags does not overlap the - // ascii character set that is frequently used in testing. - IntMin = 0x80 // 128 - intMaxWidth = 8 - intZero = IntMin + intMaxWidth // 136 - intSmall = IntMax - intZero - intMaxWidth // 109 - // IntMax is the maximum int tag value. - IntMax = 0xfd // 253 -) - -// EncodeUvarintAscending encodes the uint64 value using a variable length -// (length-prefixed) representation. The length is encoded as a single -// byte indicating the number of encoded bytes (-8) to follow. See -// EncodeVarintAscending for rationale. The encoded bytes are appended to the -// supplied buffer and the final buffer is returned. -func EncodeUvarintAscending(b []byte, v uint64) []byte { - switch { - case v <= intSmall: - return append(b, intZero+byte(v)) - case v <= 0xff: - return append(b, IntMax-7, byte(v)) - case v <= 0xffff: - return append(b, IntMax-6, byte(v>>8), byte(v)) - case v <= 0xffffff: - return append(b, IntMax-5, byte(v>>16), byte(v>>8), byte(v)) - case v <= 0xffffffff: - return append(b, IntMax-4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) - case v <= 0xffffffffff: - return append(b, IntMax-3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8), - byte(v)) - case v <= 0xffffffffffff: - return append(b, IntMax-2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), - byte(v>>8), byte(v)) - case v <= 0xffffffffffffff: - return append(b, IntMax-1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), - byte(v>>16), byte(v>>8), byte(v)) - default: - return append(b, IntMax, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), - byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) - } -} - -// DecodeUvarintAscending decodes a varint encoded uint64 from the input -// buffer. The remainder of the input buffer and the decoded uint64 -// are returned. -func DecodeUvarintAscending(b []byte) ([]byte, uint64, error) { - if len(b) == 0 { - return nil, 0, fmt.Errorf("insufficient bytes to decode uvarint value") - } - length := int(b[0]) - intZero - b = b[1:] // skip length byte - if length <= intSmall { - return b, uint64(length), nil - } - length -= intSmall - if length < 0 || length > 8 { - return nil, 0, fmt.Errorf("invalid uvarint length of %d", length) - } else if len(b) < length { - return nil, 0, fmt.Errorf("insufficient bytes to decode uvarint value: %q", b) - } - var v uint64 - // It is faster to range over the elements in a slice than to index - // into the slice on each loop iteration. - for _, t := range b[:length] { - v = (v << 8) | uint64(t) - } - return b[length:], v, nil -} - -// ------------------------------------------------------------ - -type MemUvarintReader struct { - C int // index of next byte to read from S - S []byte -} - -func NewMemUvarintReader(s []byte) *MemUvarintReader { - return &MemUvarintReader{S: s} -} - -// Len returns the number of unread bytes. -func (r *MemUvarintReader) Len() int { - n := len(r.S) - r.C - if n < 0 { - return 0 - } - return n -} - -var ErrMemUvarintReaderOverflow = errors.New("MemUvarintReader overflow") - -// ReadUvarint reads an encoded uint64. The original code this was -// based on is at encoding/binary/ReadUvarint(). -func (r *MemUvarintReader) ReadUvarint() (uint64, error) { - var x uint64 - var s uint - var C = r.C - var S = r.S - - for { - b := S[C] - C++ - - if b < 0x80 { - r.C = C - - // why 63? The original code had an 'i += 1' loop var and - // checked for i > 9 || i == 9 ...; but, we no longer - // check for the i var, but instead check here for s, - // which is incremented by 7. So, 7*9 == 63. - // - // why the "extra" >= check? The normal case is that s < - // 63, so we check this single >= guard first so that we - // hit the normal, nil-error return pathway sooner. - if s >= 63 && (s > 63 || s == 63 && b > 1) { - return 0, ErrMemUvarintReaderOverflow - } - - return x | uint64(b)< 0 { + rv = make([]byte, len(inclusiveEnd)) + copy(rv, inclusiveEnd) + if rv[len(rv)-1] < 0xff { + // last byte can be incremented by one + rv[len(rv)-1]++ + } else { + // last byte is already 0xff, so append 0 + // next key is simply one byte longer + rv = append(rv, 0x0) + } + } + return rv +} + func (i *IndexSnapshot) FieldDictRange(field string, startTerm []byte, endTerm []byte) (index.FieldDict, error) { return i.newIndexSnapshotFieldDict(field, func(i segment.TermDictionary) segment.DictionaryIterator { - return i.RangeIterator(string(startTerm), string(endTerm)) + endTermExclusive := calculateExclusiveEndFromInclusiveEnd(endTerm) + return i.AutomatonIterator(nil, startTerm, endTermExclusive) }, false) } +// calculateExclusiveEndFromPrefix produces the first key that +// does not have the same prefix as the input bytes, suitable +// to use as the end key in a traditional (inclusive, exclusive] +// start/end range +func calculateExclusiveEndFromPrefix(in []byte) []byte { + rv := make([]byte, len(in)) + copy(rv, in) + for i := len(rv) - 1; i >= 0; i-- { + rv[i] = rv[i] + 1 + if rv[i] != 0 { + return rv // didn't overflow, so stop + } + } + // all bytes were 0xff, so return nil + // as there is no end key for this prefix + return nil +} + func (i *IndexSnapshot) FieldDictPrefix(field string, termPrefix []byte) (index.FieldDict, error) { + termPrefixEnd := calculateExclusiveEndFromPrefix(termPrefix) return i.newIndexSnapshotFieldDict(field, func(i segment.TermDictionary) segment.DictionaryIterator { - return i.PrefixIterator(string(termPrefix)) + return i.AutomatonIterator(nil, termPrefix, termPrefixEnd) }, false) } @@ -213,7 +254,7 @@ func (i *IndexSnapshot) FieldDictRegexp(field string, // TODO: potential optimization where the literal prefix represents the, // entire regexp, allowing us to use PrefixIterator(prefixTerm)? - a, prefixBeg, prefixEnd, err := segment.ParseRegexp(termRegex) + a, prefixBeg, prefixEnd, err := parseRegexp(termRegex) if err != nil { return nil, err } @@ -243,7 +284,7 @@ func (i *IndexSnapshot) FieldDictFuzzy(field string, var prefixBeg, prefixEnd []byte if prefix != "" { prefixBeg = []byte(prefix) - prefixEnd = segment.IncrementBytes(prefixBeg) + prefixEnd = calculateExclusiveEndFromPrefix(prefixBeg) } return i.newIndexSnapshotFieldDict(field, func(i segment.TermDictionary) segment.DictionaryIterator { @@ -251,13 +292,6 @@ func (i *IndexSnapshot) FieldDictFuzzy(field string, }, false) } -func (i *IndexSnapshot) FieldDictOnly(field string, - onlyTerms [][]byte, includeCount bool) (index.FieldDict, error) { - return i.newIndexSnapshotFieldDict(field, func(i segment.TermDictionary) segment.DictionaryIterator { - return i.OnlyIterator(onlyTerms, includeCount) - }, false) -} - func (i *IndexSnapshot) FieldDictContains(field string) (index.FieldDictContains, error) { return i.newIndexSnapshotFieldDict(field, nil, true) } @@ -349,7 +383,7 @@ func (i *IndexSnapshot) DocCount() (uint64, error) { return rv, nil } -func (i *IndexSnapshot) Document(id string) (rv *document.Document, err error) { +func (i *IndexSnapshot) Document(id string) (rv index.Document, err error) { // FIXME could be done more efficiently directly, but reusing for simplicity tfr, err := i.TermFieldReader([]byte(id), "_id", false, false, false) if err != nil { @@ -377,7 +411,7 @@ func (i *IndexSnapshot) Document(id string) (rv *document.Document, err error) { } segmentIndex, localDocNum := i.segmentIndexAndLocalDocNumFromGlobal(docNum) - rv = document.NewDocument(id) + rvd := document.NewDocument(id) err = i.segment[segmentIndex].VisitDocument(localDocNum, func(name string, typ byte, val []byte, pos []uint64) bool { if name == "_id" { return true @@ -389,15 +423,15 @@ func (i *IndexSnapshot) Document(id string) (rv *document.Document, err error) { switch typ { case 't': - rv.AddField(document.NewTextField(name, arrayPos, value)) + rvd.AddField(document.NewTextField(name, arrayPos, value)) case 'n': - rv.AddField(document.NewNumericFieldFromBytes(name, arrayPos, value)) + rvd.AddField(document.NewNumericFieldFromBytes(name, arrayPos, value)) case 'd': - rv.AddField(document.NewDateTimeFieldFromBytes(name, arrayPos, value)) + rvd.AddField(document.NewDateTimeFieldFromBytes(name, arrayPos, value)) case 'b': - rv.AddField(document.NewBooleanFieldFromBytes(name, arrayPos, value)) + rvd.AddField(document.NewBooleanFieldFromBytes(name, arrayPos, value)) case 'g': - rv.AddField(document.NewGeoPointFieldFromBytes(name, arrayPos, value)) + rvd.AddField(document.NewGeoPointFieldFromBytes(name, arrayPos, value)) } return true @@ -406,7 +440,7 @@ func (i *IndexSnapshot) Document(id string) (rv *document.Document, err error) { return nil, err } - return rv, nil + return rvd, nil } func (i *IndexSnapshot) segmentIndexAndLocalDocNumFromGlobal(docNum uint64) (int, uint64) { @@ -563,40 +597,15 @@ func docInternalToNumber(in index.IndexInternalID) (uint64, error) { return binary.BigEndian.Uint64(in), nil } -func (i *IndexSnapshot) DocumentVisitFieldTerms(id index.IndexInternalID, - fields []string, visitor index.DocumentFieldTermVisitor) error { - _, err := i.documentVisitFieldTerms(id, fields, visitor, nil) - return err -} - -func (i *IndexSnapshot) documentVisitFieldTerms(id index.IndexInternalID, - fields []string, visitor index.DocumentFieldTermVisitor, - dvs segment.DocVisitState) (segment.DocVisitState, error) { - docNum, err := docInternalToNumber(id) - if err != nil { - return nil, err - } - - segmentIndex, localDocNum := i.segmentIndexAndLocalDocNumFromGlobal(docNum) - if segmentIndex >= len(i.segment) { - return nil, nil - } - - _, dvs, err = i.documentVisitFieldTermsOnSegment( - segmentIndex, localDocNum, fields, nil, visitor, dvs) - - return dvs, err -} - func (i *IndexSnapshot) documentVisitFieldTermsOnSegment( segmentIndex int, localDocNum uint64, fields []string, cFields []string, - visitor index.DocumentFieldTermVisitor, dvs segment.DocVisitState) ( + visitor index.DocValueVisitor, dvs segment.DocVisitState) ( cFieldsOut []string, dvsOut segment.DocVisitState, err error) { ss := i.segment[segmentIndex] var vFields []string // fields that are visitable via the segment - ssv, ssvOk := ss.segment.(segment.DocumentFieldTermVisitable) + ssv, ssvOk := ss.segment.(segment.DocValueVisitable) if ssvOk && ssv != nil { vFields, err = ssv.VisitableDocValueFields() if err != nil { @@ -627,7 +636,7 @@ func (i *IndexSnapshot) documentVisitFieldTermsOnSegment( } if ssvOk && ssv != nil && len(vFields) > 0 { - dvs, err = ssv.VisitDocumentFieldTerms(localDocNum, fields, visitor, dvs) + dvs, err = ssv.VisitDocValues(localDocNum, fields, visitor, dvs) if err != nil { return nil, nil, err } @@ -662,7 +671,7 @@ type DocValueReader struct { } func (dvr *DocValueReader) VisitDocValues(id index.IndexInternalID, - visitor index.DocumentFieldTermVisitor) (err error) { + visitor index.DocValueVisitor) (err error) { docNum, err := docInternalToNumber(id) if err != nil { return err diff --git a/index/scorch/snapshot_index_dict.go b/index/scorch/snapshot_index_dict.go index 47486c255..90e5a5677 100644 --- a/index/scorch/snapshot_index_dict.go +++ b/index/scorch/snapshot_index_dict.go @@ -17,8 +17,8 @@ package scorch import ( "container/heap" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" ) type segmentDictCursor struct { diff --git a/index/scorch/snapshot_index_doc.go b/index/scorch/snapshot_index_doc.go index 27da20865..183f1783a 100644 --- a/index/scorch/snapshot_index_doc.go +++ b/index/scorch/snapshot_index_doc.go @@ -19,8 +19,8 @@ import ( "reflect" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeIndexSnapshotDocIDReader int diff --git a/index/scorch/snapshot_index_tfr.go b/index/scorch/snapshot_index_tfr.go index 239f68fbe..367d29be4 100644 --- a/index/scorch/snapshot_index_tfr.go +++ b/index/scorch/snapshot_index_tfr.go @@ -20,9 +20,9 @@ import ( "reflect" "sync/atomic" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeIndexSnapshotTermFieldReader int diff --git a/index/scorch/snapshot_segment.go b/index/scorch/snapshot_segment.go index 96742b4f9..38ffb3623 100644 --- a/index/scorch/snapshot_segment.go +++ b/index/scorch/snapshot_segment.go @@ -20,9 +20,9 @@ import ( "sync/atomic" "github.com/RoaringBitmap/roaring" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch/segment" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + segment "github.com/blevesearch/scorch_segment_api" + "github.com/blevesearch/bleve/v2/size" ) var TermSeparator byte = 0xff @@ -62,8 +62,8 @@ func (s *SegmentSnapshot) Close() error { return s.segment.Close() } -func (s *SegmentSnapshot) VisitDocument(num uint64, visitor segment.DocumentFieldValueVisitor) error { - return s.segment.VisitDocument(num, visitor) +func (s *SegmentSnapshot) VisitDocument(num uint64, visitor segment.StoredFieldValueVisitor) error { + return s.segment.VisitStoredFields(num, visitor) } func (s *SegmentSnapshot) DocID(num uint64) ([]byte, error) { @@ -147,7 +147,7 @@ func (cfd *cachedFieldDocs) prepareField(field string, ss *SegmentSnapshot) { var postings segment.PostingsList var postingsItr segment.PostingsIterator - dictItr := dict.Iterator() + dictItr := dict.AutomatonIterator(nil, nil, nil) next, err := dictItr.Next() for err == nil && next != nil { var err1 error @@ -253,7 +253,7 @@ func (c *cachedDocs) updateSizeLOCKED() { } func (c *cachedDocs) visitDoc(localDocNum uint64, - fields []string, visitor index.DocumentFieldTermVisitor) { + fields []string, visitor index.DocValueVisitor) { c.m.Lock() for _, field := range fields { diff --git a/index/scorch/segment/unadorned.go b/index/scorch/unadorned.go similarity index 64% rename from index/scorch/segment/unadorned.go rename to index/scorch/unadorned.go index db06562df..bc7ca4e31 100644 --- a/index/scorch/segment/unadorned.go +++ b/index/scorch/unadorned.go @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package segment +package scorch import ( "github.com/RoaringBitmap/roaring" + segment "github.com/blevesearch/scorch_segment_api" "math" "reflect" ) @@ -25,28 +26,28 @@ var reflectStaticSizeUnadornedPostingsIterator1Hit int var reflectStaticSizeUnadornedPosting int func init() { - var pib UnadornedPostingsIteratorBitmap + var pib unadornedPostingsIteratorBitmap reflectStaticSizeUnadornedPostingsIteratorBitmap = int(reflect.TypeOf(pib).Size()) - var pi1h UnadornedPostingsIterator1Hit + var pi1h unadornedPostingsIterator1Hit reflectStaticSizeUnadornedPostingsIterator1Hit = int(reflect.TypeOf(pi1h).Size()) var up UnadornedPosting reflectStaticSizeUnadornedPosting = int(reflect.TypeOf(up).Size()) } -type UnadornedPostingsIteratorBitmap struct { +type unadornedPostingsIteratorBitmap struct { actual roaring.IntPeekable actualBM *roaring.Bitmap } -func (i *UnadornedPostingsIteratorBitmap) Next() (Posting, error) { +func (i *unadornedPostingsIteratorBitmap) Next() (segment.Posting, error) { return i.nextAtOrAfter(0) } -func (i *UnadornedPostingsIteratorBitmap) Advance(docNum uint64) (Posting, error) { +func (i *unadornedPostingsIteratorBitmap) Advance(docNum uint64) (segment.Posting, error) { return i.nextAtOrAfter(docNum) } -func (i *UnadornedPostingsIteratorBitmap) nextAtOrAfter(atOrAfter uint64) (Posting, error) { +func (i *unadornedPostingsIteratorBitmap) nextAtOrAfter(atOrAfter uint64) (segment.Posting, error) { docNum, exists := i.nextDocNumAtOrAfter(atOrAfter) if !exists { return nil, nil @@ -54,7 +55,7 @@ func (i *UnadornedPostingsIteratorBitmap) nextAtOrAfter(atOrAfter uint64) (Posti return UnadornedPosting(docNum), nil } -func (i *UnadornedPostingsIteratorBitmap) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool) { +func (i *unadornedPostingsIteratorBitmap) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool) { if i.actual == nil || !i.actual.HasNext() { return 0, false } @@ -67,25 +68,25 @@ func (i *UnadornedPostingsIteratorBitmap) nextDocNumAtOrAfter(atOrAfter uint64) return uint64(i.actual.Next()), true } -func (i *UnadornedPostingsIteratorBitmap) Size() int { +func (i *unadornedPostingsIteratorBitmap) Size() int { return reflectStaticSizeUnadornedPostingsIteratorBitmap } -func (i *UnadornedPostingsIteratorBitmap) ActualBitmap() *roaring.Bitmap { +func (i *unadornedPostingsIteratorBitmap) ActualBitmap() *roaring.Bitmap { return i.actualBM } -func (i *UnadornedPostingsIteratorBitmap) DocNum1Hit() (uint64, bool) { +func (i *unadornedPostingsIteratorBitmap) DocNum1Hit() (uint64, bool) { return 0, false } -func (i *UnadornedPostingsIteratorBitmap) ReplaceActual(actual *roaring.Bitmap) { +func (i *unadornedPostingsIteratorBitmap) ReplaceActual(actual *roaring.Bitmap) { i.actualBM = actual i.actual = actual.Iterator() } -func NewUnadornedPostingsIteratorFromBitmap(bm *roaring.Bitmap) PostingsIterator { - return &UnadornedPostingsIteratorBitmap{ +func newUnadornedPostingsIteratorFromBitmap(bm *roaring.Bitmap) segment.PostingsIterator { + return &unadornedPostingsIteratorBitmap{ actualBM: bm, actual: bm.Iterator(), } @@ -93,19 +94,19 @@ func NewUnadornedPostingsIteratorFromBitmap(bm *roaring.Bitmap) PostingsIterator const docNum1HitFinished = math.MaxUint64 -type UnadornedPostingsIterator1Hit struct { +type unadornedPostingsIterator1Hit struct { docNum uint64 } -func (i *UnadornedPostingsIterator1Hit) Next() (Posting, error) { +func (i *unadornedPostingsIterator1Hit) Next() (segment.Posting, error) { return i.nextAtOrAfter(0) } -func (i *UnadornedPostingsIterator1Hit) Advance(docNum uint64) (Posting, error) { +func (i *unadornedPostingsIterator1Hit) Advance(docNum uint64) (segment.Posting, error) { return i.nextAtOrAfter(docNum) } -func (i *UnadornedPostingsIterator1Hit) nextAtOrAfter(atOrAfter uint64) (Posting, error) { +func (i *unadornedPostingsIterator1Hit) nextAtOrAfter(atOrAfter uint64) (segment.Posting, error) { docNum, exists := i.nextDocNumAtOrAfter(atOrAfter) if !exists { return nil, nil @@ -113,7 +114,7 @@ func (i *UnadornedPostingsIterator1Hit) nextAtOrAfter(atOrAfter uint64) (Posting return UnadornedPosting(docNum), nil } -func (i *UnadornedPostingsIterator1Hit) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool) { +func (i *unadornedPostingsIterator1Hit) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool) { if i.docNum == docNum1HitFinished { return 0, false } @@ -127,12 +128,12 @@ func (i *UnadornedPostingsIterator1Hit) nextDocNumAtOrAfter(atOrAfter uint64) (u return docNum, true } -func (i *UnadornedPostingsIterator1Hit) Size() int { +func (i *unadornedPostingsIterator1Hit) Size() int { return reflectStaticSizeUnadornedPostingsIterator1Hit } -func NewUnadornedPostingsIteratorFrom1Hit(docNum1Hit uint64) PostingsIterator { - return &UnadornedPostingsIterator1Hit{ +func newUnadornedPostingsIteratorFrom1Hit(docNum1Hit uint64) segment.PostingsIterator { + return &unadornedPostingsIterator1Hit{ docNum1Hit, } } @@ -151,7 +152,7 @@ func (p UnadornedPosting) Norm() float64 { return 0 } -func (p UnadornedPosting) Locations() []Location { +func (p UnadornedPosting) Locations() []segment.Location { return nil } diff --git a/index/store/batch.go b/index/store/batch.go deleted file mode 100644 index 711052661..000000000 --- a/index/store/batch.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package store - -type op struct { - K []byte - V []byte -} - -type EmulatedBatch struct { - Ops []*op - Merger *EmulatedMerge -} - -func NewEmulatedBatch(mo MergeOperator) *EmulatedBatch { - return &EmulatedBatch{ - Ops: make([]*op, 0, 1000), - Merger: NewEmulatedMerge(mo), - } -} - -func (b *EmulatedBatch) Set(key, val []byte) { - ck := make([]byte, len(key)) - copy(ck, key) - cv := make([]byte, len(val)) - copy(cv, val) - b.Ops = append(b.Ops, &op{ck, cv}) -} - -func (b *EmulatedBatch) Delete(key []byte) { - ck := make([]byte, len(key)) - copy(ck, key) - b.Ops = append(b.Ops, &op{ck, nil}) -} - -func (b *EmulatedBatch) Merge(key, val []byte) { - ck := make([]byte, len(key)) - copy(ck, key) - cv := make([]byte, len(val)) - copy(cv, val) - b.Merger.Merge(key, val) -} - -func (b *EmulatedBatch) Reset() { - b.Ops = b.Ops[:0] -} - -func (b *EmulatedBatch) Close() error { - return nil -} diff --git a/index/store/kvstore.go b/index/store/kvstore.go deleted file mode 100644 index 34698c7bd..000000000 --- a/index/store/kvstore.go +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package store - -import "encoding/json" - -// KVStore is an abstraction for working with KV stores. Note that -// in order to be used with the bleve.registry, it must also implement -// a constructor function of the registry.KVStoreConstructor type. -type KVStore interface { - - // Writer returns a KVWriter which can be used to - // make changes to the KVStore. If a writer cannot - // be obtained a non-nil error is returned. - Writer() (KVWriter, error) - - // Reader returns a KVReader which can be used to - // read data from the KVStore. If a reader cannot - // be obtained a non-nil error is returned. - Reader() (KVReader, error) - - // Close closes the KVStore - Close() error -} - -// KVReader is an abstraction of an **ISOLATED** reader -// In this context isolated is defined to mean that -// writes/deletes made after the KVReader is opened -// are not observed. -// Because there is usually a cost associated with -// keeping isolated readers active, users should -// close them as soon as they are no longer needed. -type KVReader interface { - - // Get returns the value associated with the key - // If the key does not exist, nil is returned. - // The caller owns the bytes returned. - Get(key []byte) ([]byte, error) - - // MultiGet retrieves multiple values in one call. - MultiGet(keys [][]byte) ([][]byte, error) - - // PrefixIterator returns a KVIterator that will - // visit all K/V pairs with the provided prefix - PrefixIterator(prefix []byte) KVIterator - - // RangeIterator returns a KVIterator that will - // visit all K/V pairs >= start AND < end - RangeIterator(start, end []byte) KVIterator - - // Close closes the iterator - Close() error -} - -// KVIterator is an abstraction around key iteration -type KVIterator interface { - - // Seek will advance the iterator to the specified key - Seek(key []byte) - - // Next will advance the iterator to the next key - Next() - - // Key returns the key pointed to by the iterator - // The bytes returned are **ONLY** valid until the next call to Seek/Next/Close - // Continued use after that requires that they be copied. - Key() []byte - - // Value returns the value pointed to by the iterator - // The bytes returned are **ONLY** valid until the next call to Seek/Next/Close - // Continued use after that requires that they be copied. - Value() []byte - - // Valid returns whether or not the iterator is in a valid state - Valid() bool - - // Current returns Key(),Value(),Valid() in a single operation - Current() ([]byte, []byte, bool) - - // Close closes the iterator - Close() error -} - -// KVWriter is an abstraction for mutating the KVStore -// KVWriter does **NOT** enforce restrictions of a single writer -// if the underlying KVStore allows concurrent writes, the -// KVWriter interface should also do so, it is up to the caller -// to do this in a way that is safe and makes sense -type KVWriter interface { - - // NewBatch returns a KVBatch for performing batch operations on this kvstore - NewBatch() KVBatch - - // NewBatchEx returns a KVBatch and an associated byte array - // that's pre-sized based on the KVBatchOptions. The caller can - // use the returned byte array for keys and values associated with - // the batch. Once the batch is either executed or closed, the - // associated byte array should no longer be accessed by the - // caller. - NewBatchEx(KVBatchOptions) ([]byte, KVBatch, error) - - // ExecuteBatch will execute the KVBatch, the provided KVBatch **MUST** have - // been created by the same KVStore (though not necessarily the same KVWriter) - // Batch execution is atomic, either all the operations or none will be performed - ExecuteBatch(batch KVBatch) error - - // Close closes the writer - Close() error -} - -// KVBatchOptions provides the KVWriter.NewBatchEx() method with batch -// preparation and preallocation information. -type KVBatchOptions struct { - // TotalBytes is the sum of key and value bytes needed by the - // caller for the entire batch. It affects the size of the - // returned byte array of KVWrite.NewBatchEx(). - TotalBytes int - - // NumSets is the number of Set() calls the caller will invoke on - // the KVBatch. - NumSets int - - // NumDeletes is the number of Delete() calls the caller will invoke - // on the KVBatch. - NumDeletes int - - // NumMerges is the number of Merge() calls the caller will invoke - // on the KVBatch. - NumMerges int -} - -// KVBatch is an abstraction for making multiple KV mutations at once -type KVBatch interface { - - // Set updates the key with the specified value - // both key and value []byte may be reused as soon as this call returns - Set(key, val []byte) - - // Delete removes the specified key - // the key []byte may be reused as soon as this call returns - Delete(key []byte) - - // Merge merges old value with the new value at the specified key - // as prescribed by the KVStores merge operator - // both key and value []byte may be reused as soon as this call returns - Merge(key, val []byte) - - // Reset frees resources for this batch and allows reuse - Reset() - - // Close frees resources - Close() error -} - -// KVStoreStats is an optional interface that KVStores can implement -// if they're able to report any useful stats -type KVStoreStats interface { - // Stats returns a JSON serializable object representing stats for this KVStore - Stats() json.Marshaler - - StatsMap() map[string]interface{} -} diff --git a/index/store/merge.go b/index/store/merge.go deleted file mode 100644 index ca2561b0a..000000000 --- a/index/store/merge.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package store - -// At the moment this happens to be the same interface as described by -// RocksDB, but this may not always be the case. - -type MergeOperator interface { - - // FullMerge the full sequence of operands on top of the existingValue - // if no value currently exists, existingValue is nil - // return the merged value, and success/failure - FullMerge(key, existingValue []byte, operands [][]byte) ([]byte, bool) - - // Partially merge these two operands. - // If partial merge cannot be done, return nil,false, which will defer - // all processing until the FullMerge is done. - PartialMerge(key, leftOperand, rightOperand []byte) ([]byte, bool) - - // Name returns an identifier for the operator - Name() string -} - -type EmulatedMerge struct { - Merges map[string][][]byte - mo MergeOperator -} - -func NewEmulatedMerge(mo MergeOperator) *EmulatedMerge { - return &EmulatedMerge{ - Merges: make(map[string][][]byte), - mo: mo, - } -} - -func (m *EmulatedMerge) Merge(key, val []byte) { - ops, ok := m.Merges[string(key)] - if ok && len(ops) > 0 { - last := ops[len(ops)-1] - mergedVal, partialMergeOk := m.mo.PartialMerge(key, last, val) - if partialMergeOk { - // replace last entry with the result of the merge - ops[len(ops)-1] = mergedVal - } else { - // could not partial merge, append this to the end - ops = append(ops, val) - } - } else { - ops = [][]byte{val} - } - m.Merges[string(key)] = ops -} diff --git a/index/store/multiget.go b/index/store/multiget.go deleted file mode 100644 index 635bcd411..000000000 --- a/index/store/multiget.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2016 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package store - -// MultiGet is a helper function to retrieve mutiple keys from a -// KVReader, and might be used by KVStore implementations that don't -// have a native multi-get facility. -func MultiGet(kvreader KVReader, keys [][]byte) ([][]byte, error) { - vals := make([][]byte, 0, len(keys)) - - for i, key := range keys { - val, err := kvreader.Get(key) - if err != nil { - return nil, err - } - - vals[i] = val - } - - return vals, nil -} diff --git a/index/store/test/README.md b/index/store/test/README.md deleted file mode 100644 index 392df2811..000000000 --- a/index/store/test/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Generic KVStore implementation tests - -These are a set of common tests that should pass on any correct KVStore implementation. - -Each test function in this package has the form: - - func CommonTest(t *testing.T, s store.KVStore) {...} - -A KVStore implementation test should use the same name, including its own KVStore name in the test function. It should instantiate an instance of the store, and pass the testing.T and store to the common function. - -The common test functions should *NOT* close the KVStore. The KVStore test implementation should close the store and cleanup any state. \ No newline at end of file diff --git a/index/store/test/bytes.go b/index/store/test/bytes.go deleted file mode 100644 index faef1f952..000000000 --- a/index/store/test/bytes.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package test - -import ( - "bytes" - "reflect" - "testing" - - "github.com/blevesearch/bleve/index/store" -) - -// tests which focus on the byte ownership - -// CommonTestReaderOwnsGetBytes attempts to mutate the returned bytes -// first, while the reader is still open, second after that reader is -// closed, then the original key is read again, to ensure these -// modifications did not cause panic, or mutate the stored value -func CommonTestReaderOwnsGetBytes(t *testing.T, s store.KVStore) { - - originalKey := []byte("key") - originalVal := []byte("val") - - // open a writer - writer, err := s.Writer() - if err != nil { - t.Fatal(err) - } - - // write key/val - batch := writer.NewBatch() - batch.Set(originalKey, originalVal) - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - - // close the writer - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // read key - returnedVal, err := reader.Get(originalKey) - if err != nil { - t.Fatal(err) - } - - // check that it is the expected value - if !reflect.DeepEqual(returnedVal, originalVal) { - t.Fatalf("expected value: %v for '%s', got %v", originalVal, originalKey, returnedVal) - } - - // mutate the returned value with reader still open - for i := range returnedVal { - returnedVal[i] = '1' - } - - // read the key again - returnedVal2, err := reader.Get(originalKey) - if err != nil { - t.Fatal(err) - } - - // check that it is the expected value - if !reflect.DeepEqual(returnedVal2, originalVal) { - t.Fatalf("expected value: %v for '%s', got %v", originalVal, originalKey, returnedVal2) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } - - // mutate the original returned value again - for i := range returnedVal { - returnedVal[i] = '2' - } - - // open another reader - reader, err = s.Reader() - if err != nil { - t.Fatal(err) - } - - // read the key again - returnedVal3, err := reader.Get(originalKey) - if err != nil { - t.Fatal(err) - } - - // check that it is the expected value - if !reflect.DeepEqual(returnedVal3, originalVal) { - t.Fatalf("expected value: %v for '%s', got %v", originalVal, originalKey, returnedVal3) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } - - // finally check that the value we mutated still has what we set it to - for i := range returnedVal { - if returnedVal[i] != '2' { - t.Errorf("expected byte to be '2', got %v", returnedVal[i]) - } - } -} - -func CommonTestWriterOwnsBytes(t *testing.T, s store.KVStore) { - - keyBuffer := make([]byte, 5) - valBuffer := make([]byte, 5) - - // open a writer - writer, err := s.Writer() - if err != nil { - t.Fatal(err) - } - - // write key/val pairs reusing same buffer - batch := writer.NewBatch() - for i := 0; i < 10; i++ { - keyBuffer[0] = 'k' - keyBuffer[1] = 'e' - keyBuffer[2] = 'y' - keyBuffer[3] = '-' - keyBuffer[4] = byte('0' + i) - valBuffer[0] = 'v' - valBuffer[1] = 'a' - valBuffer[2] = 'l' - valBuffer[3] = '-' - valBuffer[4] = byte('0' + i) - batch.Set(keyBuffer, valBuffer) - } - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - - // close the writer - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // check that we can read back what we expect - allks := make([][]byte, 0) - allvs := make([][]byte, 0) - iter := reader.RangeIterator(nil, nil) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - allks = append(allks, copyk) - v := iter.Key() - copyv := make([]byte, len(v)) - copy(copyv, v) - allvs = append(allvs, copyv) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - if len(allks) != 10 { - t.Fatalf("expected 10 k/v pairs, got %d", len(allks)) - } - for i, key := range allks { - val := allvs[i] - if !bytes.HasSuffix(key, []byte{byte('0' + i)}) { - t.Errorf("expected key %v to end in %d", key, []byte{byte('0' + i)}) - } - if !bytes.HasSuffix(val, []byte{byte('0' + i)}) { - t.Errorf("expected val %v to end in %d", val, []byte{byte('0' + i)}) - } - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } - - // open a writer - writer, err = s.Writer() - if err != nil { - t.Fatal(err) - } - - // now delete using same approach - batch = writer.NewBatch() - for i := 0; i < 10; i++ { - keyBuffer[0] = 'k' - keyBuffer[1] = 'e' - keyBuffer[2] = 'y' - keyBuffer[3] = '-' - keyBuffer[4] = byte('0' + i) - batch.Delete(keyBuffer) - } - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - - // close the writer - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err = s.Reader() - if err != nil { - t.Fatal(err) - } - - // check that we can read back what we expect - allks = make([][]byte, 0) - iter = reader.RangeIterator(nil, nil) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - allks = append(allks, copyk) - v := iter.Key() - copyv := make([]byte, len(v)) - copy(copyv, v) - allvs = append(allvs, copyv) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - if len(allks) != 0 { - t.Fatalf("expected 0 k/v pairs remaining, got %d", len(allks)) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } -} diff --git a/index/store/test/crud.go b/index/store/test/crud.go deleted file mode 100644 index 00236a8a2..000000000 --- a/index/store/test/crud.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package test - -import ( - "testing" - - "github.com/blevesearch/bleve/index/store" -) - -// basic crud tests - -func CommonTestKVCrud(t *testing.T, s store.KVStore) { - - writer, err := s.Writer() - if err != nil { - t.Error(err) - } - - batch := writer.NewBatch() - batch.Set([]byte("a"), []byte("val-a")) - batch.Set([]byte("z"), []byte("val-z")) - batch.Delete([]byte("z")) - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - - batch.Reset() - - batch.Set([]byte("b"), []byte("val-b")) - batch.Set([]byte("c"), []byte("val-c")) - batch.Set([]byte("d"), []byte("val-d")) - batch.Set([]byte("e"), []byte("val-e")) - batch.Set([]byte("f"), []byte("val-f")) - batch.Set([]byte("g"), []byte("val-g")) - batch.Set([]byte("h"), []byte("val-h")) - batch.Set([]byte("i"), []byte("val-i")) - batch.Set([]byte("j"), []byte("val-j")) - - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - reader, err := s.Reader() - if err != nil { - t.Error(err) - } - defer func() { - err := reader.Close() - if err != nil { - t.Fatal(err) - } - }() - it := reader.RangeIterator([]byte("b"), nil) - key, val, valid := it.Current() - if !valid { - t.Fatalf("valid false, expected true") - } - if string(key) != "b" { - t.Fatalf("expected key b, got %s", key) - } - if string(val) != "val-b" { - t.Fatalf("expected value val-b, got %s", val) - } - - it.Next() - key, val, valid = it.Current() - if !valid { - t.Fatalf("valid false, expected true") - } - if string(key) != "c" { - t.Fatalf("expected key c, got %s", key) - } - if string(val) != "val-c" { - t.Fatalf("expected value val-c, got %s", val) - } - - it.Seek([]byte("i")) - key, val, valid = it.Current() - if !valid { - t.Fatalf("valid false, expected true") - } - if string(key) != "i" { - t.Fatalf("expected key i, got %s", key) - } - if string(val) != "val-i" { - t.Fatalf("expected value val-i, got %s", val) - } - - err = it.Close() - if err != nil { - t.Fatal(err) - } -} diff --git a/index/store/test/isolation.go b/index/store/test/isolation.go deleted file mode 100644 index bf40a9fe1..000000000 --- a/index/store/test/isolation.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package test - -import ( - "fmt" - "reflect" - "testing" - - "github.com/blevesearch/bleve/index/store" -) - -// tests focused on verifying that readers are isolated from writers - -func CommonTestReaderIsolation(t *testing.T, s store.KVStore) { - // insert a kv pair - writer, err := s.Writer() - if err != nil { - t.Error(err) - } - - // ************************************************** - // this is a hack only required for BoltDB - // however its harmless so to keep the tests - // the same everywhere, we include it here - // - // this is a hack to try to pre-emptively overflow - // boltdb writes *MAY* block a long reader - // in particular, if the write requires additional - // allocation, it must acquire the same lock as - // the reader, thus cannot continue until that - // reader is closed. - // in general this is not a problem for bleve - // (though it may affect performance in some cases) - // but it is a problem for this test which attempts - // to easily verify that readers are isolated - // this hack writes enough initial data such that - // the subsequent writes do not require additional - // space - hackSize := 1000 - batch := writer.NewBatch() - for i := 0; i < hackSize; i++ { - k := fmt.Sprintf("x%d", i) - batch.Set([]byte(k), []byte("filler")) - } - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - // ************************************************** - - batch = writer.NewBatch() - batch.Set([]byte("a"), []byte("val-a")) - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // create an isolated reader - reader, err := s.Reader() - if err != nil { - t.Error(err) - } - defer func() { - err := reader.Close() - if err != nil { - t.Fatal(err) - } - }() - - // verify that we see the value already inserted - val, err := reader.Get([]byte("a")) - if err != nil { - t.Error(err) - } - if !reflect.DeepEqual(val, []byte("val-a")) { - t.Errorf("expected val-a, got nil") - } - - // verify that an iterator sees it - count := 0 - it := reader.RangeIterator([]byte{0}, []byte{'x'}) - defer func() { - err := it.Close() - if err != nil { - t.Fatal(err) - } - }() - for it.Valid() { - it.Next() - count++ - } - if count != 1 { - t.Errorf("expected iterator to see 1, saw %d", count) - } - - // add something after the reader was created - writer, err = s.Writer() - if err != nil { - t.Error(err) - } - batch = writer.NewBatch() - batch.Set([]byte("b"), []byte("val-b")) - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // ensure that a newer reader sees it - newReader, err := s.Reader() - if err != nil { - t.Error(err) - } - defer func() { - err := newReader.Close() - if err != nil { - t.Fatal(err) - } - }() - val, err = newReader.Get([]byte("b")) - if err != nil { - t.Error(err) - } - if !reflect.DeepEqual(val, []byte("val-b")) { - t.Errorf("expected val-b, got nil") - } - - // ensure that the direct iterator sees it - count = 0 - it2 := newReader.RangeIterator([]byte{0}, []byte{'x'}) - defer func() { - err := it2.Close() - if err != nil { - t.Fatal(err) - } - }() - for it2.Valid() { - it2.Next() - count++ - } - if count != 2 { - t.Errorf("expected iterator to see 2, saw %d", count) - } - - // but that the isolated reader does not - val, err = reader.Get([]byte("b")) - if err != nil { - t.Error(err) - } - if val != nil { - t.Errorf("expected nil, got %v", val) - } - - // and ensure that the iterator on the isolated reader also does not - count = 0 - it3 := reader.RangeIterator([]byte{0}, []byte{'x'}) - defer func() { - err := it3.Close() - if err != nil { - t.Fatal(err) - } - }() - for it3.Valid() { - it3.Next() - count++ - } - if count != 1 { - t.Errorf("expected iterator to see 1, saw %d", count) - } - -} diff --git a/index/store/test/iterator.go b/index/store/test/iterator.go deleted file mode 100644 index b48d99748..000000000 --- a/index/store/test/iterator.go +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package test - -import ( - "bytes" - "reflect" - "strings" - "testing" - - "github.com/blevesearch/bleve/index/store" -) - -// tests around the correct behavior of iterators - -type testRow struct { - key []byte - val []byte -} - -func batchWriteRows(s store.KVStore, rows []testRow) error { - // open a writer - writer, err := s.Writer() - if err != nil { - return err - } - - // write the data - batch := writer.NewBatch() - for _, row := range rows { - batch.Set(row.key, row.val) - } - err = writer.ExecuteBatch(batch) - if err != nil { - return err - } - - // close the writer - err = writer.Close() - if err != nil { - return err - } - return nil -} - -func CommonTestPrefixIterator(t *testing.T, s store.KVStore) { - - data := []testRow{ - {[]byte("apple"), []byte("val")}, - {[]byte("cat1"), []byte("val")}, - {[]byte("cat2"), []byte("val")}, - {[]byte("cat3"), []byte("val")}, - {[]byte("dog1"), []byte("val")}, - {[]byte("dog2"), []byte("val")}, - {[]byte("dog4"), []byte("val")}, - {[]byte("elephant"), []byte("val")}, - } - - expectedCats := [][]byte{ - []byte("cat1"), - []byte("cat2"), - []byte("cat3"), - } - - expectedDogs := [][]byte{ - []byte("dog1"), - // we seek to "dog3" and ensure it skips over "dog2" - // but still finds "dog4" even though there was no "dog3" - []byte("dog4"), - } - - err := batchWriteRows(s, data) - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // get a prefix reader - cats := make([][]byte, 0) - iter := reader.PrefixIterator([]byte("cat")) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - cats = append(cats, copyk) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found all the cats - if !reflect.DeepEqual(cats, expectedCats) { - t.Fatalf("expected cats %v, got %v", expectedCats, cats) - } - - // get a prefix reader - dogs := make([][]byte, 0) - iter = reader.PrefixIterator([]byte("dog")) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - dogs = append(dogs, copyk) - if len(dogs) < 2 { - iter.Seek([]byte("dog3")) - } else { - iter.Next() - } - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found the expected dogs - if !reflect.DeepEqual(dogs, expectedDogs) { - t.Fatalf("expected dogs %v, got %v", expectedDogs, dogs) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } -} - -func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) { - - data := []testRow{ - {[]byte("a"), []byte("val")}, - {[]byte("b1"), []byte("val")}, - {[]byte("b2"), []byte("val")}, - {[]byte("b3"), []byte("val")}, - {[]byte("c"), []byte("val")}, - } - - err := batchWriteRows(s, data) - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - defer func() { - err := reader.Close() - if err != nil { - t.Fatal(err) - } - }() - - // get an iterator on a central subset of the data - iter := reader.PrefixIterator([]byte("b")) - defer func() { - err := iter.Close() - if err != nil { - t.Fatal(err) - } - }() - - // check that all keys have prefix - found := []string{} - for ; iter.Valid(); iter.Next() { - found = append(found, string(iter.Key())) - } - for _, f := range found { - if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix", f) - } - } - if len(found) != 3 { - t.Errorf("expected 3 keys with prefix, got %d", len(found)) - } - - // now try to seek before the prefix and repeat - found = []string{} - for iter.Seek([]byte("a")); iter.Valid(); iter.Next() { - found = append(found, string(iter.Key())) - } - for _, f := range found { - if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix", f) - } - } - if len(found) != 3 { - t.Errorf("expected 3 keys with prefix, got %d", len(found)) - } - - // now try to seek after the prefix and repeat - found = []string{} - for iter.Seek([]byte("c")); iter.Valid(); iter.Next() { - found = append(found, string(iter.Key())) - } - for _, f := range found { - if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix", f) - } - } - if len(found) != 0 { - t.Errorf("expected 0 keys with prefix, got %d", len(found)) - } - -} - -func CommonTestRangeIterator(t *testing.T, s store.KVStore) { - - data := []testRow{ - {[]byte("a1"), []byte("val")}, - {[]byte("b1"), []byte("val")}, - {[]byte("b2"), []byte("val")}, - {[]byte("b3"), []byte("val")}, - {[]byte("c1"), []byte("val")}, - {[]byte("c2"), []byte("val")}, - {[]byte("c4"), []byte("val")}, - {[]byte("d1"), []byte("val")}, - } - - expectedAll := make([][]byte, 0) - expectedBToC := make([][]byte, 0) - expectedCToDSeek3 := make([][]byte, 0) - expectedCToEnd := make([][]byte, 0) - for _, row := range data { - expectedAll = append(expectedAll, row.key) - if bytes.HasPrefix(row.key, []byte("b")) { - expectedBToC = append(expectedBToC, row.key) - } - if bytes.HasPrefix(row.key, []byte("c")) && !bytes.HasSuffix(row.key, []byte("2")) { - expectedCToDSeek3 = append(expectedCToDSeek3, row.key) - } - if bytes.Compare(row.key, []byte("c")) > 0 { - expectedCToEnd = append(expectedCToEnd, row.key) - } - } - - err := batchWriteRows(s, data) - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // get a range iterator (all) - all := make([][]byte, 0) - iter := reader.RangeIterator(nil, nil) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - all = append(all, copyk) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found all - if !reflect.DeepEqual(all, expectedAll) { - t.Fatalf("expected all %v, got %v", expectedAll, all) - } - - // get range iterator from b - c - bToC := make([][]byte, 0) - iter = reader.RangeIterator([]byte("b"), []byte("c")) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - bToC = append(bToC, copyk) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found b-c - if !reflect.DeepEqual(bToC, expectedBToC) { - t.Fatalf("expected b-c %v, got %v", expectedBToC, bToC) - } - - // get range iterator from c - d, but seek to 'c3' - cToDSeek3 := make([][]byte, 0) - iter = reader.RangeIterator([]byte("c"), []byte("d")) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - cToDSeek3 = append(cToDSeek3, copyk) - if len(cToDSeek3) < 2 { - iter.Seek([]byte("c3")) - } else { - iter.Next() - } - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found c-d with seek to c3 - if !reflect.DeepEqual(cToDSeek3, expectedCToDSeek3) { - t.Fatalf("expected b-c %v, got %v", expectedCToDSeek3, cToDSeek3) - } - - // get range iterator from c to the end - cToEnd := make([][]byte, 0) - iter = reader.RangeIterator([]byte("c"), nil) - for iter.Valid() { - // if we want to keep bytes from iteration we must copy - k := iter.Key() - copyk := make([]byte, len(k)) - copy(copyk, k) - cToEnd = append(cToEnd, copyk) - iter.Next() - } - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - // check that we found c to end - if !reflect.DeepEqual(cToEnd, expectedCToEnd) { - t.Fatalf("expected b-c %v, got %v", expectedCToEnd, cToEnd) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } -} - -func CommonTestRangeIteratorSeek(t *testing.T, s store.KVStore) { - - data := []testRow{ - {[]byte("a1"), []byte("val")}, - {[]byte("b1"), []byte("val")}, - {[]byte("c1"), []byte("val")}, - {[]byte("d1"), []byte("val")}, - {[]byte("e1"), []byte("val")}, - } - - err := batchWriteRows(s, data) - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // get an iterator on a central subset of the data - start := []byte("b1") - end := []byte("d1") - iter := reader.RangeIterator(start, end) - - // seek before, at and after every possible key - targets := [][]byte{} - for _, row := range data { - prefix := string(row.key[:1]) - targets = append(targets, []byte(prefix+"0")) - targets = append(targets, []byte(prefix+"1")) - targets = append(targets, []byte(prefix+"2")) - } - for _, target := range targets { - found := []string{} - for iter.Seek(target); iter.Valid(); iter.Next() { - found = append(found, string(iter.Key())) - if len(found) > len(data) { - t.Fatalf("enumerated more than data keys after seeking to %s", - string(target)) - } - } - wanted := []string{} - for _, row := range data { - if bytes.Compare(row.key, start) < 0 || - bytes.Compare(row.key, target) < 0 || - bytes.Compare(row.key, end) >= 0 { - continue - } - wanted = append(wanted, string(row.key)) - } - fs := strings.Join(found, ", ") - ws := strings.Join(wanted, ", ") - if fs != ws { - t.Fatalf("iterating from %s returned [%s] instead of [%s]", - string(target), fs, ws) - } - } - - err = iter.Close() - if err != nil { - t.Fatal(err) - } - - if err != nil { - t.Fatal(err) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } -} diff --git a/index/store/test/merge.go b/index/store/test/merge.go deleted file mode 100644 index f27843178..000000000 --- a/index/store/test/merge.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package test - -import ( - "encoding/binary" - "testing" - - "github.com/blevesearch/bleve/index/store" -) - -// test merge behavior - -func encodeUint64(in uint64) []byte { - rv := make([]byte, 8) - binary.LittleEndian.PutUint64(rv, in) - return rv -} - -func CommonTestMerge(t *testing.T, s store.KVStore) { - - testKey := []byte("k1") - - data := []struct { - key []byte - val []byte - }{ - {testKey, encodeUint64(1)}, - {testKey, encodeUint64(1)}, - } - - // open a writer - writer, err := s.Writer() - if err != nil { - t.Fatal(err) - } - - // write the data - batch := writer.NewBatch() - for _, row := range data { - batch.Merge(row.key, row.val) - } - err = writer.ExecuteBatch(batch) - if err != nil { - t.Fatal(err) - } - - // close the writer - err = writer.Close() - if err != nil { - t.Fatal(err) - } - - // open a reader - reader, err := s.Reader() - if err != nil { - t.Fatal(err) - } - - // read key - returnedVal, err := reader.Get(testKey) - if err != nil { - t.Fatal(err) - } - - // check the value - mergedval := binary.LittleEndian.Uint64(returnedVal) - if mergedval != 2 { - t.Errorf("expected 2, got %d", mergedval) - } - - // close the reader - err = reader.Close() - if err != nil { - t.Fatal(err) - } - -} - -// a test merge operator which is just an incrementing counter of uint64 -type TestMergeCounter struct{} - -func (mc *TestMergeCounter) FullMerge(key, existingValue []byte, operands [][]byte) ([]byte, bool) { - var newval uint64 - if len(existingValue) > 0 { - newval = binary.LittleEndian.Uint64(existingValue) - } - - // now process operands - for _, operand := range operands { - next := binary.LittleEndian.Uint64(operand) - newval += next - } - - rv := make([]byte, 8) - binary.LittleEndian.PutUint64(rv, newval) - return rv, true -} - -func (mc *TestMergeCounter) PartialMerge(key, leftOperand, rightOperand []byte) ([]byte, bool) { - left := binary.LittleEndian.Uint64(leftOperand) - right := binary.LittleEndian.Uint64(rightOperand) - rv := make([]byte, 8) - binary.LittleEndian.PutUint64(rv, left+right) - return rv, true -} - -func (mc *TestMergeCounter) Name() string { - return "test_merge_counter" -} diff --git a/index/upsidedown/analysis.go b/index/upsidedown/analysis.go index d1b1fd596..ca877c40b 100644 --- a/index/upsidedown/analysis.go +++ b/index/upsidedown/analysis.go @@ -15,29 +15,42 @@ package upsidedown import ( - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" + index "github.com/blevesearch/bleve_index_api" ) -func (udc *UpsideDownCouch) Analyze(d *document.Document) *index.AnalysisResult { - rv := &index.AnalysisResult{ - DocID: d.ID, - Rows: make([]index.IndexRow, 0, 100), +type IndexRow interface { + KeySize() int + KeyTo([]byte) (int, error) + Key() []byte + + ValueSize() int + ValueTo([]byte) (int, error) + Value() []byte +} + +type AnalysisResult struct { + DocID string + Rows []IndexRow +} + +func (udc *UpsideDownCouch) analyze(d index.Document) *AnalysisResult { + rv := &AnalysisResult{ + DocID: d.ID(), + Rows: make([]IndexRow, 0, 100), } - docIDBytes := []byte(d.ID) + docIDBytes := []byte(d.ID()) // track our back index entries backIndexStoredEntries := make([]*BackIndexStoreEntry, 0) // information we collate as we merge fields with same name - fieldTermFreqs := make(map[uint16]analysis.TokenFrequencies) + fieldTermFreqs := make(map[uint16]index.TokenFrequencies) fieldLengths := make(map[uint16]int) fieldIncludeTermVectors := make(map[uint16]bool) fieldNames := make(map[uint16]string) - analyzeField := func(field document.Field, storable bool) { + analyzeField := func(field index.Field, storable bool) { fieldIndex, newFieldRow := udc.fieldIndexOrNewRow(field.Name()) if newFieldRow != nil { rv.Rows = append(rv.Rows, newFieldRow) @@ -45,7 +58,9 @@ func (udc *UpsideDownCouch) Analyze(d *document.Document) *index.AnalysisResult fieldNames[fieldIndex] = field.Name() if field.Options().IsIndexed() { - fieldLength, tokenFreqs := field.Analyze() + field.Analyze() + fieldLength := field.AnalyzedLength() + tokenFreqs := field.AnalyzedTokenFrequencies() existingFreqs := fieldTermFreqs[fieldIndex] if existingFreqs == nil { fieldTermFreqs[fieldIndex] = tokenFreqs @@ -66,21 +81,21 @@ func (udc *UpsideDownCouch) Analyze(d *document.Document) *index.AnalysisResult // place information about indexed fields into map // this collates information across fields with // same names (arrays) - for _, field := range d.Fields { + d.VisitFields(func(field index.Field) { analyzeField(field, true) - } + }) - if len(d.CompositeFields) > 0 { + if d.HasComposite() { for fieldIndex, tokenFreqs := range fieldTermFreqs { // see if any of the composite fields need this - for _, compositeField := range d.CompositeFields { - compositeField.Compose(fieldNames[fieldIndex], fieldLengths[fieldIndex], tokenFreqs) - } + d.VisitComposite(func(field index.CompositeField) { + field.Compose(fieldNames[fieldIndex], fieldLengths[fieldIndex], tokenFreqs) + }) } - for _, compositeField := range d.CompositeFields { - analyzeField(compositeField, false) - } + d.VisitComposite(func(field index.CompositeField) { + analyzeField(field, false) + }) } rowsCapNeeded := len(rv.Rows) + 1 @@ -88,7 +103,7 @@ func (udc *UpsideDownCouch) Analyze(d *document.Document) *index.AnalysisResult rowsCapNeeded += len(tokenFreqs) } - rv.Rows = append(make([]index.IndexRow, 0, rowsCapNeeded), rv.Rows...) + rv.Rows = append(make([]IndexRow, 0, rowsCapNeeded), rv.Rows...) backIndexTermsEntries := make([]*BackIndexTermsEntry, 0, len(fieldTermFreqs)) diff --git a/index/upsidedown/analysis_test.go b/index/upsidedown/analysis_test.go index 5889b930a..0e964b327 100644 --- a/index/upsidedown/analysis_test.go +++ b/index/upsidedown/analysis_test.go @@ -17,11 +17,11 @@ package upsidedown import ( "testing" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/null" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/null" + "github.com/blevesearch/bleve/v2/registry" ) func TestAnalysisBug328(t *testing.T) { @@ -38,14 +38,14 @@ func TestAnalysisBug328(t *testing.T) { } d := document.NewDocument("1") - f := document.NewTextFieldCustom("title", nil, []byte("bleve"), document.IndexField|document.IncludeTermVectors, analyzer) + f := document.NewTextFieldCustom("title", nil, []byte("bleve"), index.IndexField|index.IncludeTermVectors, analyzer) d.AddField(f) - f = document.NewTextFieldCustom("body", nil, []byte("bleve"), document.IndexField|document.IncludeTermVectors, analyzer) + f = document.NewTextFieldCustom("body", nil, []byte("bleve"), index.IndexField|index.IncludeTermVectors, analyzer) d.AddField(f) - cf := document.NewCompositeFieldWithIndexingOptions("_all", true, []string{}, []string{}, document.IndexField|document.IncludeTermVectors) + cf := document.NewCompositeFieldWithIndexingOptions("_all", true, []string{}, []string{}, index.IndexField|index.IncludeTermVectors) d.AddField(cf) - rv := idx.Analyze(d) + rv := idx.(*UpsideDownCouch).analyze(d) fieldIndexes := make(map[uint16]string) for _, row := range rv.Rows { if row, ok := row.(*FieldRow); ok { @@ -84,7 +84,7 @@ func BenchmarkAnalyze(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - rv := idx.Analyze(d) + rv := idx.(*UpsideDownCouch).analyze(d) if len(rv.Rows) < 92 || len(rv.Rows) > 93 { b.Fatalf("expected 512-13 rows, got %d", len(rv.Rows)) } diff --git a/index/upsidedown/benchmark_boltdb_test.go b/index/upsidedown/benchmark_boltdb_test.go index c505aeea2..5fabfa668 100644 --- a/index/upsidedown/benchmark_boltdb_test.go +++ b/index/upsidedown/benchmark_boltdb_test.go @@ -17,7 +17,7 @@ package upsidedown import ( "testing" - "github.com/blevesearch/bleve/index/store/boltdb" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" ) var boltTestConfig = map[string]interface{}{ diff --git a/index/upsidedown/benchmark_common_test.go b/index/upsidedown/benchmark_common_test.go index bb14bf9cb..d4bb9e8f9 100644 --- a/index/upsidedown/benchmark_common_test.go +++ b/index/upsidedown/benchmark_common_test.go @@ -19,10 +19,10 @@ import ( "strconv" "testing" - _ "github.com/blevesearch/bleve/analysis/analyzer/standard" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/registry" + _ "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/registry" ) var benchmarkDocBodies = []string{ @@ -68,7 +68,7 @@ func CommonBenchmarkIndex(b *testing.B, storeName string, storeConfig map[string if err != nil { b.Fatal(err) } - indexDocument.ID = strconv.Itoa(i) + indexDocument.SetID(strconv.Itoa(i)) // just time the indexing portion b.StartTimer() err = idx.Update(indexDocument) @@ -125,7 +125,7 @@ func CommonBenchmarkIndexBatch(b *testing.B, storeName string, storeConfig map[s } indexDocument := document.NewDocument(""). AddField(document.NewTextFieldWithAnalyzer("body", []uint64{}, []byte(benchmarkDocBodies[j%10]), analyzer)) - indexDocument.ID = strconv.Itoa(i) + "-" + strconv.Itoa(j) + indexDocument.SetID(strconv.Itoa(i) + "-" + strconv.Itoa(j)) batch.Update(indexDocument) } // close last batch diff --git a/index/upsidedown/benchmark_cznicb_test.go b/index/upsidedown/benchmark_cznicb_test.go deleted file mode 100644 index 964f8ecdf..000000000 --- a/index/upsidedown/benchmark_cznicb_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build cznicb - -package upsidedown - -import ( - "testing" - - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/blevex/cznicb" -) - -func CreateCznicB() (store.KVStore, error) { - return cznicb.StoreConstructor(nil) -} - -func DestroyCznicB() error { - return nil -} - -func BenchmarkCznicBIndexing1Workers(b *testing.B) { - CommonBenchmarkIndex(b, CreateCznicB, DestroyCznicB, 1) -} - -func BenchmarkCznicBIndexing2Workers(b *testing.B) { - CommonBenchmarkIndex(b, CreateCznicB, DestroyCznicB, 2) -} - -func BenchmarkCznicBIndexing4Workers(b *testing.B) { - CommonBenchmarkIndex(b, CreateCznicB, DestroyCznicB, 4) -} - -// batches - -func BenchmarkCznicBIndexing1Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 1, 10) -} - -func BenchmarkCznicBIndexing2Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 2, 10) -} - -func BenchmarkCznicBIndexing4Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 4, 10) -} - -func BenchmarkCznicBIndexing1Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 1, 100) -} - -func BenchmarkCznicBIndexing2Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 2, 100) -} - -func BenchmarkCznicBIndexing4Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 4, 100) -} - -func BenchmarkCznicBIndexing1Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 1, 1000) -} - -func BenchmarkCznicBIndexing2Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 2, 1000) -} - -func BenchmarkCznicBIndexing4Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, CreateCznicB, DestroyCznicB, 4, 1000) -} diff --git a/index/upsidedown/benchmark_goleveldb_test.go b/index/upsidedown/benchmark_goleveldb_test.go deleted file mode 100644 index 485ba344d..000000000 --- a/index/upsidedown/benchmark_goleveldb_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package upsidedown - -import ( - "testing" - - "github.com/blevesearch/bleve/index/store/goleveldb" -) - -var goLevelDBTestOptions = map[string]interface{}{ - "create_if_missing": true, - "path": "test", -} - -func BenchmarkGoLevelDBIndexing1Workers(b *testing.B) { - CommonBenchmarkIndex(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 1) -} - -func BenchmarkGoLevelDBIndexing2Workers(b *testing.B) { - CommonBenchmarkIndex(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 2) -} - -func BenchmarkGoLevelDBIndexing4Workers(b *testing.B) { - CommonBenchmarkIndex(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 4) -} - -// batches - -func BenchmarkGoLevelDBIndexing1Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 1, 10) -} - -func BenchmarkGoLevelDBIndexing2Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 2, 10) -} - -func BenchmarkGoLevelDBIndexing4Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 4, 10) -} - -func BenchmarkGoLevelDBIndexing1Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 1, 100) -} - -func BenchmarkGoLevelDBIndexing2Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 2, 100) -} - -func BenchmarkGoLevelDBIndexing4Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 4, 100) -} - -func BenchmarkGoLevelDBIndexing1Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 1, 1000) -} - -func BenchmarkGoLevelDBIndexing2Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 2, 1000) -} - -func BenchmarkGoLevelDBIndexing4Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, goleveldb.Name, goLevelDBTestOptions, DestroyTest, 4, 1000) -} diff --git a/index/upsidedown/benchmark_gorocksdb_test.go b/index/upsidedown/benchmark_gorocksdb_test.go deleted file mode 100644 index a65e3cc26..000000000 --- a/index/upsidedown/benchmark_gorocksdb_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build rocksdb - -package upsidedown - -import ( - "testing" - - "github.com/blevesearch/blevex/rocksdb" -) - -var rocksdbTestOptions = map[string]interface{}{ - "path": "test", - "create_if_missing": true, -} - -func BenchmarkRocksDBIndexing1Workers(b *testing.B) { - CommonBenchmarkIndex(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 1) -} - -func BenchmarkRocksDBIndexing2Workers(b *testing.B) { - CommonBenchmarkIndex(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 2) -} - -func BenchmarkRocksDBIndexing4Workers(b *testing.B) { - CommonBenchmarkIndex(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 4) -} - -// batches - -func BenchmarkRocksDBIndexing1Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 1, 10) -} - -func BenchmarkRocksDBIndexing2Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 2, 10) -} - -func BenchmarkRocksDBIndexing4Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 4, 10) -} - -func BenchmarkRocksDBIndexing1Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 1, 100) -} - -func BenchmarkRocksDBIndexing2Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 2, 100) -} - -func BenchmarkRocksDBIndexing4Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 4, 100) -} - -func BenchmarkRocksDBIndexing1Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 1, 1000) -} - -func BenchmarkRocksDBIndexing2Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 2, 1000) -} - -func BenchmarkRocksDBIndexing4Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, rocksdb.Name, rocksdbTestOptions, DestroyTest, 4, 1000) -} diff --git a/index/upsidedown/benchmark_gtreap_test.go b/index/upsidedown/benchmark_gtreap_test.go index 501c42ad5..fb508fd13 100644 --- a/index/upsidedown/benchmark_gtreap_test.go +++ b/index/upsidedown/benchmark_gtreap_test.go @@ -17,7 +17,7 @@ package upsidedown import ( "testing" - "github.com/blevesearch/bleve/index/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" ) func BenchmarkGTreapIndexing1Workers(b *testing.B) { diff --git a/index/upsidedown/benchmark_leveldb_test.go b/index/upsidedown/benchmark_leveldb_test.go deleted file mode 100644 index 8854d6224..000000000 --- a/index/upsidedown/benchmark_leveldb_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2014 Couchbase, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build leveldb - -package upsidedown - -import ( - "testing" - - "github.com/blevesearch/blevex/leveldb" -) - -var leveldbTestOptions = map[string]interface{}{ - "path": "test", - "create_if_missing": true, -} - -func BenchmarkLevelDBIndexing1Workers(b *testing.B) { - CommonBenchmarkIndex(b, leveldb.Name, leveldbTestOptions, DestroyTest, 1) -} - -func BenchmarkLevelDBIndexing2Workers(b *testing.B) { - CommonBenchmarkIndex(b, leveldb.Name, leveldbTestOptions, DestroyTest, 2) -} - -func BenchmarkLevelDBIndexing4Workers(b *testing.B) { - CommonBenchmarkIndex(b, leveldb.Name, leveldbTestOptions, DestroyTest, 4) -} - -// batches - -func BenchmarkLevelDBIndexing1Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 1, 10) -} - -func BenchmarkLevelDBIndexing2Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 2, 10) -} - -func BenchmarkLevelDBIndexing4Workers10Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 4, 10) -} - -func BenchmarkLevelDBIndexing1Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 1, 100) -} - -func BenchmarkLevelDBIndexing2Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 2, 100) -} - -func BenchmarkLevelDBIndexing4Workers100Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 4, 100) -} - -func BenchmarkLevelDBIndexing1Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 1, 1000) -} - -func BenchmarkLevelDBIndexing2Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 2, 1000) -} - -func BenchmarkLevelDBIndexing4Workers1000Batch(b *testing.B) { - CommonBenchmarkIndexBatch(b, leveldb.Name, leveldbTestOptions, DestroyTest, 4, 1000) -} diff --git a/index/upsidedown/benchmark_null_test.go b/index/upsidedown/benchmark_null_test.go index fce4eea23..1576aaefc 100644 --- a/index/upsidedown/benchmark_null_test.go +++ b/index/upsidedown/benchmark_null_test.go @@ -17,7 +17,7 @@ package upsidedown import ( "testing" - "github.com/blevesearch/bleve/index/store/null" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/null" ) func BenchmarkNullIndexing1Workers(b *testing.B) { diff --git a/index/upsidedown/dump.go b/index/upsidedown/dump.go index cb045d249..64ebb1b26 100644 --- a/index/upsidedown/dump.go +++ b/index/upsidedown/dump.go @@ -18,7 +18,7 @@ import ( "bytes" "sort" - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/upsidedown_store_api" ) // the functions in this file are only intended to be used by diff --git a/index/upsidedown/dump_test.go b/index/upsidedown/dump_test.go index 0d816960f..74408532c 100644 --- a/index/upsidedown/dump_test.go +++ b/index/upsidedown/dump_test.go @@ -18,10 +18,10 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/boltdb" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" + index "github.com/blevesearch/bleve_index_api" - "github.com/blevesearch/bleve/document" + "github.com/blevesearch/bleve/v2/document" ) func TestDump(t *testing.T) { @@ -66,9 +66,9 @@ func TestDump(t *testing.T) { } doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -79,9 +79,9 @@ func TestDump(t *testing.T) { } doc = document.NewDocument("2") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test2"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - dateField, err = document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test2"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + dateField, err = document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -96,7 +96,11 @@ func TestDump(t *testing.T) { if err != nil { t.Fatal(err) } - fieldsRows := reader.DumpFields() + upsideDownReader, ok := reader.(*IndexReader) + if !ok { + t.Fatal("dump is only supported by index type upsidedown") + } + fieldsRows := upsideDownReader.DumpFields() for range fieldsRows { fieldsCount++ } @@ -110,7 +114,7 @@ func TestDump(t *testing.T) { // 3 stored fields expectedDocRowCount := int(1 + (2 * (64 / document.DefaultPrecisionStep)) + 3) docRowCount := 0 - docRows := reader.DumpDoc("1") + docRows := upsideDownReader.DumpDoc("1") for range docRows { docRowCount++ } @@ -119,7 +123,7 @@ func TestDump(t *testing.T) { } docRowCount = 0 - docRows = reader.DumpDoc("2") + docRows = upsideDownReader.DumpDoc("2") for range docRows { docRowCount++ } @@ -136,7 +140,7 @@ func TestDump(t *testing.T) { // 16 date term row counts (shared for both docs, same date value) expectedAllRowCount := int(1 + fieldsCount + (2 * expectedDocRowCount) + 2 + 2 + int((2 * (64 / document.DefaultPrecisionStep)))) allRowCount := 0 - allRows := reader.DumpAll() + allRows := upsideDownReader.DumpAll() for range allRows { allRowCount++ } diff --git a/index/field_cache.go b/index/upsidedown/field_cache.go similarity index 99% rename from index/field_cache.go rename to index/upsidedown/field_cache.go index 9354081f1..1f68b71dd 100644 --- a/index/field_cache.go +++ b/index/upsidedown/field_cache.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package index +package upsidedown import ( "sync" diff --git a/index/upsidedown/field_dict.go b/index/upsidedown/field_dict.go index 20d4eb34f..c4be57740 100644 --- a/index/upsidedown/field_dict.go +++ b/index/upsidedown/field_dict.go @@ -17,8 +17,8 @@ package upsidedown import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" + index "github.com/blevesearch/bleve_index_api" + store "github.com/blevesearch/upsidedown_store_api" ) type UpsideDownCouchFieldDict struct { diff --git a/index/upsidedown/field_dict_test.go b/index/upsidedown/field_dict_test.go index 3c59bb212..b3b3d9179 100644 --- a/index/upsidedown/field_dict_test.go +++ b/index/upsidedown/field_dict_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/boltdb" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" ) func TestIndexFieldDict(t *testing.T) { @@ -58,8 +58,8 @@ func TestIndexFieldDict(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextFieldWithAnalyzer("name", []uint64{}, []byte("test test test"), testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("prefix", []uint64{}, []byte("bob cat cats catting dog doggy zoo"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("prefix", []uint64{}, []byte("bob cat cats catting dog doggy zoo"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) diff --git a/index/upsidedown/index_reader.go b/index/upsidedown/index_reader.go index ea7243eaa..ff0986d57 100644 --- a/index/upsidedown/index_reader.go +++ b/index/upsidedown/index_reader.go @@ -17,9 +17,9 @@ package upsidedown import ( "reflect" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/upsidedown_store_api" ) var reflectStaticSizeIndexReader int @@ -67,7 +67,7 @@ func (i *IndexReader) DocIDReaderOnly(ids []string) (index.DocIDReader, error) { return newUpsideDownCouchDocIDReaderOnly(i, ids) } -func (i *IndexReader) Document(id string) (doc *document.Document, err error) { +func (i *IndexReader) Document(id string) (doc index.Document, err error) { // first hit the back index to confirm doc exists var backIndexRow *BackIndexRow backIndexRow, err = backIndexRowForDoc(i.kvreader, []byte(id)) @@ -77,7 +77,7 @@ func (i *IndexReader) Document(id string) (doc *document.Document, err error) { if backIndexRow == nil { return } - doc = document.NewDocument(id) + rvd := document.NewDocument(id) storedRow := NewStoredRow([]byte(id), 0, []uint64{}, 'x', nil) storedRowScanPrefix := storedRow.ScanPrefixForDoc() it := i.kvreader.PrefixIterator(storedRowScanPrefix) @@ -93,24 +93,23 @@ func (i *IndexReader) Document(id string) (doc *document.Document, err error) { var row *StoredRow row, err = NewStoredRowKV(key, safeVal) if err != nil { - doc = nil - return + return nil, err } if row != nil { fieldName := i.index.fieldCache.FieldIndexed(row.field) field := decodeFieldType(row.typ, fieldName, row.arrayPositions, row.value) if field != nil { - doc.AddField(field) + rvd.AddField(field) } } it.Next() key, val, valid = it.Current() } - return + return rvd, nil } -func (i *IndexReader) DocumentVisitFieldTerms(id index.IndexInternalID, fields []string, visitor index.DocumentFieldTermVisitor) error { +func (i *IndexReader) documentVisitFieldTerms(id index.IndexInternalID, fields []string, visitor index.DocValueVisitor) error { fieldsMap := make(map[uint16]string, len(fields)) for _, f := range fields { id, ok := i.index.fieldCache.FieldNamed(f, false) @@ -221,6 +220,6 @@ type DocValueReader struct { } func (dvr *DocValueReader) VisitDocValues(id index.IndexInternalID, - visitor index.DocumentFieldTermVisitor) error { - return dvr.i.DocumentVisitFieldTerms(id, dvr.fields, visitor) + visitor index.DocValueVisitor) error { + return dvr.i.documentVisitFieldTerms(id, dvr.fields, visitor) } diff --git a/index/upsidedown/reader.go b/index/upsidedown/reader.go index bc0fef119..701967298 100644 --- a/index/upsidedown/reader.go +++ b/index/upsidedown/reader.go @@ -20,9 +20,9 @@ import ( "sort" "sync/atomic" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeUpsideDownCouchTermFieldReader int diff --git a/index/upsidedown/reader_test.go b/index/upsidedown/reader_test.go index 22317a3ba..1abc4f197 100644 --- a/index/upsidedown/reader_test.go +++ b/index/upsidedown/reader_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/boltdb" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" ) func TestIndexReader(t *testing.T) { @@ -58,7 +58,7 @@ func TestIndexReader(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextFieldWithAnalyzer("name", []uint64{}, []byte("test test test"), testAnalyzer)) - doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors, testAnalyzer)) + doc.AddField(document.NewTextFieldCustom("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors, testAnalyzer)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -233,7 +233,7 @@ func TestIndexDocIdReader(t *testing.T) { doc = document.NewDocument("2") doc.AddField(document.NewTextField("name", []uint64{}, []byte("test test test"))) - doc.AddField(document.NewTextFieldWithIndexingOptions("desc", []uint64{}, []byte("eat more rice"), document.IndexField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("desc", []uint64{}, []byte("eat more rice"), index.IndexField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) diff --git a/index/upsidedown/row.go b/index/upsidedown/row.go index 531e0a0d3..901a4bcb0 100644 --- a/index/upsidedown/row.go +++ b/index/upsidedown/row.go @@ -22,7 +22,7 @@ import ( "math" "reflect" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/size" "github.com/golang/protobuf/proto" ) diff --git a/index/upsidedown/stats.go b/index/upsidedown/stats.go index a148ab704..c1b4ddc01 100644 --- a/index/upsidedown/stats.go +++ b/index/upsidedown/stats.go @@ -18,7 +18,7 @@ import ( "encoding/json" "sync/atomic" - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/upsidedown_store_api" ) type indexStat struct { diff --git a/index/store/boltdb/iterator.go b/index/upsidedown/store/boltdb/iterator.go similarity index 100% rename from index/store/boltdb/iterator.go rename to index/upsidedown/store/boltdb/iterator.go diff --git a/index/store/boltdb/reader.go b/index/upsidedown/store/boltdb/reader.go similarity index 96% rename from index/store/boltdb/reader.go rename to index/upsidedown/store/boltdb/reader.go index 7977ebbe5..79513f600 100644 --- a/index/store/boltdb/reader.go +++ b/index/upsidedown/store/boltdb/reader.go @@ -15,7 +15,7 @@ package boltdb import ( - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" bolt "go.etcd.io/bbolt" ) diff --git a/index/store/boltdb/stats.go b/index/upsidedown/store/boltdb/stats.go similarity index 100% rename from index/store/boltdb/stats.go rename to index/upsidedown/store/boltdb/stats.go diff --git a/index/store/boltdb/store.go b/index/upsidedown/store/boltdb/store.go similarity index 97% rename from index/store/boltdb/store.go rename to index/upsidedown/store/boltdb/store.go index 3c749693c..ac3a0f825 100644 --- a/index/store/boltdb/store.go +++ b/index/upsidedown/store/boltdb/store.go @@ -28,8 +28,8 @@ import ( "fmt" "os" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" bolt "go.etcd.io/bbolt" ) diff --git a/index/store/boltdb/store_test.go b/index/upsidedown/store/boltdb/store_test.go similarity index 96% rename from index/store/boltdb/store_test.go rename to index/upsidedown/store/boltdb/store_test.go index ae4cca3e0..6f2b0e78a 100644 --- a/index/store/boltdb/store_test.go +++ b/index/upsidedown/store/boltdb/store_test.go @@ -18,8 +18,8 @@ import ( "os" "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/upsidedown_store_api/test" bolt "go.etcd.io/bbolt" ) diff --git a/index/store/boltdb/writer.go b/index/upsidedown/store/boltdb/writer.go similarity index 97% rename from index/store/boltdb/writer.go rename to index/upsidedown/store/boltdb/writer.go index f09357457..c25583cab 100644 --- a/index/store/boltdb/writer.go +++ b/index/upsidedown/store/boltdb/writer.go @@ -17,7 +17,7 @@ package boltdb import ( "fmt" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type Writer struct { diff --git a/index/store/goleveldb/batch.go b/index/upsidedown/store/goleveldb/batch.go similarity index 95% rename from index/store/goleveldb/batch.go rename to index/upsidedown/store/goleveldb/batch.go index f14c18a60..7a58bb83b 100644 --- a/index/store/goleveldb/batch.go +++ b/index/upsidedown/store/goleveldb/batch.go @@ -15,7 +15,7 @@ package goleveldb import ( - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/index/store/goleveldb/config.go b/index/upsidedown/store/goleveldb/config.go similarity index 100% rename from index/store/goleveldb/config.go rename to index/upsidedown/store/goleveldb/config.go diff --git a/index/store/goleveldb/iterator.go b/index/upsidedown/store/goleveldb/iterator.go similarity index 100% rename from index/store/goleveldb/iterator.go rename to index/upsidedown/store/goleveldb/iterator.go diff --git a/index/store/goleveldb/reader.go b/index/upsidedown/store/goleveldb/reader.go similarity index 96% rename from index/store/goleveldb/reader.go rename to index/upsidedown/store/goleveldb/reader.go index bb2ff6538..584109269 100644 --- a/index/store/goleveldb/reader.go +++ b/index/upsidedown/store/goleveldb/reader.go @@ -15,7 +15,7 @@ package goleveldb import ( - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/util" ) diff --git a/index/store/goleveldb/store.go b/index/upsidedown/store/goleveldb/store.go similarity index 97% rename from index/store/goleveldb/store.go rename to index/upsidedown/store/goleveldb/store.go index d53cdb5b6..fcd961b9a 100644 --- a/index/store/goleveldb/store.go +++ b/index/upsidedown/store/goleveldb/store.go @@ -19,8 +19,8 @@ import ( "fmt" "os" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/util" diff --git a/index/store/goleveldb/store_test.go b/index/upsidedown/store/goleveldb/store_test.go similarity index 95% rename from index/store/goleveldb/store_test.go rename to index/upsidedown/store/goleveldb/store_test.go index 48b921a3d..c9e5d4db3 100644 --- a/index/store/goleveldb/store_test.go +++ b/index/upsidedown/store/goleveldb/store_test.go @@ -18,8 +18,8 @@ import ( "os" "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/upsidedown_store_api/test" ) func open(t *testing.T, mo store.MergeOperator) store.KVStore { diff --git a/index/store/goleveldb/writer.go b/index/upsidedown/store/goleveldb/writer.go similarity index 97% rename from index/store/goleveldb/writer.go rename to index/upsidedown/store/goleveldb/writer.go index 6712c95fd..4746c94fe 100644 --- a/index/store/goleveldb/writer.go +++ b/index/upsidedown/store/goleveldb/writer.go @@ -17,7 +17,7 @@ package goleveldb import ( "fmt" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/index/store/gtreap/iterator.go b/index/upsidedown/store/gtreap/iterator.go similarity index 100% rename from index/store/gtreap/iterator.go rename to index/upsidedown/store/gtreap/iterator.go diff --git a/index/store/gtreap/reader.go b/index/upsidedown/store/gtreap/reader.go similarity index 97% rename from index/store/gtreap/reader.go rename to index/upsidedown/store/gtreap/reader.go index 98254d347..34df81302 100644 --- a/index/store/gtreap/reader.go +++ b/index/upsidedown/store/gtreap/reader.go @@ -18,7 +18,7 @@ package gtreap import ( - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/upsidedown_store_api" "github.com/steveyen/gtreap" ) diff --git a/index/store/gtreap/store.go b/index/upsidedown/store/gtreap/store.go similarity index 94% rename from index/store/gtreap/store.go rename to index/upsidedown/store/gtreap/store.go index 3e6c5fec1..8a81663d3 100644 --- a/index/store/gtreap/store.go +++ b/index/upsidedown/store/gtreap/store.go @@ -24,8 +24,8 @@ import ( "os" "sync" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" "github.com/steveyen/gtreap" ) diff --git a/index/store/gtreap/store_test.go b/index/upsidedown/store/gtreap/store_test.go similarity index 95% rename from index/store/gtreap/store_test.go rename to index/upsidedown/store/gtreap/store_test.go index 86bc5a101..2fc3aa87f 100644 --- a/index/store/gtreap/store_test.go +++ b/index/upsidedown/store/gtreap/store_test.go @@ -17,8 +17,8 @@ package gtreap import ( "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/upsidedown_store_api/test" ) func open(t *testing.T, mo store.MergeOperator) store.KVStore { diff --git a/index/store/gtreap/writer.go b/index/upsidedown/store/gtreap/writer.go similarity index 97% rename from index/store/gtreap/writer.go rename to index/upsidedown/store/gtreap/writer.go index 777aab406..80aa15b19 100644 --- a/index/store/gtreap/writer.go +++ b/index/upsidedown/store/gtreap/writer.go @@ -21,7 +21,7 @@ import ( "fmt" "math/rand" - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/upsidedown_store_api" ) type Writer struct { diff --git a/index/store/metrics/batch.go b/index/upsidedown/store/metrics/batch.go similarity index 94% rename from index/store/metrics/batch.go rename to index/upsidedown/store/metrics/batch.go index a044b592e..8293509d6 100644 --- a/index/store/metrics/batch.go +++ b/index/upsidedown/store/metrics/batch.go @@ -14,7 +14,7 @@ package metrics -import "github.com/blevesearch/bleve/index/store" +import store "github.com/blevesearch/upsidedown_store_api" type Batch struct { s *Store diff --git a/index/store/metrics/iterator.go b/index/upsidedown/store/metrics/iterator.go similarity index 95% rename from index/store/metrics/iterator.go rename to index/upsidedown/store/metrics/iterator.go index 0cbe1ae75..c55d2c3d4 100644 --- a/index/store/metrics/iterator.go +++ b/index/upsidedown/store/metrics/iterator.go @@ -14,7 +14,7 @@ package metrics -import "github.com/blevesearch/bleve/index/store" +import store "github.com/blevesearch/upsidedown_store_api" type Iterator struct { s *Store diff --git a/index/store/metrics/metrics_test.go b/index/upsidedown/store/metrics/metrics_test.go similarity index 98% rename from index/store/metrics/metrics_test.go rename to index/upsidedown/store/metrics/metrics_test.go index fb78514bf..416a7dc1d 100644 --- a/index/store/metrics/metrics_test.go +++ b/index/upsidedown/store/metrics/metrics_test.go @@ -20,7 +20,7 @@ import ( "fmt" "testing" - "github.com/blevesearch/bleve/index/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" ) func TestMetricsStore(t *testing.T) { diff --git a/index/store/metrics/reader.go b/index/upsidedown/store/metrics/reader.go similarity index 96% rename from index/store/metrics/reader.go rename to index/upsidedown/store/metrics/reader.go index ca6ae194c..ad1c25a5d 100644 --- a/index/store/metrics/reader.go +++ b/index/upsidedown/store/metrics/reader.go @@ -14,7 +14,7 @@ package metrics -import "github.com/blevesearch/bleve/index/store" +import store "github.com/blevesearch/upsidedown_store_api" type Reader struct { s *Store diff --git a/index/store/metrics/stats.go b/index/upsidedown/store/metrics/stats.go similarity index 96% rename from index/store/metrics/stats.go rename to index/upsidedown/store/metrics/stats.go index e27e152c7..c30d2dd62 100644 --- a/index/store/metrics/stats.go +++ b/index/upsidedown/store/metrics/stats.go @@ -17,7 +17,7 @@ package metrics import ( "encoding/json" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type stats struct { diff --git a/index/store/metrics/store.go b/index/upsidedown/store/metrics/store.go similarity index 98% rename from index/store/metrics/store.go rename to index/upsidedown/store/metrics/store.go index dea193454..376dce2d3 100644 --- a/index/store/metrics/store.go +++ b/index/upsidedown/store/metrics/store.go @@ -25,8 +25,8 @@ import ( "sync" "time" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" "github.com/rcrowley/go-metrics" ) diff --git a/index/store/metrics/store_test.go b/index/upsidedown/store/metrics/store_test.go similarity index 92% rename from index/store/metrics/store_test.go rename to index/upsidedown/store/metrics/store_test.go index c20633af3..0cd00af23 100644 --- a/index/store/metrics/store_test.go +++ b/index/upsidedown/store/metrics/store_test.go @@ -17,9 +17,9 @@ package metrics import ( "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/upsidedown_store_api/test" ) func open(t *testing.T, mo store.MergeOperator) store.KVStore { diff --git a/index/store/metrics/util.go b/index/upsidedown/store/metrics/util.go similarity index 100% rename from index/store/metrics/util.go rename to index/upsidedown/store/metrics/util.go diff --git a/index/store/metrics/writer.go b/index/upsidedown/store/metrics/writer.go similarity index 96% rename from index/store/metrics/writer.go rename to index/upsidedown/store/metrics/writer.go index 8a6b024f6..c278e3882 100644 --- a/index/store/metrics/writer.go +++ b/index/upsidedown/store/metrics/writer.go @@ -17,7 +17,7 @@ package metrics import ( "fmt" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type Writer struct { diff --git a/index/store/moss/batch.go b/index/upsidedown/store/moss/batch.go similarity index 97% rename from index/store/moss/batch.go rename to index/upsidedown/store/moss/batch.go index 13eac14db..0aa998a2f 100644 --- a/index/store/moss/batch.go +++ b/index/upsidedown/store/moss/batch.go @@ -17,7 +17,7 @@ package moss import ( "github.com/couchbase/moss" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type Batch struct { diff --git a/index/store/moss/iterator.go b/index/upsidedown/store/moss/iterator.go similarity index 100% rename from index/store/moss/iterator.go rename to index/upsidedown/store/moss/iterator.go diff --git a/index/store/moss/lower.go b/index/upsidedown/store/moss/lower.go similarity index 99% rename from index/store/moss/lower.go rename to index/upsidedown/store/moss/lower.go index 1133f95f6..cfe570929 100644 --- a/index/store/moss/lower.go +++ b/index/upsidedown/store/moss/lower.go @@ -25,8 +25,8 @@ import ( "github.com/couchbase/moss" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" ) func initLowerLevelStore( diff --git a/index/store/moss/lower_test.go b/index/upsidedown/store/moss/lower_test.go similarity index 96% rename from index/store/moss/lower_test.go rename to index/upsidedown/store/moss/lower_test.go index afc0a0959..10626da7b 100644 --- a/index/store/moss/lower_test.go +++ b/index/upsidedown/store/moss/lower_test.go @@ -19,8 +19,8 @@ import ( "os" "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/upsidedown_store_api/test" ) func openWithLower(t *testing.T, mo store.MergeOperator) (string, store.KVStore) { diff --git a/index/store/moss/reader.go b/index/upsidedown/store/moss/reader.go similarity index 97% rename from index/store/moss/reader.go rename to index/upsidedown/store/moss/reader.go index 6aca999e3..93063cdc7 100644 --- a/index/store/moss/reader.go +++ b/index/upsidedown/store/moss/reader.go @@ -17,7 +17,7 @@ package moss import ( "github.com/couchbase/moss" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type Reader struct { diff --git a/index/store/moss/stats.go b/index/upsidedown/store/moss/stats.go similarity index 96% rename from index/store/moss/stats.go rename to index/upsidedown/store/moss/stats.go index 4a6493616..c39fc4b99 100644 --- a/index/store/moss/stats.go +++ b/index/upsidedown/store/moss/stats.go @@ -17,7 +17,7 @@ package moss import ( "encoding/json" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) type stats struct { diff --git a/index/store/moss/store.go b/index/upsidedown/store/moss/store.go similarity index 98% rename from index/store/moss/store.go rename to index/upsidedown/store/moss/store.go index 47aab076f..5253f08b0 100644 --- a/index/store/moss/store.go +++ b/index/upsidedown/store/moss/store.go @@ -24,8 +24,8 @@ import ( "github.com/couchbase/moss" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" ) // RegistryCollectionOptions should be treated as read-only after diff --git a/index/store/moss/store_test.go b/index/upsidedown/store/moss/store_test.go similarity index 95% rename from index/store/moss/store_test.go rename to index/upsidedown/store/moss/store_test.go index e9c24784e..49013b6d2 100644 --- a/index/store/moss/store_test.go +++ b/index/upsidedown/store/moss/store_test.go @@ -17,8 +17,8 @@ package moss import ( "testing" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/store/test" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/upsidedown_store_api/test" ) func open(t *testing.T, mo store.MergeOperator) store.KVStore { diff --git a/index/store/moss/writer.go b/index/upsidedown/store/moss/writer.go similarity index 97% rename from index/store/moss/writer.go rename to index/upsidedown/store/moss/writer.go index a8f888d58..cb447167f 100644 --- a/index/store/moss/writer.go +++ b/index/upsidedown/store/moss/writer.go @@ -17,7 +17,7 @@ package moss import ( "fmt" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" "github.com/couchbase/moss" ) diff --git a/index/store/null/null.go b/index/upsidedown/store/null/null.go similarity index 96% rename from index/store/null/null.go rename to index/upsidedown/store/null/null.go index 5201b8ba6..f88d482da 100644 --- a/index/store/null/null.go +++ b/index/upsidedown/store/null/null.go @@ -15,8 +15,8 @@ package null import ( - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + store "github.com/blevesearch/upsidedown_store_api" + "github.com/blevesearch/bleve/v2/registry" ) const Name = "null" diff --git a/index/store/null/null_test.go b/index/upsidedown/store/null/null_test.go similarity index 97% rename from index/store/null/null_test.go rename to index/upsidedown/store/null/null_test.go index 7589da678..2042f4d9e 100644 --- a/index/store/null/null_test.go +++ b/index/upsidedown/store/null/null_test.go @@ -17,7 +17,7 @@ package null import ( "testing" - "github.com/blevesearch/bleve/index/store" + store "github.com/blevesearch/upsidedown_store_api" ) func TestStore(t *testing.T) { diff --git a/index/upsidedown/upsidedown.go b/index/upsidedown/upsidedown.go index 8e915c6ad..d67ee03fb 100644 --- a/index/upsidedown/upsidedown.go +++ b/index/upsidedown/upsidedown.go @@ -25,11 +25,10 @@ import ( "sync/atomic" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/registry" + index "github.com/blevesearch/bleve_index_api" + store "github.com/blevesearch/upsidedown_store_api" "github.com/golang/protobuf/proto" ) @@ -49,13 +48,15 @@ const Version uint8 = 7 var IncompatibleVersion = fmt.Errorf("incompatible version, %d is supported", Version) +var ErrorUnknownStorageType = fmt.Errorf("unknown storage type") + type UpsideDownCouch struct { version uint8 path string storeName string storeConfig map[string]interface{} store store.KVStore - fieldCache *index.FieldCache + fieldCache *FieldCache analysisQueue *index.AnalysisQueue stats *indexStat @@ -68,14 +69,14 @@ type UpsideDownCouch struct { type docBackIndexRow struct { docID string - doc *document.Document // If deletion, doc will be nil. + doc index.Document // If deletion, doc will be nil. backIndexRow *BackIndexRow } func NewUpsideDownCouch(storeName string, storeConfig map[string]interface{}, analysisQueue *index.AnalysisQueue) (index.Index, error) { rv := &UpsideDownCouch{ version: Version, - fieldCache: index.NewFieldCache(), + fieldCache: NewFieldCache(), storeName: storeName, storeConfig: storeConfig, analysisQueue: analysisQueue, @@ -300,7 +301,7 @@ func (udc *UpsideDownCouch) Open() (err error) { // open the kv store storeConstructor := registry.KVStoreConstructorByName(udc.storeName) if storeConstructor == nil { - err = index.ErrorUnknownStorageType + err = ErrorUnknownStorageType return } @@ -412,14 +413,16 @@ func (udc *UpsideDownCouch) Close() error { return udc.store.Close() } -func (udc *UpsideDownCouch) Update(doc *document.Document) (err error) { +func (udc *UpsideDownCouch) Update(doc index.Document) (err error) { // do analysis before acquiring write lock analysisStart := time.Now() - resultChan := make(chan *index.AnalysisResult) - aw := index.NewAnalysisWork(udc, doc, resultChan) + resultChan := make(chan *AnalysisResult) // put the work on the queue - udc.analysisQueue.Queue(aw) + udc.analysisQueue.Queue(func() { + ar := udc.analyze(doc) + resultChan <- ar + }) // wait for the result result := <-resultChan @@ -439,7 +442,7 @@ func (udc *UpsideDownCouch) Update(doc *document.Document) (err error) { // first we lookup the backindex row for the doc id if it exists // lookup the back index row var backIndexRow *BackIndexRow - backIndexRow, err = backIndexRowForDoc(kvreader, index.IndexInternalID(doc.ID)) + backIndexRow, err = backIndexRowForDoc(kvreader, index.IndexInternalID(doc.ID())) if err != nil { _ = kvreader.Close() atomic.AddUint64(&udc.stats.errors, 1) @@ -454,8 +457,8 @@ func (udc *UpsideDownCouch) Update(doc *document.Document) (err error) { return udc.UpdateWithAnalysis(doc, result, backIndexRow) } -func (udc *UpsideDownCouch) UpdateWithAnalysis(doc *document.Document, - result *index.AnalysisResult, backIndexRow *BackIndexRow) (err error) { +func (udc *UpsideDownCouch) UpdateWithAnalysis(doc index.Document, + result *AnalysisResult, backIndexRow *BackIndexRow) (err error) { // start a writer for this update indexStart := time.Now() var kvwriter store.KVWriter @@ -501,7 +504,7 @@ func (udc *UpsideDownCouch) UpdateWithAnalysis(doc *document.Document, return } -func (udc *UpsideDownCouch) mergeOldAndNew(backIndexRow *BackIndexRow, rows []index.IndexRow) (addRows []UpsideDownCouchRow, updateRows []UpsideDownCouchRow, deleteRows []UpsideDownCouchRow) { +func (udc *UpsideDownCouch) mergeOldAndNew(backIndexRow *BackIndexRow, rows []IndexRow) (addRows []UpsideDownCouchRow, updateRows []UpsideDownCouchRow, deleteRows []UpsideDownCouchRow) { addRows = make([]UpsideDownCouchRow, 0, len(rows)) if backIndexRow == nil { @@ -587,8 +590,8 @@ func (udc *UpsideDownCouch) mergeOldAndNew(backIndexRow *BackIndexRow, rows []in return addRows, updateRows, deleteRows } -func (udc *UpsideDownCouch) storeField(docID []byte, field document.Field, fieldIndex uint16, rows []index.IndexRow, backIndexStoredEntries []*BackIndexStoreEntry) ([]index.IndexRow, []*BackIndexStoreEntry) { - fieldType := encodeFieldType(field) +func (udc *UpsideDownCouch) storeField(docID []byte, field index.Field, fieldIndex uint16, rows []IndexRow, backIndexStoredEntries []*BackIndexStoreEntry) ([]IndexRow, []*BackIndexStoreEntry) { + fieldType := field.EncodedFieldType() storedRow := NewStoredRow(docID, fieldIndex, field.ArrayPositions(), fieldType, field.Value()) // record the back index entry @@ -597,26 +600,7 @@ func (udc *UpsideDownCouch) storeField(docID []byte, field document.Field, field return append(rows, storedRow), append(backIndexStoredEntries, &backIndexStoredEntry) } -func encodeFieldType(f document.Field) byte { - fieldType := byte('x') - switch f.(type) { - case *document.TextField: - fieldType = 't' - case *document.NumericField: - fieldType = 'n' - case *document.DateTimeField: - fieldType = 'd' - case *document.BooleanField: - fieldType = 'b' - case *document.GeoPointField: - fieldType = 'g' - case *document.CompositeField: - fieldType = 'c' - } - return fieldType -} - -func (udc *UpsideDownCouch) indexField(docID []byte, includeTermVectors bool, fieldIndex uint16, fieldLength int, tokenFreqs analysis.TokenFrequencies, rows []index.IndexRow, backIndexTermsEntries []*BackIndexTermsEntry) ([]index.IndexRow, []*BackIndexTermsEntry) { +func (udc *UpsideDownCouch) indexField(docID []byte, includeTermVectors bool, fieldIndex uint16, fieldLength int, tokenFreqs index.TokenFrequencies, rows []IndexRow, backIndexTermsEntries []*BackIndexTermsEntry) ([]IndexRow, []*BackIndexTermsEntry) { fieldNorm := float32(1.0 / math.Sqrt(float64(fieldLength))) termFreqRows := make([]TermFrequencyRow, len(tokenFreqs)) @@ -747,11 +731,11 @@ func decodeFieldType(typ byte, name string, pos []uint64, value []byte) document return nil } -func frequencyFromTokenFreq(tf *analysis.TokenFreq) int { +func frequencyFromTokenFreq(tf *index.TokenFreq) int { return tf.Frequency() } -func (udc *UpsideDownCouch) termVectorsFromTokenFreq(field uint16, tf *analysis.TokenFreq, rows []index.IndexRow) ([]*TermVector, []index.IndexRow) { +func (udc *UpsideDownCouch) termVectorsFromTokenFreq(field uint16, tf *index.TokenFreq, rows []IndexRow) ([]*TermVector, []IndexRow) { a := make([]TermVector, len(tf.Locations)) rv := make([]*TermVector, len(tf.Locations)) @@ -807,7 +791,7 @@ func (udc *UpsideDownCouch) Batch(batch *index.Batch) (err error) { } analysisStart := time.Now() - resultChan := make(chan *index.AnalysisResult, len(batch.IndexOps)) + resultChan := make(chan *AnalysisResult, len(batch.IndexOps)) var numUpdates uint64 var numPlainTextBytes uint64 @@ -823,9 +807,11 @@ func (udc *UpsideDownCouch) Batch(batch *index.Batch) (err error) { for k := range batch.IndexOps { doc := batch.IndexOps[k] if doc != nil { - aw := index.NewAnalysisWork(udc, doc, resultChan) // put the work on the queue - udc.analysisQueue.Queue(aw) + udc.analysisQueue.Queue(func() { + ar := udc.analyze(doc) + resultChan <- ar + }) } } }() @@ -866,7 +852,7 @@ func (udc *UpsideDownCouch) Batch(batch *index.Batch) (err error) { }() // wait for analysis result - newRowsMap := make(map[string][]index.IndexRow) + newRowsMap := make(map[string][]IndexRow) var itemsDeQueued uint64 for itemsDeQueued < numUpdates { result := <-resultChan diff --git a/index/upsidedown/upsidedown_test.go b/index/upsidedown/upsidedown_test.go index cc7cccfcb..0d72c5504 100644 --- a/index/upsidedown/upsidedown_test.go +++ b/index/upsidedown/upsidedown_test.go @@ -24,14 +24,14 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - regexpTokenizer "github.com/blevesearch/bleve/analysis/tokenizer/regexp" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/boltdb" - "github.com/blevesearch/bleve/index/store/null" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + regexpTokenizer "github.com/blevesearch/bleve/v2/analysis/tokenizer/regexp" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/null" + "github.com/blevesearch/bleve/v2/registry" ) var testAnalyzer = &analysis.Analyzer{ @@ -511,7 +511,7 @@ func TestIndexInsertWithStore(t *testing.T) { } doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -555,10 +555,11 @@ func TestIndexInsertWithStore(t *testing.T) { } }() - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) if len(storedDoc.Fields) != 1 { t.Errorf("expected 1 stored field, got %d", len(storedDoc.Fields)) @@ -809,9 +810,9 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { } doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - df, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + df, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -863,10 +864,11 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { t.Error(err) } - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) err = indexReader.Close() if err != nil { @@ -910,8 +912,8 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { // now update the document, but omit one of the fields doc = document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testup"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 36.99, document.IndexField|document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testup"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 36.99, index.IndexField|index.StoreField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -932,10 +934,11 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) { } // should only get 2 fields back now though - storedDoc, err = indexReader2.Document("1") + storedDocInt, err = indexReader2.Document("1") if err != nil { t.Error(err) } + storedDoc = storedDocInt.(*document.Document) err = indexReader2.Close() if err != nil { @@ -1012,9 +1015,9 @@ func TestIndexInsertFields(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, document.IndexField|document.StoreField)) - dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), document.IndexField|document.StoreField) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewNumericFieldWithIndexingOptions("age", []uint64{}, 35.99, index.IndexField|index.StoreField)) + dateField, err := document.NewDateTimeFieldWithIndexingOptions("unixEpoch", []uint64{}, time.Unix(0, 0), index.IndexField|index.StoreField) if err != nil { t.Error(err) } @@ -1072,9 +1075,9 @@ func TestIndexUpdateComposites(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1098,9 +1101,9 @@ func TestIndexUpdateComposites(t *testing.T) { // now lets update it doc = document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testupdated"), document.IndexField|document.StoreField)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("misterupdated"), document.IndexField|document.StoreField)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("testupdated"), index.IndexField|index.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("misterupdated"), index.IndexField|index.StoreField)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1118,10 +1121,11 @@ func TestIndexUpdateComposites(t *testing.T) { }() // make sure new values are in index - storedDoc, err := indexReader.Document("1") + storedDocInt, err := indexReader.Document("1") if err != nil { t.Error(err) } + storedDoc := storedDocInt.(*document.Document) if len(storedDoc.Fields) != 2 { t.Errorf("expected 2 stored field, got %d", len(storedDoc.Fields)) } @@ -1169,8 +1173,8 @@ func TestIndexFieldsMisc(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1216,9 +1220,9 @@ func TestIndexTermReaderCompositeFields(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, document.IndexField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewCompositeFieldWithIndexingOptions("_all", true, nil, nil, index.IndexField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1252,7 +1256,7 @@ func TestIndexTermReaderCompositeFields(t *testing.T) { } } -func TestIndexDocumentVisitFieldTerms(t *testing.T) { +func TestIndexDocValueReader(t *testing.T) { defer func() { err := DestroyTest() if err != nil { @@ -1277,8 +1281,8 @@ func TestIndexDocumentVisitFieldTerms(t *testing.T) { }() doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), document.IndexField|document.StoreField|document.IncludeTermVectors)) - doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), document.IndexField|document.StoreField|document.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("name", []uint64{}, []byte("test"), index.IndexField|index.StoreField|index.IncludeTermVectors)) + doc.AddField(document.NewTextFieldWithIndexingOptions("title", []uint64{}, []byte("mister"), index.IndexField|index.StoreField|index.IncludeTermVectors)) err = idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1295,20 +1299,25 @@ func TestIndexDocumentVisitFieldTerms(t *testing.T) { } }() - fieldTerms := make(index.FieldTerms) + actualFieldTerms := make(fieldTerms) - err = indexReader.DocumentVisitFieldTerms(index.IndexInternalID("1"), []string{"name", "title"}, func(field string, term []byte) { - fieldTerms[field] = append(fieldTerms[field], string(term)) + dvr, err := indexReader.DocValueReader([]string{"name", "title"}) + if err != nil { + t.Error(err) + } + + err = dvr.VisitDocValues(index.IndexInternalID("1"), func(field string, term []byte) { + actualFieldTerms[field] = append(actualFieldTerms[field], string(term)) }) if err != nil { t.Error(err) } - expectedFieldTerms := index.FieldTerms{ + expectedFieldTerms := fieldTerms{ "name": []string{"test"}, "title": []string{"mister"}, } - if !reflect.DeepEqual(fieldTerms, expectedFieldTerms) { - t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, fieldTerms) + if !reflect.DeepEqual(actualFieldTerms, expectedFieldTerms) { + t.Errorf("expected field terms: %#v, got: %#v", expectedFieldTerms, actualFieldTerms) } } @@ -1378,7 +1387,7 @@ func TestConcurrentUpdate(t *testing.T) { wg.Add(1) go func(i int) { doc := document.NewDocument("1") - doc.AddField(document.NewTextFieldWithIndexingOptions(strconv.Itoa(i), []uint64{}, []byte(strconv.Itoa(i)), document.StoreField)) + doc.AddField(document.NewTextFieldWithIndexingOptions(strconv.Itoa(i), []uint64{}, []byte(strconv.Itoa(i)), index.StoreField)) err := idx.Update(doc) if err != nil { t.Errorf("Error updating index: %v", err) @@ -1394,10 +1403,11 @@ func TestConcurrentUpdate(t *testing.T) { log.Fatal(err) } - doc, err := r.Document("1") + docInt, err := r.Document("1") if err != nil { log.Fatal(err) } + doc := docInt.(*document.Document) if len(doc.Fields) > 1 { t.Errorf("expected single field, found %d", len(doc.Fields)) @@ -1440,7 +1450,7 @@ func TestLargeField(t *testing.T) { t.Logf("large field size: %d", len(largeFieldValue)) d := document.NewDocument("large") - f := document.NewTextFieldWithIndexingOptions("desc", nil, largeFieldValue, document.IndexField|document.StoreField) + f := document.NewTextFieldWithIndexingOptions("desc", nil, largeFieldValue, index.IndexField|index.StoreField) d.AddField(f) err = idx.Update(d) @@ -1493,3 +1503,26 @@ func TestIndexBatchPersistedCallbackWithErrorUpsideDown(t *testing.T) { } } + +// fieldTerms contains the terms used by a document, keyed by field +type fieldTerms map[string][]string + +// FieldsNotYetCached returns a list of fields not yet cached out of a larger list of fields +func (f fieldTerms) FieldsNotYetCached(fields []string) []string { + rv := make([]string, 0, len(fields)) + for _, field := range fields { + if _, ok := f[field]; !ok { + rv = append(rv, field) + } + } + return rv +} + +// Merge will combine two fieldTerms +// it assumes that the terms lists are complete (thus do not need to be merged) +// field terms from the other list always replace the ones in the receiver +func (f fieldTerms) Merge(other fieldTerms) { + for field, terms := range other { + f[field] = terms + } +} \ No newline at end of file diff --git a/index_alias_impl.go b/index_alias_impl.go index 5aa57d8ac..5a4dc5a48 100644 --- a/index_alias_impl.go +++ b/index_alias_impl.go @@ -19,11 +19,9 @@ import ( "sync" "time" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + index "github.com/blevesearch/bleve_index_api" ) type indexAliasImpl struct { @@ -110,7 +108,7 @@ func (i *indexAliasImpl) Batch(b *Batch) error { return i.indexes[0].Batch(b) } -func (i *indexAliasImpl) Document(id string) (*document.Document, error) { +func (i *indexAliasImpl) Document(id string) (index.Document, error) { i.mutex.RLock() defer i.mutex.RUnlock() @@ -369,17 +367,17 @@ func (i *indexAliasImpl) DeleteInternal(key []byte) error { return i.indexes[0].DeleteInternal(key) } -func (i *indexAliasImpl) Advanced() (index.Index, store.KVStore, error) { +func (i *indexAliasImpl) Advanced() (index.Index, error) { i.mutex.RLock() defer i.mutex.RUnlock() if !i.open { - return nil, nil, ErrorIndexClosed + return nil, ErrorIndexClosed } err := i.isAliasToSingleIndex() if err != nil { - return nil, nil, err + return nil, err } return i.indexes[0].Advanced() diff --git a/index_alias_impl_test.go b/index_alias_impl_test.go index 0c07390a3..1b6ae55f4 100644 --- a/index_alias_impl_test.go +++ b/index_alias_impl_test.go @@ -21,12 +21,11 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" + index "github.com/blevesearch/bleve_index_api" ) func TestIndexAliasSingle(t *testing.T) { @@ -1259,7 +1258,7 @@ func (i *stubIndex) Batch(b *Batch) error { return i.err } -func (i *stubIndex) Document(id string) (*document.Document, error) { +func (i *stubIndex) Document(id string) (index.Document, error) { if i.documentResult != nil { return i.documentResult, nil } @@ -1334,8 +1333,8 @@ func (i *stubIndex) DeleteInternal(key []byte) error { return i.err } -func (i *stubIndex) Advanced() (index.Index, store.KVStore, error) { - return nil, nil, nil +func (i *stubIndex) Advanced() (index.Index, error) { + return nil, nil } func (i *stubIndex) NewBatch() *Batch { diff --git a/index_impl.go b/index_impl.go index 0520fe43b..879a36634 100644 --- a/index_impl.go +++ b/index_impl.go @@ -23,16 +23,15 @@ import ( "sync/atomic" "time" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/collector" - "github.com/blevesearch/bleve/search/facet" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/collector" + "github.com/blevesearch/bleve/v2/search/facet" + "github.com/blevesearch/bleve/v2/search/highlight" + index "github.com/blevesearch/bleve_index_api" ) type indexImpl struct { @@ -107,9 +106,6 @@ func newIndexUsing(path string, mapping mapping.IndexMapping, indexType string, } err = rv.i.Open() if err != nil { - if err == index.ErrorUnknownStorageType { - return nil, ErrorUnknownStorageType - } return nil, err } defer func(rv *indexImpl) { @@ -177,9 +173,6 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde } err = rv.i.Open() if err != nil { - if err == index.ErrorUnknownStorageType { - return nil, ErrorUnknownStorageType - } return nil, err } defer func(rv *indexImpl) { @@ -228,14 +221,9 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde return rv, err } -// Advanced returns implementation internals -// necessary ONLY for advanced usage. -func (i *indexImpl) Advanced() (index.Index, store.KVStore, error) { - s, err := i.i.Advanced() - if err != nil { - return nil, nil, err - } - return i.i, s, nil +// Advanced returns internal index implementation +func (i *indexImpl) Advanced() (index.Index, error) { + return i.i, nil } // Mapping returns the IndexMapping in use by this @@ -271,7 +259,7 @@ func (i *indexImpl) Index(id string, data interface{}) (err error) { // IndexAdvanced takes a document.Document object // skips the mapping and indexes it. func (i *indexImpl) IndexAdvanced(doc *document.Document) (err error) { - if doc.ID == "" { + if doc.ID() == "" { return ErrorEmptyID } @@ -323,7 +311,7 @@ func (i *indexImpl) Batch(b *Batch) error { // stored fields for a document in the index. These // stored fields are put back into a Document object // and returned. -func (i *indexImpl) Document(id string) (doc *document.Document, err error) { +func (i *indexImpl) Document(id string) (doc index.Document, err error) { i.mutex.RLock() defer i.mutex.RUnlock() @@ -617,28 +605,28 @@ func LoadAndHighlightFields(hit *search.DocumentMatch, req *SearchRequest, if len(req.Fields) > 0 { fieldsToLoad := deDuplicate(req.Fields) for _, f := range fieldsToLoad { - for _, docF := range doc.Fields { + doc.VisitFields(func(docF index.Field) { if f == "*" || docF.Name() == f { var value interface{} switch docF := docF.(type) { - case *document.TextField: - value = string(docF.Value()) - case *document.NumericField: + case index.TextField: + value = docF.Text() + case index.NumericField: num, err := docF.Number() if err == nil { value = num } - case *document.DateTimeField: + case index.DateTimeField: datetime, err := docF.DateTime() if err == nil { value = datetime.Format(time.RFC3339) } - case *document.BooleanField: + case index.BooleanField: boolean, err := docF.Boolean() if err == nil { value = boolean } - case *document.GeoPointField: + case index.GeoPointField: lon, err := docF.Lon() if err == nil { lat, err := docF.Lat() @@ -651,7 +639,7 @@ func LoadAndHighlightFields(hit *search.DocumentMatch, req *SearchRequest, hit.AddFieldValue(docF.Name(), value) } } - } + }) } } if highlighter != nil { diff --git a/index_meta.go b/index_meta.go index d814799a8..fe0ddebac 100644 --- a/index_meta.go +++ b/index_meta.go @@ -20,7 +20,7 @@ import ( "os" "path/filepath" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/index/upsidedown" ) const metaFilename = "index_meta.json" diff --git a/index_test.go b/index_test.go index 394e73083..6b1e72ddc 100644 --- a/index_test.go +++ b/index_test.go @@ -31,17 +31,17 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/analysis/analyzer/keyword" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/boltdb" - "github.com/blevesearch/bleve/index/store/null" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/query" - - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/analysis/analyzer/keyword" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/null" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/query" + + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown" ) type Fatalfable interface { @@ -67,7 +67,7 @@ func TestCrud(t *testing.T) { tmpIndexPath := createTmpIndexPath(t) defer cleanupTmpIndexPath(t, tmpIndexPath) - index, err := New(tmpIndexPath, NewIndexMapping()) + idx, err := New(tmpIndexPath, NewIndexMapping()) if err != nil { t.Fatal(err) } @@ -76,7 +76,7 @@ func TestCrud(t *testing.T) { "name": "marty", "desc": "gophercon india", } - err = index.Index("a", doca) + err = idx.Index("a", doca) if err != nil { t.Error(err) } @@ -85,12 +85,12 @@ func TestCrud(t *testing.T) { "name": "jasper", "desc": "clojure", } - err = index.Index("y", docy) + err = idx.Index("y", docy) if err != nil { t.Error(err) } - err = index.Delete("y") + err = idx.Delete("y") if err != nil { t.Error(err) } @@ -99,12 +99,12 @@ func TestCrud(t *testing.T) { "name": "rose", "desc": "googler", } - err = index.Index("x", docx) + err = idx.Index("x", docx) if err != nil { t.Error(err) } - err = index.SetInternal([]byte("status"), []byte("pending")) + err = idx.SetInternal([]byte("status"), []byte("pending")) if err != nil { t.Error(err) } @@ -113,7 +113,7 @@ func TestCrud(t *testing.T) { "name": "steve", "desc": "cbft master", } - batch := index.NewBatch() + batch := idx.NewBatch() err = batch.Index("b", docb) if err != nil { t.Error(err) @@ -121,18 +121,18 @@ func TestCrud(t *testing.T) { batch.Delete("x") batch.SetInternal([]byte("batchi"), []byte("batchv")) batch.DeleteInternal([]byte("status")) - err = index.Batch(batch) + err = idx.Batch(batch) if err != nil { t.Error(err) } - val, err := index.GetInternal([]byte("batchi")) + val, err := idx.GetInternal([]byte("batchi")) if err != nil { t.Error(err) } if string(val) != "batchv" { t.Errorf("expected 'batchv', got '%s'", val) } - val, err = index.GetInternal([]byte("status")) + val, err = idx.GetInternal([]byte("status")) if err != nil { t.Error(err) } @@ -140,19 +140,19 @@ func TestCrud(t *testing.T) { t.Errorf("expected nil, got '%s'", val) } - err = index.SetInternal([]byte("seqno"), []byte("7")) + err = idx.SetInternal([]byte("seqno"), []byte("7")) if err != nil { t.Error(err) } - err = index.SetInternal([]byte("status"), []byte("ready")) + err = idx.SetInternal([]byte("status"), []byte("ready")) if err != nil { t.Error(err) } - err = index.DeleteInternal([]byte("status")) + err = idx.DeleteInternal([]byte("status")) if err != nil { t.Error(err) } - val, err = index.GetInternal([]byte("status")) + val, err = idx.GetInternal([]byte("status")) if err != nil { t.Error(err) } @@ -160,7 +160,7 @@ func TestCrud(t *testing.T) { t.Errorf("expected nil, got '%s'", val) } - val, err = index.GetInternal([]byte("seqno")) + val, err = idx.GetInternal([]byte("seqno")) if err != nil { t.Error(err) } @@ -169,23 +169,23 @@ func TestCrud(t *testing.T) { } // close the index, open it again, and try some more things - err = index.Close() + err = idx.Close() if err != nil { t.Fatal(err) } - index, err = Open(tmpIndexPath) + idx, err = Open(tmpIndexPath) if err != nil { t.Fatal(err) } defer func() { - err := index.Close() + err := idx.Close() if err != nil { t.Fatal(err) } }() - count, err := index.DocCount() + count, err := idx.DocCount() if err != nil { t.Fatal(err) } @@ -193,24 +193,21 @@ func TestCrud(t *testing.T) { t.Errorf("expected doc count 2, got %d", count) } - doc, err := index.Document("a") + doc, err := idx.Document("a") if err != nil { t.Fatal(err) } - if doc == nil { - t.Errorf("expected doc not nil, got nil") - } foundNameField := false - for _, field := range doc.Fields { + doc.VisitFields(func(field index.Field) { if field.Name() == "name" && string(field.Value()) == "marty" { foundNameField = true } - } + }) if !foundNameField { t.Errorf("expected to find field named 'name' with value 'marty'") } - fields, err := index.Fields() + fields, err := idx.Fields() if err != nil { t.Fatal(err) } @@ -279,8 +276,8 @@ func TestIndexOpenMetaMissingOrCorrupt(t *testing.T) { } index, err = Open(tmpIndexPath) - if err != ErrorUnknownStorageType { - t.Fatalf("expected error unknown storage type, got %v", err) + if err == nil { + t.Fatalf("expected error for unknown storage type, got %v", err) } // now intentionally corrupt the metadata @@ -856,13 +853,13 @@ func TestDocumentFieldArrayPositions(t *testing.T) { tmpIndexPath := createTmpIndexPath(t) defer cleanupTmpIndexPath(t, tmpIndexPath) - index, err := New(tmpIndexPath, NewIndexMapping()) + idx, err := New(tmpIndexPath, NewIndexMapping()) if err != nil { t.Fatal(err) } // index a document with an array of strings - err = index.Index("k", struct { + err = idx.Index("k", struct { Messages []string }{ Messages: []string{ @@ -877,17 +874,17 @@ func TestDocumentFieldArrayPositions(t *testing.T) { } // load the document - doc, err := index.Document("k") + doc, err := idx.Document("k") if err != nil { t.Fatal(err) } - for _, f := range doc.Fields { + doc.VisitFields(func(f index.Field) { if reflect.DeepEqual(f.Value(), []byte("first")) { ap := f.ArrayPositions() if len(ap) < 1 { t.Errorf("expected an array position, got none") - continue + return } if ap[0] != 0 { t.Errorf("expected 'first' in array position 0, got %d", ap[0]) @@ -897,7 +894,7 @@ func TestDocumentFieldArrayPositions(t *testing.T) { ap := f.ArrayPositions() if len(ap) < 1 { t.Errorf("expected an array position, got none") - continue + return } if ap[0] != 1 { t.Errorf("expected 'second' in array position 1, got %d", ap[0]) @@ -907,7 +904,7 @@ func TestDocumentFieldArrayPositions(t *testing.T) { ap := f.ArrayPositions() if len(ap) < 1 { t.Errorf("expected an array position, got none") - continue + return } if ap[0] != 2 { t.Errorf("expected 'third' in array position 2, got %d", ap[0]) @@ -917,16 +914,16 @@ func TestDocumentFieldArrayPositions(t *testing.T) { ap := f.ArrayPositions() if len(ap) < 1 { t.Errorf("expected an array position, got none") - continue + return } if ap[0] != 3 { t.Errorf("expected 'last' in array position 3, got %d", ap[0]) } } - } + }) // now index a document in the same field with a single string - err = index.Index("k2", struct { + err = idx.Index("k2", struct { Messages string }{ Messages: "only", @@ -936,22 +933,22 @@ func TestDocumentFieldArrayPositions(t *testing.T) { } // load the document - doc, err = index.Document("k2") + doc, err = idx.Document("k2") if err != nil { t.Fatal(err) } - for _, f := range doc.Fields { + doc.VisitFields(func(f index.Field) { if reflect.DeepEqual(f.Value(), []byte("only")) { ap := f.ArrayPositions() if len(ap) != 0 { t.Errorf("expected no array positions, got %d", len(ap)) - continue + return } } - } + }) - err = index.Close() + err = idx.Close() if err != nil { t.Fatal(err) } @@ -1700,15 +1697,9 @@ func TestIndexAdvancedCountMatchSearch(t *testing.T) { for j := 0; j < 200; j++ { id := fmt.Sprintf("%d", (i*200)+j) - doc := &document.Document{ - ID: id, - Fields: []document.Field{ - document.NewTextField("body", []uint64{}, []byte("match")), - }, - CompositeFields: []*document.CompositeField{ - document.NewCompositeField("_all", true, []string{}, []string{}), - }, - } + doc := document.NewDocument(id) + doc.AddField(document.NewTextField("body", []uint64{}, []byte("match"))) + doc.AddField(document.NewCompositeField("_all", true, []string{}, []string{})) err := b.IndexAdvanced(doc) if err != nil { @@ -1838,7 +1829,7 @@ func TestBatchMerge(t *testing.T) { tmpIndexPath := createTmpIndexPath(t) defer cleanupTmpIndexPath(t, tmpIndexPath) - index, err := New(tmpIndexPath, NewIndexMapping()) + idx, err := New(tmpIndexPath, NewIndexMapping()) if err != nil { t.Fatal(err) } @@ -1848,7 +1839,7 @@ func TestBatchMerge(t *testing.T) { "nation": "india", } - batchA := index.NewBatch() + batchA := idx.NewBatch() err = batchA.Index("a", doca) if err != nil { t.Error(err) @@ -1860,7 +1851,7 @@ func TestBatchMerge(t *testing.T) { "desc": "gophercon MV", } - batchB := index.NewBatch() + batchB := idx.NewBatch() err = batchB.Index("b", docb) if err != nil { t.Error(err) @@ -1873,7 +1864,7 @@ func TestBatchMerge(t *testing.T) { "country": "usa", } - batchC := index.NewBatch() + batchC := idx.NewBatch() err = batchC.Index("c", docC) if err != nil { t.Error(err) @@ -1895,29 +1886,29 @@ func TestBatchMerge(t *testing.T) { t.Errorf("expected batch size 6, got %d", batchA.Size()) } - err = index.Batch(batchA) + err = idx.Batch(batchA) if err != nil { t.Fatal(err) } // close the index, open it again, and try some more things - err = index.Close() + err = idx.Close() if err != nil { t.Fatal(err) } - index, err = Open(tmpIndexPath) + idx, err = Open(tmpIndexPath) if err != nil { t.Fatal(err) } defer func() { - err := index.Close() + err := idx.Close() if err != nil { t.Fatal(err) } }() - count, err := index.DocCount() + count, err := idx.DocCount() if err != nil { t.Fatal(err) } @@ -1925,15 +1916,12 @@ func TestBatchMerge(t *testing.T) { t.Errorf("expected doc count 2, got %d", count) } - doc, err := index.Document("c") + doc, err := idx.Document("c") if err != nil { t.Fatal(err) } - if doc == nil { - t.Errorf("expected doc not nil, got nil") - } - val, err := index.GetInternal([]byte("batchkB")) + val, err := idx.GetInternal([]byte("batchkB")) if err != nil { t.Fatal(err) } @@ -1941,7 +1929,7 @@ func TestBatchMerge(t *testing.T) { t.Errorf("expected val: batchvBNew , got %s", val) } - val, err = index.GetInternal([]byte("batchkA")) + val, err = idx.GetInternal([]byte("batchkA")) if err != nil { t.Fatal(err) } @@ -1950,16 +1938,16 @@ func TestBatchMerge(t *testing.T) { } foundNameField := false - for _, field := range doc.Fields { + doc.VisitFields(func(field index.Field) { if field.Name() == "name" && string(field.Value()) == "blahblah" { foundNameField = true } - } + }) if !foundNameField { t.Errorf("expected to find field named 'name' with value 'blahblah'") } - fields, err := index.Fields() + fields, err := idx.Fields() if err != nil { t.Fatal(err) } diff --git a/mapping.go b/mapping.go index 76238dc15..54753073a 100644 --- a/mapping.go +++ b/mapping.go @@ -14,7 +14,7 @@ package bleve -import "github.com/blevesearch/bleve/mapping" +import "github.com/blevesearch/bleve/v2/mapping" // NewIndexMapping creates a new IndexMapping that will use all the default indexing rules func NewIndexMapping() *mapping.IndexMappingImpl { diff --git a/mapping/document.go b/mapping/document.go index dd42fab96..44911de77 100644 --- a/mapping/document.go +++ b/mapping/document.go @@ -21,7 +21,7 @@ import ( "reflect" "time" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/registry" ) // A DocumentMapping describes how a type of document diff --git a/mapping/field.go b/mapping/field.go index 278faa1a9..7ad1744d4 100644 --- a/mapping/field.go +++ b/mapping/field.go @@ -19,9 +19,11 @@ import ( "fmt" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/geo" + index "github.com/blevesearch/bleve_index_api" + + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/geo" ) // control the default behavior for dynamic fields (those not explicitly mapped) @@ -59,6 +61,12 @@ type FieldMapping struct { // DocValues, if true makes the index uninverting possible for this field // It is useful for faceting and sorting queries. DocValues bool `json:"docvalues,omitempty"` + + // SkipFreqNorm, if true, avoids the indexing of frequency and norm values + // of the tokens for this field. This option would be useful for saving + // the processing of freq/norm details when the default score based relevancy + // isn't needed. + SkipFreqNorm bool `json:"skip_freq_norm,omitempty"` } // NewTextFieldMapping returns a default field mapping for text @@ -150,19 +158,22 @@ func NewGeoPointFieldMapping() *FieldMapping { } // Options returns the indexing options for this field. -func (fm *FieldMapping) Options() document.IndexingOptions { - var rv document.IndexingOptions +func (fm *FieldMapping) Options() index.FieldIndexingOptions { + var rv index.FieldIndexingOptions if fm.Store { - rv |= document.StoreField + rv |= index.StoreField } if fm.Index { - rv |= document.IndexField + rv |= index.IndexField } if fm.IncludeTermVectors { - rv |= document.IncludeTermVectors + rv |= index.IncludeTermVectors } if fm.DocValues { - rv |= document.DocValues + rv |= index.DocValues + } + if fm.SkipFreqNorm { + rv |= index.SkipFreqNorm } return rv } @@ -330,6 +341,11 @@ func (fm *FieldMapping) UnmarshalJSON(data []byte) error { if err != nil { return err } + case "skip_freq_norm": + err := json.Unmarshal(v, &fm.SkipFreqNorm) + if err != nil { + return err + } default: invalidKeys = append(invalidKeys, k) } diff --git a/mapping/index.go b/mapping/index.go index 319ba949c..c34343385 100644 --- a/mapping/index.go +++ b/mapping/index.go @@ -17,12 +17,13 @@ package mapping import ( "encoding/json" "fmt" + index "github.com/blevesearch/bleve_index_api" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - "github.com/blevesearch/bleve/analysis/datetime/optional" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/registry" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + "github.com/blevesearch/bleve/v2/analysis/datetime/optional" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/registry" ) var MappingJSONStrict = false @@ -106,10 +107,10 @@ func (im *IndexMappingImpl) AddCustomTokenFilter(name string, config map[string] // use their metadata to fill configuration entries: // // import ( -// "github.com/blevesearch/bleve/analysis/analyzer/custom" -// "github.com/blevesearch/bleve/analysis/char/html" -// "github.com/blevesearch/bleve/analysis/token/lowercase" -// "github.com/blevesearch/bleve/analysis/tokenizer/unicode" +// "github.com/blevesearch/bleve/v2/analysis/analyzer/custom" +// "github.com/blevesearch/bleve/v2/analysis/char/html" +// "github.com/blevesearch/bleve/v2/analysis/token/lowercase" +// "github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode" // ) // // m := bleve.NewIndexMapping() @@ -327,7 +328,7 @@ func (im *IndexMappingImpl) MapDocument(doc *document.Document, data interface{} // see if the _all field was disabled allMapping := docMapping.documentMappingForPath("_all") if allMapping == nil || allMapping.Enabled { - field := document.NewCompositeFieldWithIndexingOptions("_all", true, []string{}, walkContext.excludedFromAll, document.IndexField|document.IncludeTermVectors) + field := document.NewCompositeFieldWithIndexingOptions("_all", true, []string{}, walkContext.excludedFromAll, index.IndexField|index.IncludeTermVectors) doc.AddField(field) } } diff --git a/mapping/mapping.go b/mapping/mapping.go index 4a4728112..bcf6749a4 100644 --- a/mapping/mapping.go +++ b/mapping/mapping.go @@ -18,8 +18,8 @@ import ( "io/ioutil" "log" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/document" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/document" ) // A Classifier is an interface describing any object which knows how to diff --git a/mapping/mapping_test.go b/mapping/mapping_test.go index 564fbb212..f20b9ede7 100644 --- a/mapping/mapping_test.go +++ b/mapping/mapping_test.go @@ -17,14 +17,15 @@ package mapping import ( "encoding/json" "fmt" + index "github.com/blevesearch/bleve_index_api" "reflect" "strconv" "testing" "time" - "github.com/blevesearch/bleve/analysis/tokenizer/exception" - "github.com/blevesearch/bleve/analysis/tokenizer/regexp" - "github.com/blevesearch/bleve/document" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/exception" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/regexp" + "github.com/blevesearch/bleve/v2/document" ) var mappingSource = []byte(`{ @@ -969,7 +970,7 @@ func TestMappingForGeo(t *testing.T) { for _, f := range doc.Fields { if f.Name() == "location" { foundGeo = true - geoF, ok := f.(*document.GeoPointField) + geoF, ok := f.(index.GeoPointField) if !ok { t.Errorf("expected a geopoint field!") } @@ -1136,7 +1137,7 @@ func TestMappingPointerToTimeBug1152(t *testing.T) { if len(doc.Fields) != 1 { t.Fatalf("expected 1 field, got: %d", len(doc.Fields)) } - if _, ok := doc.Fields[0].(*document.DateTimeField); !ok { + if _, ok := doc.Fields[0].(index.DateTimeField); !ok { t.Fatalf("expected field to be type *document.DateTimeField, got %T", doc.Fields[0]) } } diff --git a/query.go b/query.go index 523db5ec0..91d2d5f42 100644 --- a/query.go +++ b/query.go @@ -17,7 +17,7 @@ package bleve import ( "time" - "github.com/blevesearch/bleve/search/query" + "github.com/blevesearch/bleve/v2/search/query" ) // NewBoolFieldQuery creates a new Query for boolean fields diff --git a/registry/analyzer.go b/registry/analyzer.go index 340e349dc..6c0d73b31 100644 --- a/registry/analyzer.go +++ b/registry/analyzer.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterAnalyzer(name string, constructor AnalyzerConstructor) { diff --git a/registry/char_filter.go b/registry/char_filter.go index 4696713cc..aa400be68 100644 --- a/registry/char_filter.go +++ b/registry/char_filter.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterCharFilter(name string, constructor CharFilterConstructor) { diff --git a/registry/datetime_parser.go b/registry/datetime_parser.go index 2cd46e5ac..a2d8ac24a 100644 --- a/registry/datetime_parser.go +++ b/registry/datetime_parser.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterDateTimeParser(name string, constructor DateTimeParserConstructor) { diff --git a/registry/fragment_formatter.go b/registry/fragment_formatter.go index d0121d967..6699f53ba 100644 --- a/registry/fragment_formatter.go +++ b/registry/fragment_formatter.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search/highlight" ) func RegisterFragmentFormatter(name string, constructor FragmentFormatterConstructor) { diff --git a/registry/fragmenter.go b/registry/fragmenter.go index 18ab2ac07..cd1e32d28 100644 --- a/registry/fragmenter.go +++ b/registry/fragmenter.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search/highlight" ) func RegisterFragmenter(name string, constructor FragmenterConstructor) { diff --git a/registry/highlighter.go b/registry/highlighter.go index b84219ca1..8eb210fb3 100644 --- a/registry/highlighter.go +++ b/registry/highlighter.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search/highlight" ) func RegisterHighlighter(name string, constructor HighlighterConstructor) { diff --git a/registry/index_type.go b/registry/index_type.go index 4da07c82e..67938c4af 100644 --- a/registry/index_type.go +++ b/registry/index_type.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/index" + index "github.com/blevesearch/bleve_index_api" ) func RegisterIndexType(name string, constructor IndexTypeConstructor) { diff --git a/registry/registry.go b/registry/registry.go index a0ea69c8b..02125e64f 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -17,8 +17,8 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/search/highlight" ) var stores = make(KVStoreRegistry, 0) diff --git a/registry/store.go b/registry/store.go index 83187763d..02ebd888c 100644 --- a/registry/store.go +++ b/registry/store.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/index/store" + "github.com/blevesearch/upsidedown_store_api" ) func RegisterKVStore(name string, constructor KVStoreConstructor) { diff --git a/registry/token_filter.go b/registry/token_filter.go index e202e15fc..df39411ae 100644 --- a/registry/token_filter.go +++ b/registry/token_filter.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterTokenFilter(name string, constructor TokenFilterConstructor) { diff --git a/registry/token_maps.go b/registry/token_maps.go index 66ca08fdf..08c9956eb 100644 --- a/registry/token_maps.go +++ b/registry/token_maps.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterTokenMap(name string, constructor TokenMapConstructor) { diff --git a/registry/tokenizer.go b/registry/tokenizer.go index cb9af6438..eb954287c 100644 --- a/registry/tokenizer.go +++ b/registry/tokenizer.go @@ -17,7 +17,7 @@ package registry import ( "fmt" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func RegisterTokenizer(name string, constructor TokenizerConstructor) { diff --git a/search.go b/search.go index f67450779..a9d00b935 100644 --- a/search.go +++ b/search.go @@ -21,14 +21,14 @@ import ( "sort" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/datetime/optional" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/collector" - "github.com/blevesearch/bleve/search/query" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/datetime/optional" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/collector" + "github.com/blevesearch/bleve/v2/search/query" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeSearchResult int diff --git a/search/collector.go b/search/collector.go index df3ff9c5a..38e34fe7c 100644 --- a/search/collector.go +++ b/search/collector.go @@ -18,7 +18,7 @@ import ( "context" "time" - "github.com/blevesearch/bleve/index" + index "github.com/blevesearch/bleve_index_api" ) type Collector interface { diff --git a/search/collector/bench_test.go b/search/collector/bench_test.go index e6a786f41..8e7d27de9 100644 --- a/search/collector/bench_test.go +++ b/search/collector/bench_test.go @@ -20,8 +20,8 @@ import ( "strconv" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) type createCollector func() search.Collector diff --git a/search/collector/heap.go b/search/collector/heap.go index 05502d5df..9503f0060 100644 --- a/search/collector/heap.go +++ b/search/collector/heap.go @@ -17,7 +17,7 @@ package collector import ( "container/heap" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) type collectStoreHeap struct { diff --git a/search/collector/list.go b/search/collector/list.go index f01d205c9..20d4c9d01 100644 --- a/search/collector/list.go +++ b/search/collector/list.go @@ -17,7 +17,7 @@ package collector import ( "container/list" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) type collectStoreList struct { diff --git a/search/collector/search_test.go b/search/collector/search_test.go index 233bc9711..0d7cd09b0 100644 --- a/search/collector/search_test.go +++ b/search/collector/search_test.go @@ -17,9 +17,8 @@ package collector import ( "reflect" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" + index "github.com/blevesearch/bleve_index_api" ) type stubSearcher struct { @@ -118,11 +117,11 @@ func (sr *stubReader) FieldDictPrefix(field string, termPrefix []byte) (index.Fi return nil, nil } -func (sr *stubReader) Document(id string) (*document.Document, error) { +func (sr *stubReader) Document(id string) (index.Document, error) { return nil, nil } -func (sr *stubReader) DocumentVisitFieldTerms(id index.IndexInternalID, fields []string, visitor index.DocumentFieldTermVisitor) error { +func (sr *stubReader) DocumentVisitFieldTerms(id index.IndexInternalID, fields []string, visitor index.DocValueVisitor) error { return nil } @@ -171,6 +170,6 @@ type DocValueReader struct { fields []string } -func (dvr *DocValueReader) VisitDocValues(id index.IndexInternalID, visitor index.DocumentFieldTermVisitor) error { +func (dvr *DocValueReader) VisitDocValues(id index.IndexInternalID, visitor index.DocValueVisitor) error { return dvr.i.DocumentVisitFieldTerms(id, dvr.fields, visitor) } diff --git a/search/collector/slice.go b/search/collector/slice.go index 85fe73c40..b38d9abc4 100644 --- a/search/collector/slice.go +++ b/search/collector/slice.go @@ -14,7 +14,7 @@ package collector -import "github.com/blevesearch/bleve/search" +import "github.com/blevesearch/bleve/v2/search" type collectStoreSlice struct { slice search.DocumentMatchCollection diff --git a/search/collector/topn.go b/search/collector/topn.go index 8d4afb63a..937904f4b 100644 --- a/search/collector/topn.go +++ b/search/collector/topn.go @@ -20,9 +20,9 @@ import ( "strconv" "time" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeTopNCollector int @@ -68,7 +68,7 @@ type TopNCollector struct { cachedDesc []bool lowestMatchOutsideResults *search.DocumentMatch - updateFieldVisitor index.DocumentFieldTermVisitor + updateFieldVisitor index.DocValueVisitor dvReader index.DocValueReader searchAfter *search.DocumentMatch } diff --git a/search/collector/topn_test.go b/search/collector/topn_test.go index 2e668bd9e..26fcd52cd 100644 --- a/search/collector/topn_test.go +++ b/search/collector/topn_test.go @@ -19,8 +19,8 @@ import ( "context" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestTop10Scores(t *testing.T) { diff --git a/search/explanation.go b/search/explanation.go index 3b81737b5..b1ac29aa8 100644 --- a/search/explanation.go +++ b/search/explanation.go @@ -19,7 +19,7 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeExplanation int diff --git a/search/facet/facet_builder_datetime.go b/search/facet/facet_builder_datetime.go index c45442e4d..a316ee4da 100644 --- a/search/facet/facet_builder_datetime.go +++ b/search/facet/facet_builder_datetime.go @@ -19,9 +19,9 @@ import ( "sort" "time" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDateTimeFacetBuilder int diff --git a/search/facet/facet_builder_numeric.go b/search/facet/facet_builder_numeric.go index c1692b549..6d0c6c9d1 100644 --- a/search/facet/facet_builder_numeric.go +++ b/search/facet/facet_builder_numeric.go @@ -18,9 +18,9 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeNumericFacetBuilder int diff --git a/search/facet/facet_builder_numeric_test.go b/search/facet/facet_builder_numeric_test.go index 41824092d..391395c49 100644 --- a/search/facet/facet_builder_numeric_test.go +++ b/search/facet/facet_builder_numeric_test.go @@ -18,7 +18,7 @@ import ( "strconv" "testing" - "github.com/blevesearch/bleve/numeric" + "github.com/blevesearch/bleve/v2/numeric" ) var pcodedvalues []numeric.PrefixCoded diff --git a/search/facet/facet_builder_terms.go b/search/facet/facet_builder_terms.go index 5b5901e01..1b378db7c 100644 --- a/search/facet/facet_builder_terms.go +++ b/search/facet/facet_builder_terms.go @@ -18,8 +18,8 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeTermsFacetBuilder int diff --git a/search/facets_builder.go b/search/facets_builder.go index 7fc0bedf3..fb0dfcbe0 100644 --- a/search/facets_builder.go +++ b/search/facets_builder.go @@ -18,8 +18,8 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeFacetsBuilder int diff --git a/search/highlight/format/ansi/ansi.go b/search/highlight/format/ansi/ansi.go index 2500409c0..b9171ae2e 100644 --- a/search/highlight/format/ansi/ansi.go +++ b/search/highlight/format/ansi/ansi.go @@ -15,8 +15,8 @@ package ansi import ( - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight" ) const Name = "ansi" diff --git a/search/highlight/format/html/html.go b/search/highlight/format/html/html.go index 5bf16ca92..a0658d9c7 100644 --- a/search/highlight/format/html/html.go +++ b/search/highlight/format/html/html.go @@ -17,8 +17,8 @@ package html import ( "html" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight" ) const Name = "html" diff --git a/search/highlight/format/html/html_test.go b/search/highlight/format/html/html_test.go index 0652d477f..774ab06bc 100644 --- a/search/highlight/format/html/html_test.go +++ b/search/highlight/format/html/html_test.go @@ -17,8 +17,8 @@ package html import ( "testing" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight" ) func TestHTMLFragmentFormatter(t *testing.T) { diff --git a/search/highlight/fragmenter/simple/simple.go b/search/highlight/fragmenter/simple/simple.go index 9c63f7fb6..348dc1ce3 100644 --- a/search/highlight/fragmenter/simple/simple.go +++ b/search/highlight/fragmenter/simple/simple.go @@ -17,8 +17,8 @@ package simple import ( "unicode/utf8" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight" ) const Name = "simple" diff --git a/search/highlight/fragmenter/simple/simple_test.go b/search/highlight/fragmenter/simple/simple_test.go index d02e83bd1..dcf4bf830 100644 --- a/search/highlight/fragmenter/simple/simple_test.go +++ b/search/highlight/fragmenter/simple/simple_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search/highlight" ) func TestSimpleFragmenter(t *testing.T) { diff --git a/search/highlight/highlighter.go b/search/highlight/highlighter.go index 8077985d4..3dd9ce053 100644 --- a/search/highlight/highlighter.go +++ b/search/highlight/highlighter.go @@ -15,8 +15,8 @@ package highlight import ( - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" + index "github.com/blevesearch/bleve_index_api" ) type Fragment struct { @@ -59,6 +59,6 @@ type Highlighter interface { Separator() string SetSeparator(string) - BestFragmentInField(*search.DocumentMatch, *document.Document, string) string - BestFragmentsInField(*search.DocumentMatch, *document.Document, string, int) []string + BestFragmentInField(*search.DocumentMatch, index.Document, string) string + BestFragmentsInField(*search.DocumentMatch, index.Document, string, int) []string } diff --git a/search/highlight/highlighter/ansi/ansi.go b/search/highlight/highlighter/ansi/ansi.go index 1d9f2efc2..39d950b4e 100644 --- a/search/highlight/highlighter/ansi/ansi.go +++ b/search/highlight/highlighter/ansi/ansi.go @@ -17,11 +17,11 @@ package ansi import ( "fmt" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight" - ansiFormatter "github.com/blevesearch/bleve/search/highlight/format/ansi" - simpleFragmenter "github.com/blevesearch/bleve/search/highlight/fragmenter/simple" - simpleHighlighter "github.com/blevesearch/bleve/search/highlight/highlighter/simple" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight" + ansiFormatter "github.com/blevesearch/bleve/v2/search/highlight/format/ansi" + simpleFragmenter "github.com/blevesearch/bleve/v2/search/highlight/fragmenter/simple" + simpleHighlighter "github.com/blevesearch/bleve/v2/search/highlight/highlighter/simple" ) const Name = "ansi" diff --git a/search/highlight/highlighter/html/html.go b/search/highlight/highlighter/html/html.go index 928589c47..ceb686dce 100644 --- a/search/highlight/highlighter/html/html.go +++ b/search/highlight/highlighter/html/html.go @@ -17,11 +17,11 @@ package html import ( "fmt" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search/highlight" - htmlFormatter "github.com/blevesearch/bleve/search/highlight/format/html" - simpleFragmenter "github.com/blevesearch/bleve/search/highlight/fragmenter/simple" - simpleHighlighter "github.com/blevesearch/bleve/search/highlight/highlighter/simple" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search/highlight" + htmlFormatter "github.com/blevesearch/bleve/v2/search/highlight/format/html" + simpleFragmenter "github.com/blevesearch/bleve/v2/search/highlight/fragmenter/simple" + simpleHighlighter "github.com/blevesearch/bleve/v2/search/highlight/highlighter/simple" ) const Name = "html" diff --git a/search/highlight/highlighter/simple/fragment_scorer_simple.go b/search/highlight/highlighter/simple/fragment_scorer_simple.go index 3ec4c3d28..786e33cb3 100644 --- a/search/highlight/highlighter/simple/fragment_scorer_simple.go +++ b/search/highlight/highlighter/simple/fragment_scorer_simple.go @@ -15,8 +15,8 @@ package simple import ( - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight" ) // FragmentScorer will score fragments by how many diff --git a/search/highlight/highlighter/simple/fragment_scorer_simple_test.go b/search/highlight/highlighter/simple/fragment_scorer_simple_test.go index 92ced62db..116c7bda0 100644 --- a/search/highlight/highlighter/simple/fragment_scorer_simple_test.go +++ b/search/highlight/highlighter/simple/fragment_scorer_simple_test.go @@ -17,8 +17,8 @@ package simple import ( "testing" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight" ) func TestSimpleFragmentScorer(t *testing.T) { diff --git a/search/highlight/highlighter/simple/highlighter_simple.go b/search/highlight/highlighter/simple/highlighter_simple.go index 4849516ba..19949687d 100644 --- a/search/highlight/highlighter/simple/highlighter_simple.go +++ b/search/highlight/highlighter/simple/highlighter_simple.go @@ -17,11 +17,11 @@ package simple import ( "container/heap" "fmt" + index "github.com/blevesearch/bleve_index_api" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight" ) const Name = "simple" @@ -65,7 +65,7 @@ func (s *Highlighter) SetSeparator(sep string) { s.sep = sep } -func (s *Highlighter) BestFragmentInField(dm *search.DocumentMatch, doc *document.Document, field string) string { +func (s *Highlighter) BestFragmentInField(dm *search.DocumentMatch, doc index.Document, field string) string { fragments := s.BestFragmentsInField(dm, doc, field, 1) if len(fragments) > 0 { return fragments[0] @@ -73,7 +73,7 @@ func (s *Highlighter) BestFragmentInField(dm *search.DocumentMatch, doc *documen return "" } -func (s *Highlighter) BestFragmentsInField(dm *search.DocumentMatch, doc *document.Document, field string, num int) []string { +func (s *Highlighter) BestFragmentsInField(dm *search.DocumentMatch, doc index.Document, field string, num int) []string { tlm := dm.Locations[field] orderedTermLocations := highlight.OrderTermLocations(tlm) scorer := NewFragmentScorer(tlm) @@ -81,9 +81,9 @@ func (s *Highlighter) BestFragmentsInField(dm *search.DocumentMatch, doc *docume // score the fragments and put them into a priority queue ordered by score fq := make(FragmentQueue, 0) heap.Init(&fq) - for _, f := range doc.Fields { + doc.VisitFields(func(f index.Field) { if f.Name() == field { - _, ok := f.(*document.TextField) + _, ok := f.(index.TextField) if ok { termLocationsSameArrayPosition := make(highlight.TermLocations, 0) for _, otl := range orderedTermLocations { @@ -101,7 +101,7 @@ func (s *Highlighter) BestFragmentsInField(dm *search.DocumentMatch, doc *docume } } } - } + }) // now find the N best non-overlapping fragments var bestFragments []*highlight.Fragment diff --git a/search/highlight/highlighter/simple/highlighter_simple_test.go b/search/highlight/highlighter/simple/highlighter_simple_test.go index 4b51ce924..e93166a4d 100644 --- a/search/highlight/highlighter/simple/highlighter_simple_test.go +++ b/search/highlight/highlighter/simple/highlighter_simple_test.go @@ -18,10 +18,10 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight/format/ansi" - sfrag "github.com/blevesearch/bleve/search/highlight/fragmenter/simple" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight/format/ansi" + sfrag "github.com/blevesearch/bleve/v2/search/highlight/fragmenter/simple" ) const ( diff --git a/search/highlight/term_locations.go b/search/highlight/term_locations.go index 6d2cb133e..6bf385c05 100644 --- a/search/highlight/term_locations.go +++ b/search/highlight/term_locations.go @@ -18,7 +18,7 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) type TermLocation struct { diff --git a/search/highlight/term_locations_test.go b/search/highlight/term_locations_test.go index c45376eae..6daa5ccff 100644 --- a/search/highlight/term_locations_test.go +++ b/search/highlight/term_locations_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) func TestTermLocationOverlaps(t *testing.T) { diff --git a/search/query/bool_field.go b/search/query/bool_field.go index b7b5a3d36..5b3bd2fb9 100644 --- a/search/query/bool_field.go +++ b/search/query/bool_field.go @@ -15,10 +15,10 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type BoolFieldQuery struct { diff --git a/search/query/boolean.go b/search/query/boolean.go index 3cfa1d99f..0f49c5fbe 100644 --- a/search/query/boolean.go +++ b/search/query/boolean.go @@ -18,10 +18,10 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type BooleanQuery struct { diff --git a/search/query/conjunction.go b/search/query/conjunction.go index 1a7ed1bc0..15a3b8eb0 100644 --- a/search/query/conjunction.go +++ b/search/query/conjunction.go @@ -17,10 +17,10 @@ package query import ( "encoding/json" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type ConjunctionQuery struct { diff --git a/search/query/date_range.go b/search/query/date_range.go index 3ac0322f5..a92788301 100644 --- a/search/query/date_range.go +++ b/search/query/date_range.go @@ -20,13 +20,13 @@ import ( "math" "time" - "github.com/blevesearch/bleve/analysis/datetime/optional" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/registry" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + "github.com/blevesearch/bleve/v2/analysis/datetime/optional" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/registry" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) // QueryDateTimeParser controls the default query date time parser diff --git a/search/query/disjunction.go b/search/query/disjunction.go index a1fc1439a..cb8c52e32 100644 --- a/search/query/disjunction.go +++ b/search/query/disjunction.go @@ -18,10 +18,10 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type DisjunctionQuery struct { diff --git a/search/query/docid.go b/search/query/docid.go index 3b865f93a..2dfbaadce 100644 --- a/search/query/docid.go +++ b/search/query/docid.go @@ -15,10 +15,10 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type DocIDQuery struct { diff --git a/search/query/fuzzy.go b/search/query/fuzzy.go index f18982d40..4cd3deef8 100644 --- a/search/query/fuzzy.go +++ b/search/query/fuzzy.go @@ -15,10 +15,10 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type FuzzyQuery struct { diff --git a/search/query/geo_boundingbox.go b/search/query/geo_boundingbox.go index de6be4a58..04c0b8f91 100644 --- a/search/query/geo_boundingbox.go +++ b/search/query/geo_boundingbox.go @@ -18,11 +18,11 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type GeoBoundingBoxQuery struct { diff --git a/search/query/geo_boundingpolygon.go b/search/query/geo_boundingpolygon.go index 41c7f7f3a..fadfde7b9 100644 --- a/search/query/geo_boundingpolygon.go +++ b/search/query/geo_boundingpolygon.go @@ -18,11 +18,11 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type GeoBoundingPolygonQuery struct { diff --git a/search/query/geo_distance.go b/search/query/geo_distance.go index ef3aa88c9..ab487942c 100644 --- a/search/query/geo_distance.go +++ b/search/query/geo_distance.go @@ -18,11 +18,11 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type GeoDistanceQuery struct { diff --git a/search/query/match.go b/search/query/match.go index 36c9ee4a4..dae596233 100644 --- a/search/query/match.go +++ b/search/query/match.go @@ -18,9 +18,9 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) type MatchQuery struct { @@ -37,9 +37,9 @@ type MatchQueryOperator int const ( // Document must satisfy AT LEAST ONE of term searches. - MatchQueryOperatorOr = 0 + MatchQueryOperatorOr = MatchQueryOperator(0) // Document must satisfy ALL of term searches. - MatchQueryOperatorAnd = 1 + MatchQueryOperatorAnd = MatchQueryOperator(1) ) func (o MatchQueryOperator) MarshalJSON() ([]byte, error) { diff --git a/search/query/match_all.go b/search/query/match_all.go index 7fbe1f99d..9ada4f87a 100644 --- a/search/query/match_all.go +++ b/search/query/match_all.go @@ -17,10 +17,10 @@ package query import ( "encoding/json" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type MatchAllQuery struct { diff --git a/search/query/match_none.go b/search/query/match_none.go index dc2ea780c..e50478dc4 100644 --- a/search/query/match_none.go +++ b/search/query/match_none.go @@ -17,10 +17,10 @@ package query import ( "encoding/json" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type MatchNoneQuery struct { diff --git a/search/query/match_phrase.go b/search/query/match_phrase.go index 51be35526..cc9bc5800 100644 --- a/search/query/match_phrase.go +++ b/search/query/match_phrase.go @@ -17,10 +17,10 @@ package query import ( "fmt" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/analysis" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) type MatchPhraseQuery struct { diff --git a/search/query/match_phrase_test.go b/search/query/match_phrase_test.go index a4afbc2d6..a04f29ada 100644 --- a/search/query/match_phrase_test.go +++ b/search/query/match_phrase_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/analysis" + "github.com/blevesearch/bleve/v2/analysis" ) func TestTokenStreamToPhrase(t *testing.T) { diff --git a/search/query/multi_phrase.go b/search/query/multi_phrase.go index 8a7c9b6ad..1005b1c27 100644 --- a/search/query/multi_phrase.go +++ b/search/query/multi_phrase.go @@ -18,10 +18,10 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type MultiPhraseQuery struct { diff --git a/search/query/numeric_range.go b/search/query/numeric_range.go index ea3f06886..e6bcda90f 100644 --- a/search/query/numeric_range.go +++ b/search/query/numeric_range.go @@ -17,10 +17,10 @@ package query import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type NumericRangeQuery struct { diff --git a/search/query/phrase.go b/search/query/phrase.go index dff1a02d4..0a71a0a9b 100644 --- a/search/query/phrase.go +++ b/search/query/phrase.go @@ -18,10 +18,10 @@ import ( "encoding/json" "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type PhraseQuery struct { diff --git a/search/query/prefix.go b/search/query/prefix.go index 4f5be2b26..cf5159991 100644 --- a/search/query/prefix.go +++ b/search/query/prefix.go @@ -15,10 +15,10 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type PrefixQuery struct { diff --git a/search/query/query.go b/search/query/query.go index 18aca228d..f012d5ac7 100644 --- a/search/query/query.go +++ b/search/query/query.go @@ -20,9 +20,9 @@ import ( "io/ioutil" "log" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) var logger = log.New(ioutil.Discard, "bleve mapping ", log.LstdFlags) diff --git a/search/query/query_string.go b/search/query/query_string.go index ecafe6bc0..52eb4a71b 100644 --- a/search/query/query_string.go +++ b/search/query/query_string.go @@ -15,9 +15,9 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) type QueryStringQuery struct { diff --git a/search/query/query_string_parser_test.go b/search/query/query_string_parser_test.go index fa0f3ae08..25816db57 100644 --- a/search/query/query_string_parser_test.go +++ b/search/query/query_string_parser_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2/mapping" ) func TestQuerySyntaxParserValid(t *testing.T) { diff --git a/search/query/query_test.go b/search/query/query_test.go index 42d05f336..f8a9227df 100644 --- a/search/query/query_test.go +++ b/search/query/query_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2/mapping" ) var minNum = 5.1 @@ -83,6 +83,16 @@ func TestParseQuery(t *testing.T) { return q }(), }, + { + input: []byte(`{"match":"beer","field":"desc","operator":"and"}`), + output: func() Query { + operator := MatchQueryOperatorAnd + q := NewMatchQuery("beer") + q.SetOperator(operator) + q.SetField("desc") + return q + }(), + }, { input: []byte(`{"match":"beer","field":"desc","operator":"or"}`), output: func() Query { @@ -92,6 +102,16 @@ func TestParseQuery(t *testing.T) { return q }(), }, + { + input: []byte(`{"match":"beer","field":"desc","operator":"or"}`), + output: func() Query { + operator := MatchQueryOperatorOr + q := NewMatchQuery("beer") + q.SetOperator(operator) + q.SetField("desc") + return q + }(), + }, { input: []byte(`{"match":"beer","field":"desc","operator":"does not exist"}`), output: nil, diff --git a/search/query/regexp.go b/search/query/regexp.go index 0c87a6f92..72150277c 100644 --- a/search/query/regexp.go +++ b/search/query/regexp.go @@ -17,10 +17,10 @@ package query import ( "strings" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type RegexpQuery struct { diff --git a/search/query/term.go b/search/query/term.go index 2eeb5a37a..12362eeb4 100644 --- a/search/query/term.go +++ b/search/query/term.go @@ -15,10 +15,10 @@ package query import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type TermQuery struct { diff --git a/search/query/term_range.go b/search/query/term_range.go index 8f8ca8444..7db4db89b 100644 --- a/search/query/term_range.go +++ b/search/query/term_range.go @@ -17,10 +17,10 @@ package query import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) type TermRangeQuery struct { diff --git a/search/query/wildcard.go b/search/query/wildcard.go index 747dfe76f..94d4f0224 100644 --- a/search/query/wildcard.go +++ b/search/query/wildcard.go @@ -17,10 +17,10 @@ package query import ( "strings" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/searcher" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/searcher" ) var wildcardRegexpReplacer = strings.NewReplacer( diff --git a/search/scorer/scorer_conjunction.go b/search/scorer/scorer_conjunction.go index 48cdf3ae9..f3c81a78c 100644 --- a/search/scorer/scorer_conjunction.go +++ b/search/scorer/scorer_conjunction.go @@ -17,8 +17,8 @@ package scorer import ( "reflect" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeConjunctionQueryScorer int diff --git a/search/scorer/scorer_constant.go b/search/scorer/scorer_constant.go index dc10fdaa4..30ae3ffe5 100644 --- a/search/scorer/scorer_constant.go +++ b/search/scorer/scorer_constant.go @@ -18,9 +18,9 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeConstantScorer int diff --git a/search/scorer/scorer_constant_test.go b/search/scorer/scorer_constant_test.go index 37574a329..7257b89ce 100644 --- a/search/scorer/scorer_constant_test.go +++ b/search/scorer/scorer_constant_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestConstantScorer(t *testing.T) { diff --git a/search/scorer/scorer_disjunction.go b/search/scorer/scorer_disjunction.go index 7a955e168..054e76fd4 100644 --- a/search/scorer/scorer_disjunction.go +++ b/search/scorer/scorer_disjunction.go @@ -18,8 +18,8 @@ import ( "fmt" "reflect" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDisjunctionQueryScorer int diff --git a/search/scorer/scorer_term.go b/search/scorer/scorer_term.go index 718de2ea5..c09e11092 100644 --- a/search/scorer/scorer_term.go +++ b/search/scorer/scorer_term.go @@ -19,9 +19,9 @@ import ( "math" "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeTermQueryScorer int diff --git a/search/scorer/scorer_term_test.go b/search/scorer/scorer_term_test.go index b491ee00c..69cc1a9a7 100644 --- a/search/scorer/scorer_term_test.go +++ b/search/scorer/scorer_term_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestTermScorer(t *testing.T) { diff --git a/search/search.go b/search/search.go index 8ed23de45..61a9e9a16 100644 --- a/search/search.go +++ b/search/search.go @@ -19,8 +19,8 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDocumentMatch int diff --git a/search/searcher/base_test.go b/search/searcher/base_test.go index a4644b6b3..3d0323f5c 100644 --- a/search/searcher/base_test.go +++ b/search/searcher/base_test.go @@ -18,13 +18,13 @@ import ( "math" "regexp" - "github.com/blevesearch/bleve/analysis" - regexpTokenizer "github.com/blevesearch/bleve/analysis/tokenizer/regexp" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" + "github.com/blevesearch/bleve/v2/analysis" + regexpTokenizer "github.com/blevesearch/bleve/v2/analysis/tokenizer/regexp" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown" ) var twoDocIndex index.Index @@ -82,7 +82,7 @@ var testAnalyzer = &analysis.Analyzer{ } // sets up some mock data used in many tests in this package -var twoDocIndexDescIndexingOptions = document.DefaultTextIndexingOptions | document.IncludeTermVectors +var twoDocIndexDescIndexingOptions = document.DefaultTextIndexingOptions | index.IncludeTermVectors var twoDocIndexDocs = []*document.Document{ // must have 4/4 beer diff --git a/search/searcher/ordered_searchers_list.go b/search/searcher/ordered_searchers_list.go index 536c593cd..f3e646e9d 100644 --- a/search/searcher/ordered_searchers_list.go +++ b/search/searcher/ordered_searchers_list.go @@ -15,7 +15,7 @@ package searcher import ( - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) type OrderedSearcherList []search.Searcher diff --git a/search/searcher/search_boolean.go b/search/searcher/search_boolean.go index 7f0bfa424..2dae3d9d2 100644 --- a/search/searcher/search_boolean.go +++ b/search/searcher/search_boolean.go @@ -18,10 +18,10 @@ import ( "math" "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeBooleanSearcher int diff --git a/search/searcher/search_boolean_test.go b/search/searcher/search_boolean_test.go index 1e2c769e7..07c1f7a74 100644 --- a/search/searcher/search_boolean_test.go +++ b/search/searcher/search_boolean_test.go @@ -17,8 +17,8 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestBooleanSearch(t *testing.T) { diff --git a/search/searcher/search_conjunction.go b/search/searcher/search_conjunction.go index ac737bccd..2d99165fb 100644 --- a/search/searcher/search_conjunction.go +++ b/search/searcher/search_conjunction.go @@ -19,10 +19,10 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeConjunctionSearcher int diff --git a/search/searcher/search_conjunction_test.go b/search/searcher/search_conjunction_test.go index 4a71381be..8f6b06d3a 100644 --- a/search/searcher/search_conjunction_test.go +++ b/search/searcher/search_conjunction_test.go @@ -20,9 +20,9 @@ import ( "strings" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/search" ) func TestConjunctionSearch(t *testing.T) { diff --git a/search/searcher/search_disjunction.go b/search/searcher/search_disjunction.go index f47da27c4..8d3423bea 100644 --- a/search/searcher/search_disjunction.go +++ b/search/searcher/search_disjunction.go @@ -16,8 +16,8 @@ package searcher import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) // DisjunctionMaxClauseCount is a compile time setting that applications can diff --git a/search/searcher/search_disjunction_heap.go b/search/searcher/search_disjunction_heap.go index 7f0a5a00e..d153c4755 100644 --- a/search/searcher/search_disjunction_heap.go +++ b/search/searcher/search_disjunction_heap.go @@ -20,10 +20,10 @@ import ( "math" "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDisjunctionHeapSearcher int diff --git a/search/searcher/search_disjunction_slice.go b/search/searcher/search_disjunction_slice.go index dc566ade5..d3af72802 100644 --- a/search/searcher/search_disjunction_slice.go +++ b/search/searcher/search_disjunction_slice.go @@ -19,10 +19,10 @@ import ( "reflect" "sort" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDisjunctionSliceSearcher int diff --git a/search/searcher/search_disjunction_test.go b/search/searcher/search_disjunction_test.go index effe13847..7edc48080 100644 --- a/search/searcher/search_disjunction_test.go +++ b/search/searcher/search_disjunction_test.go @@ -17,8 +17,8 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestDisjunctionSearch(t *testing.T) { diff --git a/search/searcher/search_docid.go b/search/searcher/search_docid.go index 3b258a580..19e8a32ef 100644 --- a/search/searcher/search_docid.go +++ b/search/searcher/search_docid.go @@ -17,10 +17,10 @@ package searcher import ( "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeDocIDSearcher int diff --git a/search/searcher/search_docid_test.go b/search/searcher/search_docid_test.go index ff68d6d46..61698c7e6 100644 --- a/search/searcher/search_docid_test.go +++ b/search/searcher/search_docid_test.go @@ -17,11 +17,11 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/search" ) func testDocIDSearcher(t *testing.T, indexed, searched, wanted []string) { @@ -40,12 +40,9 @@ func testDocIDSearcher(t *testing.T, indexed, searched, wanted []string) { t.Fatal(err) } for _, id := range indexed { - err = i.Update(&document.Document{ - ID: id, - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc := document.NewDocument(id) + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } diff --git a/search/searcher/search_filter.go b/search/searcher/search_filter.go index 7c95fb41c..3adba5dc9 100644 --- a/search/searcher/search_filter.go +++ b/search/searcher/search_filter.go @@ -17,9 +17,9 @@ package searcher import ( "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeFilteringSearcher int diff --git a/search/searcher/search_fuzzy.go b/search/searcher/search_fuzzy.go index aca8a7d9f..fb4aafdab 100644 --- a/search/searcher/search_fuzzy.go +++ b/search/searcher/search_fuzzy.go @@ -17,8 +17,8 @@ package searcher import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) var MaxFuzziness = 2 diff --git a/search/searcher/search_fuzzy_test.go b/search/searcher/search_fuzzy_test.go index 4a87f139a..5c3ae2ef5 100644 --- a/search/searcher/search_fuzzy_test.go +++ b/search/searcher/search_fuzzy_test.go @@ -17,8 +17,8 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestFuzzySearch(t *testing.T) { diff --git a/search/searcher/search_geoboundingbox.go b/search/searcher/search_geoboundingbox.go index 76157f01a..c442fd2a0 100644 --- a/search/searcher/search_geoboundingbox.go +++ b/search/searcher/search_geoboundingbox.go @@ -15,11 +15,11 @@ package searcher import ( - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" ) type filterFunc func(key []byte) bool diff --git a/search/searcher/search_geoboundingbox_test.go b/search/searcher/search_geoboundingbox_test.go index 6b3072868..449e08515 100644 --- a/search/searcher/search_geoboundingbox_test.go +++ b/search/searcher/search_geoboundingbox_test.go @@ -18,13 +18,13 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" ) func TestGeoBoundingBox(t *testing.T) { @@ -107,93 +107,63 @@ func setupGeo(t *testing.T) index.Index { if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "a", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 0.0015, 0.0015), - }, - }) + doc := document.NewDocument("a") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 0.0015, 0.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "b", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 1.0015, 1.0015), - }, - }) + doc = document.NewDocument("b") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 1.0015, 1.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "c", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 2.0015, 2.0015), - }, - }) + doc = document.NewDocument("c") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 2.0015, 2.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "d", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 3.0015, 3.0015), - }, - }) + doc = document.NewDocument("d") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 3.0015, 3.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "e", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 4.0015, 4.0015), - }, - }) + doc = document.NewDocument("e") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 4.0015, 4.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "f", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 5.0015, 5.0015), - }, - }) + doc = document.NewDocument("f") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 5.0015, 5.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "g", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 6.0015, 6.0015), - }, - }) + doc = document.NewDocument("g") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 6.0015, 6.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "h", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 7.0015, 7.0015), - }, - }) + doc = document.NewDocument("h") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 7.0015, 7.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "i", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 8.0015, 8.0015), - }, - }) + doc = document.NewDocument("i") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 8.0015, 8.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "j", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 9.0015, 9.0015), - }, - }) + doc = document.NewDocument("j") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 9.0015, 9.0015)) + err = i.Update(doc) if err != nil { t.Fatal(err) } diff --git a/search/searcher/search_geopointdistance.go b/search/searcher/search_geopointdistance.go index b6f293244..c3b12915d 100644 --- a/search/searcher/search_geopointdistance.go +++ b/search/searcher/search_geopointdistance.go @@ -15,10 +15,10 @@ package searcher import ( - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" ) func NewGeoPointDistanceSearcher(indexReader index.IndexReader, centerLon, diff --git a/search/searcher/search_geopointdistance_test.go b/search/searcher/search_geopointdistance_test.go index 8b7f1c968..0bf63664b 100644 --- a/search/searcher/search_geopointdistance_test.go +++ b/search/searcher/search_geopointdistance_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestGeoPointDistanceSearcher(t *testing.T) { diff --git a/search/searcher/search_geopolygon.go b/search/searcher/search_geopolygon.go index 5f16aa8d2..ee3e53964 100644 --- a/search/searcher/search_geopolygon.go +++ b/search/searcher/search_geopolygon.go @@ -16,10 +16,10 @@ package searcher import ( "fmt" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" "math" ) diff --git a/search/searcher/search_geopolygon_test.go b/search/searcher/search_geopolygon_test.go index 901ef62fe..c80333250 100644 --- a/search/searcher/search_geopolygon_test.go +++ b/search/searcher/search_geopolygon_test.go @@ -18,12 +18,12 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/geo" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/search" ) func TestSimpleGeoPolygons(t *testing.T) { @@ -183,132 +183,93 @@ func setupGeoPolygonPoints(t *testing.T) index.Index { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "k", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -80.86469327, 35.2782), - }, - }) + doc := document.NewDocument("k") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -80.86469327, 35.2782)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "l", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -80.8713, 35.28138), - }, - }) + doc = document.NewDocument("l") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -80.8713, 35.28138)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "m", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -84.25, 33.153), - }, - }) + doc = document.NewDocument("m") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -84.25, 33.153)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "n", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -89.992, 35.063), - }, - }) + doc = document.NewDocument("n") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -89.992, 35.063)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "o", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -71.648, 42.437), - }, - }) + doc = document.NewDocument("o") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -71.648, 42.437)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "p", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -80.016, 40.314), - }, - }) + doc = document.NewDocument("p") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -80.016, 40.314)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "q", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, -111.919, 33.494), - }, - }) + doc = document.NewDocument("q") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, -111.919, 33.494)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "r", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 1.5, 1.1), - }, - }) + doc = document.NewDocument("r") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 1.5, 1.1)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "s", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 2, 1.5), - }, - }) + doc = document.NewDocument("s") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 2, 1.5)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "t", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 2.0, 1.9), - }, - }) + doc = document.NewDocument("t") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 2.0, 1.9)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "u", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 2.0, 1.0), - }, - }) + doc = document.NewDocument("u") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 2.0, 1.0)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "amoeba", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 77.60490, 12.97467), - }, - }) + doc = document.NewDocument("amoeba") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 77.60490, 12.97467)) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "communiti", - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, 77.608237, 12.97237), - }, - }) + doc = document.NewDocument("communiti") + doc.AddField(document.NewGeoPointField("loc", []uint64{}, 77.608237, 12.97237)) + err = i.Update(doc) if err != nil { t.Fatal(err) } @@ -393,12 +354,9 @@ func setupComplexGeoPolygonPoints(t *testing.T, points []geoPoint) index.Index { t.Fatal(err) } for _, point := range points { - err = i.Update(&document.Document{ - ID: point.title, - Fields: []document.Field{ - document.NewGeoPointField("loc", []uint64{}, point.lon, point.lat), - }, - }) + doc := document.NewDocument(point.title) + doc.AddField(document.NewGeoPointField("loc", []uint64{}, point.lon, point.lat)) + err = i.Update(doc) if err != nil { t.Fatal(err) } diff --git a/search/searcher/search_match_all.go b/search/searcher/search_match_all.go index bb6640122..68f76e97d 100644 --- a/search/searcher/search_match_all.go +++ b/search/searcher/search_match_all.go @@ -17,10 +17,10 @@ package searcher import ( "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeMatchAllSearcher int diff --git a/search/searcher/search_match_all_test.go b/search/searcher/search_match_all_test.go index 0a3e7e3fe..fd6565b7f 100644 --- a/search/searcher/search_match_all_test.go +++ b/search/searcher/search_match_all_test.go @@ -17,8 +17,8 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestMatchAllSearch(t *testing.T) { diff --git a/search/searcher/search_match_none.go b/search/searcher/search_match_none.go index a345e17f7..6765371a5 100644 --- a/search/searcher/search_match_none.go +++ b/search/searcher/search_match_none.go @@ -17,9 +17,9 @@ package searcher import ( "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeMatchNoneSearcher int diff --git a/search/searcher/search_match_none_test.go b/search/searcher/search_match_none_test.go index 7563074ca..c3a370d83 100644 --- a/search/searcher/search_match_none_test.go +++ b/search/searcher/search_match_none_test.go @@ -17,7 +17,7 @@ package searcher import ( "testing" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) func TestMatchNoneSearch(t *testing.T) { diff --git a/search/searcher/search_multi_term.go b/search/searcher/search_multi_term.go index 70a2fa38c..98bc3daa9 100644 --- a/search/searcher/search_multi_term.go +++ b/search/searcher/search_multi_term.go @@ -16,8 +16,8 @@ package searcher import ( "fmt" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func NewMultiTermSearcher(indexReader index.IndexReader, terms []string, diff --git a/search/searcher/search_numeric_range.go b/search/searcher/search_numeric_range.go index 48d6226e1..b02acf26a 100644 --- a/search/searcher/search_numeric_range.go +++ b/search/searcher/search_numeric_range.go @@ -19,9 +19,9 @@ import ( "math" "sort" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/numeric" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/numeric" + "github.com/blevesearch/bleve/v2/search" ) func NewNumericRangeSearcher(indexReader index.IndexReader, @@ -106,24 +106,6 @@ func NewNumericRangeSearcher(indexReader index.IndexReader, func filterCandidateTerms(indexReader index.IndexReader, terms [][]byte, field string) (rv [][]byte, err error) { - if ir, ok := indexReader.(index.IndexReaderOnly); ok { - fieldDict, err := ir.FieldDictOnly(field, terms, false) - if err != nil { - return nil, err - } - // enumerate the terms (no need to check them again) - tfd, err := fieldDict.Next() - for err == nil && tfd != nil { - rv = append(rv, []byte(tfd.Term)) - tfd, err = fieldDict.Next() - } - if cerr := fieldDict.Close(); cerr != nil && err == nil { - err = cerr - } - - return rv, err - } - fieldDict, err := indexReader.FieldDictRange(field, terms[0], terms[len(terms)-1]) if err != nil { return nil, err diff --git a/search/searcher/search_numeric_range_test.go b/search/searcher/search_numeric_range_test.go index b19e1b24a..83611cd9e 100644 --- a/search/searcher/search_numeric_range_test.go +++ b/search/searcher/search_numeric_range_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/numeric" + "github.com/blevesearch/bleve/v2/numeric" ) func TestSplitRange(t *testing.T) { diff --git a/search/searcher/search_phrase.go b/search/searcher/search_phrase.go index 51b7e5bd8..91777074f 100644 --- a/search/searcher/search_phrase.go +++ b/search/searcher/search_phrase.go @@ -19,9 +19,9 @@ import ( "math" "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizePhraseSearcher int diff --git a/search/searcher/search_phrase_test.go b/search/searcher/search_phrase_test.go index 04af20f08..546673c8c 100644 --- a/search/searcher/search_phrase_test.go +++ b/search/searcher/search_phrase_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestPhraseSearch(t *testing.T) { diff --git a/search/searcher/search_regexp.go b/search/searcher/search_regexp.go index 11a44f159..1a85914a1 100644 --- a/search/searcher/search_regexp.go +++ b/search/searcher/search_regexp.go @@ -17,10 +17,21 @@ package searcher import ( "regexp" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) +// The Regexp interface defines the subset of the regexp.Regexp API +// methods that are used by bleve indexes, allowing callers to pass in +// alternate implementations. +type Regexp interface { + FindStringIndex(s string) (loc []int) + + LiteralPrefix() (prefix string, complete bool) + + String() string +} + // NewRegexpStringSearcher is similar to NewRegexpSearcher, but // additionally optimizes for index readers that handle regexp's. func NewRegexpStringSearcher(indexReader index.IndexReader, pattern string, @@ -66,7 +77,7 @@ func NewRegexpStringSearcher(indexReader index.IndexReader, pattern string, // matching the entire term. The provided regexp SHOULD NOT start with ^ // or end with $ as this can intefere with the implementation. Separately, // matches will be checked to ensure they match the entire term. -func NewRegexpSearcher(indexReader index.IndexReader, pattern index.Regexp, +func NewRegexpSearcher(indexReader index.IndexReader, pattern Regexp, field string, boost float64, options search.SearcherOptions) ( search.Searcher, error) { var candidateTerms []string @@ -89,7 +100,7 @@ func NewRegexpSearcher(indexReader index.IndexReader, pattern index.Regexp, } func findRegexpCandidateTerms(indexReader index.IndexReader, - pattern index.Regexp, field, prefixTerm string) (rv []string, err error) { + pattern Regexp, field, prefixTerm string) (rv []string, err error) { rv = make([]string, 0) var fieldDict index.FieldDict if len(prefixTerm) > 0 { diff --git a/search/searcher/search_regexp_test.go b/search/searcher/search_regexp_test.go index feb23579c..347403463 100644 --- a/search/searcher/search_regexp_test.go +++ b/search/searcher/search_regexp_test.go @@ -22,8 +22,8 @@ import ( "regexp" "testing" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func TestRegexpSearchUpsideDown(t *testing.T) { diff --git a/search/searcher/search_term.go b/search/searcher/search_term.go index e07d25333..f2f1b0e79 100644 --- a/search/searcher/search_term.go +++ b/search/searcher/search_term.go @@ -17,10 +17,10 @@ package searcher import ( "reflect" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/scorer" - "github.com/blevesearch/bleve/size" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/scorer" + "github.com/blevesearch/bleve/v2/size" ) var reflectStaticSizeTermSearcher int diff --git a/search/searcher/search_term_prefix.go b/search/searcher/search_term_prefix.go index 2a8f22cff..35f96efce 100644 --- a/search/searcher/search_term_prefix.go +++ b/search/searcher/search_term_prefix.go @@ -15,8 +15,8 @@ package searcher import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func NewTermPrefixSearcher(indexReader index.IndexReader, prefix string, diff --git a/search/searcher/search_term_range.go b/search/searcher/search_term_range.go index 90be1e11a..c8e3b3d25 100644 --- a/search/searcher/search_term_range.go +++ b/search/searcher/search_term_range.go @@ -15,8 +15,8 @@ package searcher import ( - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/search" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/search" ) func NewTermRangeSearcher(indexReader index.IndexReader, diff --git a/search/searcher/search_term_range_test.go b/search/searcher/search_term_range_test.go index 22cf065d2..126e03ee4 100644 --- a/search/searcher/search_term_range_test.go +++ b/search/searcher/search_term_range_test.go @@ -15,14 +15,14 @@ package searcher import ( - "github.com/blevesearch/bleve/index/scorch" + "github.com/blevesearch/bleve/v2/index/scorch" "io/ioutil" "os" "reflect" "sort" "testing" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/search" ) func TestTermRangeSearch(t *testing.T) { diff --git a/search/searcher/search_term_test.go b/search/searcher/search_term_test.go index ad562b090..a87d2b24d 100644 --- a/search/searcher/search_term_test.go +++ b/search/searcher/search_term_test.go @@ -18,11 +18,11 @@ import ( "math" "testing" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index" - "github.com/blevesearch/bleve/index/store/gtreap" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2/document" + index "github.com/blevesearch/bleve_index_api" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/gtreap" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/search" ) func TestTermSearcher(t *testing.T) { @@ -46,93 +46,63 @@ func TestTermSearcher(t *testing.T) { if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "a", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc := document.NewDocument("a") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "b", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("b") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "c", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("c") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "d", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("d") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "e", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("e") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "f", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("f") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "g", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("g") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "h", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("h") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "i", - Fields: []document.Field{ - document.NewTextField("desc", []uint64{}, []byte("beer")), - }, - }) + doc = document.NewDocument("i") + doc.AddField(document.NewTextField("desc", []uint64{}, []byte("beer"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } - err = i.Update(&document.Document{ - ID: "j", - Fields: []document.Field{ - document.NewTextField("title", []uint64{}, []byte("cat")), - }, - }) + doc = document.NewDocument("j") + doc.AddField(document.NewTextField("title", []uint64{}, []byte("cat"))) + err = i.Update(doc) if err != nil { t.Fatal(err) } diff --git a/search/sort.go b/search/sort.go index dca422ebd..496db47fc 100644 --- a/search/sort.go +++ b/search/sort.go @@ -22,8 +22,8 @@ import ( "sort" "strings" - "github.com/blevesearch/bleve/geo" - "github.com/blevesearch/bleve/numeric" + "github.com/blevesearch/bleve/v2/geo" + "github.com/blevesearch/bleve/v2/numeric" ) var HighTerm = strings.Repeat(string([]byte{0xff}), 10) diff --git a/search_test.go b/search_test.go index 98623e1a2..bfdbd8786 100644 --- a/search_test.go +++ b/search_test.go @@ -17,30 +17,31 @@ package bleve import ( "encoding/json" "fmt" + index "github.com/blevesearch/bleve_index_api" "reflect" "strconv" "strings" "testing" "time" - "github.com/blevesearch/bleve/analysis" - "github.com/blevesearch/bleve/analysis/analyzer/custom" - "github.com/blevesearch/bleve/analysis/analyzer/keyword" - "github.com/blevesearch/bleve/analysis/analyzer/standard" - regexp_char_filter "github.com/blevesearch/bleve/analysis/char/regexp" - "github.com/blevesearch/bleve/analysis/token/length" - "github.com/blevesearch/bleve/analysis/token/lowercase" - "github.com/blevesearch/bleve/analysis/token/shingle" - "github.com/blevesearch/bleve/analysis/tokenizer/single" - "github.com/blevesearch/bleve/analysis/tokenizer/whitespace" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" - "github.com/blevesearch/bleve/search/highlight/highlighter/ansi" - "github.com/blevesearch/bleve/search/highlight/highlighter/html" - "github.com/blevesearch/bleve/search/query" + "github.com/blevesearch/bleve/v2/analysis" + "github.com/blevesearch/bleve/v2/analysis/analyzer/custom" + "github.com/blevesearch/bleve/v2/analysis/analyzer/keyword" + "github.com/blevesearch/bleve/v2/analysis/analyzer/standard" + regexp_char_filter "github.com/blevesearch/bleve/v2/analysis/char/regexp" + "github.com/blevesearch/bleve/v2/analysis/token/length" + "github.com/blevesearch/bleve/v2/analysis/token/lowercase" + "github.com/blevesearch/bleve/v2/analysis/token/shingle" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/single" + "github.com/blevesearch/bleve/v2/analysis/tokenizer/whitespace" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" + "github.com/blevesearch/bleve/v2/search/highlight/highlighter/ansi" + "github.com/blevesearch/bleve/v2/search/highlight/highlighter/html" + "github.com/blevesearch/bleve/v2/search/query" ) func TestSearchResultString(t *testing.T) { @@ -478,7 +479,7 @@ func TestNestedBooleanSearchers(t *testing.T) { doc := document.NewDocument(strconv.Itoa(i)) doc.Fields = []document.Field{ document.NewTextFieldCustom("hostname", []uint64{}, []byte(hostname), - document.IndexField, + index.IndexField, &analysis.Analyzer{ Tokenizer: single.NewSingleTokenTokenizer(), TokenFilters: []analysis.TokenFilter{ @@ -489,12 +490,12 @@ func TestNestedBooleanSearchers(t *testing.T) { } for k, v := range metadata { doc.AddField(document.NewTextFieldWithIndexingOptions( - fmt.Sprintf("metadata.%s", k), []uint64{}, []byte(v), document.IndexField)) + fmt.Sprintf("metadata.%s", k), []uint64{}, []byte(v), index.IndexField)) } doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { @@ -645,7 +646,7 @@ func TestNestedBooleanMustNotSearcherUpsidedown(t *testing.T) { doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { @@ -781,7 +782,7 @@ func TestMultipleNestedBooleanMustNotSearchersOnScorch(t *testing.T) { doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { @@ -826,7 +827,7 @@ func TestMultipleNestedBooleanMustNotSearchersOnScorch(t *testing.T) { doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { @@ -850,7 +851,7 @@ func TestMultipleNestedBooleanMustNotSearchersOnScorch(t *testing.T) { doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { @@ -1054,7 +1055,7 @@ func TestDisjunctionQueryIncorrectMin(t *testing.T) { doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"text"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { t.Fatal(err) diff --git a/test/integration.go b/test/integration.go index 74031a2ce..c45286b05 100644 --- a/test/integration.go +++ b/test/integration.go @@ -15,7 +15,7 @@ package test import ( - "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/v2" ) type SearchTest struct { diff --git a/test/integration_test.go b/test/integration_test.go index cdd50f03a..5cc4d185f 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -26,11 +26,11 @@ import ( "regexp" "testing" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/mapping" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/mapping" // allow choosing alternate kvstores - _ "github.com/blevesearch/bleve/config" + _ "github.com/blevesearch/bleve/v2/config" ) var dataset = flag.String("dataset", "", "only test datasets matching this regex") diff --git a/test/tests/sort/searches.json b/test/tests/sort/searches.json index 6d34b25c0..7f7e8e208 100644 --- a/test/tests/sort/searches.json +++ b/test/tests/sort/searches.json @@ -102,14 +102,14 @@ } }, { - "comment": "sort by age, ascending", + "comment": "sort by age, ascending, _id, ascending", "search": { "from": 0, "size": 10, "query": { "match_all":{} }, - "sort": ["age"] + "sort": ["age", "_id"] }, "result": { "total_hits": 6, @@ -136,14 +136,14 @@ } }, { - "comment": "sort by age, descending", + "comment": "sort by age, descending, _id, ascending", "search": { "from": 0, "size": 10, "query": { "match_all":{} }, - "sort": ["-age"] + "sort": ["-age", "_id"] }, "result": { "total_hits": 6, diff --git a/test/versus_score_test.go b/test/versus_score_test.go index b0cb4afe1..7a7b87520 100644 --- a/test/versus_score_test.go +++ b/test/versus_score_test.go @@ -16,17 +16,18 @@ package test import ( "fmt" + index "github.com/blevesearch/bleve_index_api" "io/ioutil" "os" "strconv" "testing" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/document" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/document" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) func TestDisjunctionSearchScoreIndexWithCompositeFields(t *testing.T) { @@ -99,7 +100,7 @@ func disjunctionQueryiOnIndexWithCompositeFields(indexName string, doc.CompositeFields = []*document.CompositeField{ document.NewCompositeFieldWithIndexingOptions( "_all", true, []string{"field1"}, []string{}, - document.IndexField|document.IncludeTermVectors), + index.IndexField|index.IncludeTermVectors), } if err = batch.IndexAdvanced(doc); err != nil { t.Error(err) diff --git a/test/versus_test.go b/test/versus_test.go index 4257a9849..3812d4c45 100644 --- a/test/versus_test.go +++ b/test/versus_test.go @@ -27,12 +27,12 @@ import ( "testing" "text/template" - "github.com/blevesearch/bleve" - "github.com/blevesearch/bleve/index/scorch" - "github.com/blevesearch/bleve/index/store/boltdb" - "github.com/blevesearch/bleve/index/upsidedown" - "github.com/blevesearch/bleve/mapping" - "github.com/blevesearch/bleve/search" + "github.com/blevesearch/bleve/v2" + "github.com/blevesearch/bleve/v2/index/scorch" + "github.com/blevesearch/bleve/v2/index/upsidedown/store/boltdb" + "github.com/blevesearch/bleve/v2/index/upsidedown" + "github.com/blevesearch/bleve/v2/mapping" + "github.com/blevesearch/bleve/v2/search" ) // Tests scorch indexer versus upsidedown/bolt indexer against various