diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6de7736..ceb9f91 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,6 +11,6 @@ jobs: steps: - uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.47.1 + version: v1.61.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d1b3920..f01dca9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,16 +8,16 @@ jobs: test: strategy: matrix: - go-version: [1.17.x, 1.18.x] + go-version: [1.23.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test run: | go version diff --git a/.golangci.yml b/.golangci.yml index 3006e0f..a5e4ea3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,17 +9,17 @@ linters-settings: min-occurrences: 2 gocritic: enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style + - diagnostic + - experimental + - opinionated + - performance + - style disabled-checks: - - dupImport # https://github.com/go-critic/go-critic/issues/845 - - ifElseChain - - octalLiteral - - whyNoLint - - wrapperFunc + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - ifElseChain + - octalLiteral + - whyNoLint + - wrapperFunc gocyclo: min-complexity: 20 # increased from 15 to get us going, but not make things worse lll: @@ -27,51 +27,51 @@ linters-settings: misspell: locale: US nolintlint: - allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) allow-unused: false # report any unused nolint directives require-explanation: false # don't require an explanation for nolint directives require-specific: false # don't require nolint directives to be specific about which linter is being skipped + gosec: + excludes: + - G115 # integer overflow conversion + revive: + rules: + - name: unused-parameter + disabled: true linters: # please, do not use `enable-all`: it's deprecated and will be removed soon. # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint disable-all: true enable: - - bodyclose - - deadcode - - depguard - - dogsled - - dupl - - errcheck - - funlen - - gochecknoinits - - goconst - - gocritic - - gocyclo - - gofmt - - goimports - - revive - - goprintffuncname - - gosec - - gosimple - - govet - - ineffassign - - lll - - misspell - - nakedret - - nolintlint - - rowserrcheck - - exportloopref - - staticcheck - - structcheck - - stylecheck - - typecheck - - unconvert - - unparam - - unused - - varcheck - - whitespace - + - bodyclose + - dogsled + - dupl + - errcheck + - funlen + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - revive + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - lll + - misspell + - nakedret + - nolintlint + - rowserrcheck + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - whitespace # don't enable: # - asciicheck # - gochecknoglobals @@ -88,118 +88,119 @@ linters: issues: # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - - path: _test\.go - linters: - - lll - - funlen - - goconst - - gocyclo - - dupl - - gochecknoinits - - path: cmd/bluge/cmd - linters: - - gochecknoinits - - path: sizes.go - linters: - - gochecknoinits - - # we don't need secure random in test - - path: _test\.go - linters: - - gosec - text: G404 - - # allow lock test to invoke itself - - path: index/lock/lock_test.go - linters: - - gosec - text: G204 - - # cannot safely refactor until optimization tests are in place again - - path: index/optimize.go - linters: - - funlen - - # FIXME refactor persister - - path: index/persister.go - linters: - - funlen - text: persisterLoop - - # many analysis tests have non-english words - # lots of false alarms on duplicate code - - path: ^analysis/.*_test\.go$ - linters: - - misspell - - dupl - - # used in some analyzers - - path: analysis/lang/ - linters: - - stylecheck - text: ST1018 - - # many language specific analyzers have - # non-english words or non-word substrings - # lots of false alrams on duplicate code - - path: ^analysis/lang/.*\.go$ - linters: - - misspell - - dupl - - gocyclo - - funlen - - # allow init here - - path: analysis/lang/in/scripts.go - linters: - - gochecknoinits - - # and allow init here - - path: analysis/freq.go - linters: - - gochecknoinits - - - path: search/searcher/search_fuzzy.go - linters: - - gochecknoinits - - # has long regexp - - path: analysis/tokenizer/web.go - linters: - - lll - - # needs rewrite to avoid fallthrough - # skipping funlen,gocyclo since ported - - path: analysis/char/asciifolding.go - linters: - - gocritic - - funlen - - gocyclo - - # many hard-coded values - - path: numeric/geo/sloppy.go - linters: - - gochecknoinits - - # allow init methods for our size calculations - - path: size.go - linters: - - gochecknoinits - - # https://github.com/go-critic/go-critic/issues/926 - - linters: - - gocritic - text: "unnecessaryDefer:" - - # until we make final decision on config - - linters: - - gocritic - text: "config is heavy" + - path: _test\.go + linters: + - lll + - funlen + - goconst + - gocyclo + - dupl + - gochecknoinits + - path: cmd/bluge/cmd + linters: + - gochecknoinits + - path: sizes.go + linters: + - gochecknoinits + + # we don't need secure random in test + - path: _test\.go + linters: + - gosec + text: G404 + + # allow lock test to invoke itself + - path: index/lock/lock_test.go + linters: + - gosec + text: G204 + + # cannot safely refactor until optimization tests are in place again + - path: index/optimize.go + linters: + - funlen + + # FIXME refactor persister + - path: index/persister.go + linters: + - funlen + text: persisterLoop + + # many analysis tests have non-english words + # lots of false alarms on duplicate code + - path: ^analysis/.*_test\.go$ + linters: + - misspell + - dupl + + # used in some analyzers + - path: analysis/lang/ + linters: + - stylecheck + text: ST1018 + + # many language specific analyzers have + # non-english words or non-word substrings + # lots of false alrams on duplicate code + - path: ^analysis/lang/.*\.go$ + linters: + - misspell + - dupl + - gocyclo + - funlen + + # allow init here + - path: analysis/lang/in/scripts.go + linters: + - gochecknoinits + + # and allow init here + - path: analysis/freq.go + linters: + - gochecknoinits + + - path: search/searcher/search_fuzzy.go + linters: + - gochecknoinits + + # has long regexp + - path: analysis/tokenizer/web.go + linters: + - lll + + # needs rewrite to avoid fallthrough + # skipping funlen,gocyclo since ported + - path: analysis/char/asciifolding.go + linters: + - gocritic + - funlen + - gocyclo + + # many hard-coded values + - path: numeric/geo/sloppy.go + linters: + - gochecknoinits + + # allow init methods for our size calculations + - path: size.go + linters: + - gochecknoinits + + # https://github.com/go-critic/go-critic/issues/926 + - linters: + - gocritic + text: "unnecessaryDefer:" + + # until we make final decision on config + - linters: + - gocritic + text: "config is heavy" + + exclude-dirs: + - test/testdata_etc + - internal/cache + - internal/renameio + - internal/robustio run: - skip-dirs: - - test/testdata_etc - - internal/cache - - internal/renameio - - internal/robustio timeout: 5m diff --git a/analysis/token/camelcase.go b/analysis/token/camelcase.go index de82074..a37429c 100644 --- a/analysis/token/camelcase.go +++ b/analysis/token/camelcase.go @@ -23,16 +23,16 @@ import ( // CamelCaseFilter splits a given token into a set of tokens where each resulting token // falls into one the following classes: -// 1) Upper case followed by lower case letters. -// Terminated by a number, an upper case letter, and a non alpha-numeric symbol. -// 2) Upper case followed by upper case letters. -// Terminated by a number, an upper case followed by a lower case letter, and a non alpha-numeric symbol. -// 3) Lower case followed by lower case letters. -// Terminated by a number, an upper case letter, and a non alpha-numeric symbol. -// 4) Number followed by numbers. -// Terminated by a letter, and a non alpha-numeric symbol. -// 5) Non alpha-numeric symbol followed by non alpha-numeric symbols. -// Terminated by a number, and a letter. +// 1. Upper case followed by lower case letters. +// Terminated by a number, an upper case letter, and a non alpha-numeric symbol. +// 2. Upper case followed by upper case letters. +// Terminated by a number, an upper case followed by a lower case letter, and a non alpha-numeric symbol. +// 3. Lower case followed by lower case letters. +// Terminated by a number, an upper case letter, and a non alpha-numeric symbol. +// 4. Number followed by numbers. +// Terminated by a letter, and a non alpha-numeric symbol. +// 5. Non alpha-numeric symbol followed by non alpha-numeric symbols. +// Terminated by a number, and a letter. // // It does a one-time sequential pass over an input token, from left to right. // The scan is greedy and generates the longest substring that fits into one of the classes. diff --git a/analysis/token/length.go b/analysis/token/length.go index 143164d..12d4180 100644 --- a/analysis/token/length.go +++ b/analysis/token/length.go @@ -25,10 +25,10 @@ type LengthFilter struct { max int } -func NewLengthFilter(min, max int) *LengthFilter { +func NewLengthFilter(minLen, maxLen int) *LengthFilter { return &LengthFilter{ - min: min, - max: max, + min: minLen, + max: maxLen, } } diff --git a/analysis/token/shingle.go b/analysis/token/shingle.go index 062ae20..6b46b7b 100644 --- a/analysis/token/shingle.go +++ b/analysis/token/shingle.go @@ -28,10 +28,10 @@ type ShingleFilter struct { fill string } -func NewShingleFilter(min, max int, outputOriginal bool, sep, fill string) *ShingleFilter { +func NewShingleFilter(minVal, maxVal int, outputOriginal bool, sep, fill string) *ShingleFilter { return &ShingleFilter{ - min: min, - max: max, + min: minVal, + max: maxVal, outputOriginal: outputOriginal, tokenSeparator: sep, fill: fill, diff --git a/doc.go b/doc.go index b52f176..2c2487c 100644 --- a/doc.go +++ b/doc.go @@ -34,37 +34,36 @@ Example Opening New Index, Indexing Data Example Getting Index Reader, Searching Data - reader, err := writer.Reader() - if err != nil { - log.Fatalf("error getting index reader: %v", err) - } - defer reader.Close() + reader, err := writer.Reader() + if err != nil { + log.Fatalf("error getting index reader: %v", err) + } + defer reader.Close() - query := bluge.NewMatchQuery("bluge").SetField("name") - request := bluge.NewTopNSearch(10, query). - WithStandardAggregations() - documentMatchIterator, err := reader.Search(context.Background(), request) - if err != nil { - log.Fatalf("error executing search: %v", err) - } - match, err := documentMatchIterator.Next() - for err == nil && match != nil { + query := bluge.NewMatchQuery("bluge").SetField("name") + request := bluge.NewTopNSearch(10, query). + WithStandardAggregations() + documentMatchIterator, err := reader.Search(context.Background(), request) + if err != nil { + log.Fatalf("error executing search: %v", err) + } + match, err := documentMatchIterator.Next() + for err == nil && match != nil { - // load the identifier for this match - err = match.VisitStoredFields(func(field string, value []byte) bool { - if field == "_id" { - fmt.Printf("match: %s\n", string(value)) + // load the identifier for this match + err = match.VisitStoredFields(func(field string, value []byte) bool { + if field == "_id" { + fmt.Printf("match: %s\n", string(value)) + } + return true + }) + if err != nil { + log.Fatalf("error loading stored fields: %v", err) } - return true - }) + match, err = documentMatchIterator.Next() + } if err != nil { - log.Fatalf("error loading stored fields: %v", err) + log.Fatalf("error iterator document matches: %v", err) } - match, err = documentMatchIterator.Next() - } - if err != nil { - log.Fatalf("error iterator document matches: %v", err) - } - */ package bluge diff --git a/go.mod b/go.mod index 8d54e8a..e40dc2a 100644 --- a/go.mod +++ b/go.mod @@ -1,26 +1,36 @@ module github.com/blugelabs/bluge -go 1.16 +go 1.23 + +toolchain go1.23.1 require ( - github.com/RoaringBitmap/roaring v0.9.4 - github.com/axiomhq/hyperloglog v0.0.0-20191112132149-a4c4c47bc57f - github.com/bits-and-blooms/bitset v1.2.0 + github.com/RoaringBitmap/roaring v1.9.4 + github.com/axiomhq/hyperloglog v0.2.0 + github.com/bits-and-blooms/bitset v1.14.3 github.com/blevesearch/go-porterstemmer v1.0.3 github.com/blevesearch/mmap-go v1.0.4 - github.com/blevesearch/segment v0.9.0 + github.com/blevesearch/segment v0.9.1 github.com/blevesearch/snowballstem v0.9.0 - github.com/blevesearch/vellum v1.0.7 + github.com/blevesearch/vellum v1.0.10 github.com/blugelabs/bluge_segment_api v0.2.0 github.com/blugelabs/ice v1.0.0 github.com/caio/go-tdigest v3.1.0+incompatible + github.com/spf13/cobra v1.8.1 + golang.org/x/sys v0.26.0 + golang.org/x/text v0.19.0 +) + +require ( + github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 // indirect - github.com/spf13/cobra v0.0.5 - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a - golang.org/x/text v0.3.0 + github.com/mschoch/smat v0.2.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect gonum.org/v1/gonum v0.7.0 // indirect ) -replace github.com/blugelabs/ice => github.com/zinclabs/ice v1.1.1 +replace github.com/blugelabs/ice => github.com/SkyAPM/ice v0.0.0-20241108011032-c3d8eea75118 replace github.com/blugelabs/bluge_segment_api => github.com/zinclabs/bluge_segment_api v1.0.0 diff --git a/go.sum b/go.sum index 34fdbf9..ceedcd1 100644 --- a/go.sum +++ b/go.sum @@ -1,87 +1,67 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/RoaringBitmap/roaring v0.9.4 h1:ckvZSX5gwCRaJYBNe7syNawCU5oruY9gQmjXlp4riwo= github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= +github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv2QzDdQ= +github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90= +github.com/SkyAPM/ice v0.0.0-20241108011032-c3d8eea75118 h1:Ja62sgOCp2qPTd8Xmldv1U83v11IRIsh6KlB7UaFLj4= +github.com/SkyAPM/ice v0.0.0-20241108011032-c3d8eea75118/go.mod h1:DoQeb0Ee86LyruZSL77Ddscfk/THJ38x453CRCnGEPI= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/axiomhq/hyperloglog v0.0.0-20191112132149-a4c4c47bc57f h1:y06x6vGnFYfXUoVMbrcP1Uzpj4JG01eB5vRps9G8agM= -github.com/axiomhq/hyperloglog v0.0.0-20191112132149-a4c4c47bc57f/go.mod h1:2stgcRjl6QmW+gU2h5E7BQXg4HU0gzxKWDuT5HviN9s= -github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= +github.com/axiomhq/hyperloglog v0.2.0 h1:u1XT3yyY1rjzlWuP6NQIrV4bRYHOaqZaovqjcBEvZJo= +github.com/axiomhq/hyperloglog v0.2.0/go.mod h1:GcgMjz9gaDKZ3G0UMS6Fq/VkZ4l7uGgcJyxA7M+omIM= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.14.3 h1:Gd2c8lSNf9pKXom5JtD7AaKO8o7fGQ2LtFj1436qilA= +github.com/bits-and-blooms/bitset v1.14.3/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= 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.3/go.mod h1:pYvKl/grLQrBxuaRYgoTssa4rVujYYeenDp++2E+yvs= github.com/blevesearch/mmap-go v1.0.4 h1:OVhDhT5B/M1HNPpYPBKIEJaD0F3Si+CrEKULGCDPWmc= github.com/blevesearch/mmap-go v1.0.4/go.mod h1:EWmEAOmdAS9z/pi/+Toxu99DnsbhG1TIxUoRmJw/pSs= -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/segment v0.9.1 h1:+dThDy+Lvgj5JMxhmOVlgFfkUtZV2kw49xax4+jTfSU= +github.com/blevesearch/segment v0.9.1/go.mod h1:zN21iLm7+GnBHWTao9I+Au/7MBiL8pPFtJBJTsk6kQw= 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/vellum v1.0.7 h1:+vn8rfyCRHxKVRgDLeR0FAXej2+6mEb5Q15aQE/XESQ= -github.com/blevesearch/vellum v1.0.7/go.mod h1:doBZpmRhwTsASB4QdUZANlJvqVAUdUyX0ZK7QJCTeBE= +github.com/blevesearch/vellum v1.0.10 h1:HGPJDT2bTva12hrHepVT3rOyIKFFF4t7Gf6yMxyMIPI= +github.com/blevesearch/vellum v1.0.10/go.mod h1:ul1oT0FhSMDIExNjIxHqJoGpVrBpKCdgDQNxfqgJt7k= github.com/caio/go-tdigest v3.1.0+incompatible h1:uoVMJ3Q5lXmVLCCqaMGHLBWnbGoN6Lpu7OAUPR60cds= github.com/caio/go-tdigest v3.1.0+incompatible/go.mod h1:sHQM/ubZStBUmF1WbB8FAm8q9GjDajLC5T7ydxE3JHI= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -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/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 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/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8= -github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= +github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= +github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb v1.7.6/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/klauspost/compress v1.15.2 h1:3WH+AG7s2+T8o3nrM/8u2rdqUEcQhmga7smjrT41nAw= -github.com/klauspost/compress v1.15.2/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 h1:X/79QL0b4YJVO5+OsPH9rF2u428CIrGL/jLmPsoOQQ4= github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353/go.mod h1:N0SVk0uhy+E1PZ3C9ctsPRlvOPAFPkCNlcPBDkt0N3U= -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.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 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/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 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/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/zinclabs/bluge_segment_api v1.0.0 h1:GJvPxdzR7KjwdxmcKleQLvtIYi/J7Q7ehRlZqgGayzg= github.com/zinclabs/bluge_segment_api v1.0.0/go.mod h1:mYfPVUdXLZ4iXsicXMER+RcI/avwphjMOi8nhN9HDLA= -github.com/zinclabs/ice v1.1.1 h1:pm4M5+kLDotDLuDHrWJ73o0U54D9uNnKWYWUzqasJKU= -github.com/zinclabs/ice v1.1.1/go.mod h1:wTwGEe30mQnSLaR1ezxu4E80GcwO6EyOww67KpJtIiw= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/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-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= @@ -90,6 +70,8 @@ gonum.org/v1/gonum v0.7.0/go.mod h1:L02bwd0sqlsvRv41G7wGWFCsVNZFv/k1xzGIxeANHGM= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/index/config.go b/index/config.go index 5dca846..9a4b2d8 100644 --- a/index/config.go +++ b/index/config.go @@ -105,9 +105,9 @@ func (config Config) WithNormCalc(calc func(field string, numTerms int) float32) return config } -func (config Config) WithTimeRange(min, max int64) Config { - config.FilterTimeMin = min - config.FilterTimeMax = max +func (config Config) WithTimeRange(timeMin, timeMax int64) Config { + config.FilterTimeMin = timeMin + config.FilterTimeMax = timeMax return config } diff --git a/index/lock/lock_test.go b/index/lock/lock_test.go index f3d8b2a..d59f9c7 100644 --- a/index/lock/lock_test.go +++ b/index/lock/lock_test.go @@ -15,7 +15,6 @@ package lock import ( - "io/ioutil" "os" "os/exec" "path/filepath" @@ -188,7 +187,7 @@ func TestOpenExclusiveThenOpenExclusive(t *testing.T) { func createTestPath(t *testing.T) (path string, cleanup func()) { // create a path to test - tmpDir, err := ioutil.TempDir("", "lock-test") + tmpDir, err := os.MkdirTemp("", "lock-test") if err != nil { t.Fatalf("error creating temp dir: %v", err) } diff --git a/index/mergeplan/merge_plan_test.go b/index/mergeplan/merge_plan_test.go index 564f5bd..4aaf39e 100644 --- a/index/mergeplan/merge_plan_test.go +++ b/index/mergeplan/merge_plan_test.go @@ -469,10 +469,10 @@ func TestPlanMaxSegmentSizeLimit(t *testing.T) { s := rand.NewSource(time.Now().UnixNano()) r := rand.New(s) - max := 20 - min := 5 + maxVal := 20 + minVal := 5 randomInRange := func() int64 { - return int64(r.Intn(max-min) + min) + return int64(r.Intn(maxVal-minVal) + minVal) } for i := 1; i < 20; i++ { o.MaxSegmentSize = randomInRange() diff --git a/index/writer.go b/index/writer.go index 85fc8ef..c850dc2 100644 --- a/index/writer.go +++ b/index/writer.go @@ -348,7 +348,7 @@ func (s *Writer) Reader() (*Snapshot, error) { func (s *Writer) MemoryUsed() (memUsed uint64) { indexSnapshot := s.currentSnapshot() if indexSnapshot == nil { - return + return 0 } defer func() { diff --git a/index/writer_test.go b/index/writer_test.go index 68eebfb..c52f308 100644 --- a/index/writer_test.go +++ b/index/writer_test.go @@ -15,7 +15,6 @@ package index import ( - "io/ioutil" "math" "os" "reflect" @@ -28,7 +27,7 @@ import ( ) func CreateConfig(name string) (config Config, cleanup func() error) { - path, err := ioutil.TempDir("", "bluge-index-test"+name) + path, err := os.MkdirTemp("", "bluge-index-test"+name) if err != nil { panic(err) } diff --git a/index_test.go b/index_test.go index 3e6c53f..2f92203 100644 --- a/index_test.go +++ b/index_test.go @@ -18,7 +18,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "math" "math/rand" "os" @@ -39,7 +38,7 @@ type Fatalfable interface { } func createTmpIndexPath(f Fatalfable) string { - tmpIndexPath, err := ioutil.TempDir("", "bluge-testidx") + tmpIndexPath, err := os.MkdirTemp("", "bluge-testidx") if err != nil { f.Fatalf("error creating temp dir: %v", err) } diff --git a/numeric/geo/parse.go b/numeric/geo/parse.go index 6dc34b0..bf47af6 100644 --- a/numeric/geo/parse.go +++ b/numeric/geo/parse.go @@ -26,15 +26,24 @@ const lonLatSliceLen = 2 // interpret it is as geo point. Supported formats: // Container: // slice length 2 (GeoJSON) -// first element lon, second element lat +// +// first element lon, second element lat +// // string (coordinates separated by comma, or a geohash) -// first element lat, second element lon +// +// first element lat, second element lon +// // map[string]interface{} -// exact keys lat and lon or lng +// +// exact keys lat and lon or lng +// // struct -// w/exported fields case-insensitive match on lat and lon or lng +// +// w/exported fields case-insensitive match on lat and lon or lng +// // struct -// satisfying Later and Loner or Lnger interfaces +// +// satisfying Later and Loner or Lnger interfaces // // in all cases values must be some sort of numeric-like thing: int/uint/float func ExtractGeoPoint(thing interface{}) (lon, lat float64, success bool) { diff --git a/query.go b/query.go index 418ea12..f898c6b 100644 --- a/query.go +++ b/query.go @@ -55,12 +55,12 @@ func (s querySlice) searchers(i search.Reader, options search.SearcherOptions) ( return rv, nil } -func (s querySlice) disjunction(i search.Reader, options search.SearcherOptions, min int) (search.Searcher, error) { +func (s querySlice) disjunction(i search.Reader, options search.SearcherOptions, minMatch int) (search.Searcher, error) { constituents, err := s.searchers(i, options) if err != nil { return nil, err } - return searcher.NewDisjunctionSearcher(i, constituents, min, similarity.NewCompositeSumScorer(), options) + return searcher.NewDisjunctionSearcher(i, constituents, minMatch, similarity.NewCompositeSumScorer(), options) } func (s querySlice) conjunction(i search.Reader, options search.SearcherOptions) (search.Searcher, error) { @@ -285,7 +285,9 @@ type DateRangeQuery struct { // NewDateRangeQuery creates a new Query for ranges // of date values. // Date strings are parsed using the DateTimeParser configured in the -// top-level config.QueryDateTimeParser +// +// top-level config.QueryDateTimeParser +// // Either, but not both endpoints can be nil. func NewDateRangeQuery(start, end time.Time) *DateRangeQuery { return NewDateRangeInclusiveQuery(start, end, true, false) @@ -294,7 +296,9 @@ func NewDateRangeQuery(start, end time.Time) *DateRangeQuery { // NewDateRangeInclusiveQuery creates a new Query for ranges // of date values. // Date strings are parsed using the DateTimeParser configured in the -// top-level config.QueryDateTimeParser +// +// top-level config.QueryDateTimeParser +// // Either, but not both endpoints can be nil. // startInclusive and endInclusive control inclusion of the endpoints. func NewDateRangeInclusiveQuery(start, end time.Time, startInclusive, endInclusive bool) *DateRangeQuery { @@ -336,7 +340,7 @@ func (q *DateRangeQuery) Field() string { } func (q *DateRangeQuery) Searcher(i search.Reader, options search.SearcherOptions) (search.Searcher, error) { - min, max, err := q.parseEndpoints() + minVal, maxVal, err := q.parseEndpoints() if err != nil { return nil, err } @@ -350,20 +354,20 @@ func (q *DateRangeQuery) Searcher(i search.Reader, options search.SearcherOption q.scorer = similarity.ConstantScorer(1) } - return searcher.NewNumericRangeSearcher(i, min, max, q.inclusiveStart, q.inclusiveEnd, field, + return searcher.NewNumericRangeSearcher(i, minVal, maxVal, q.inclusiveStart, q.inclusiveEnd, field, q.boost.Value(), q.scorer, similarity.NewCompositeSumScorer(), options) } -func (q *DateRangeQuery) parseEndpoints() (min, max float64, err error) { - min = math.Inf(-1) - max = math.Inf(1) +func (q *DateRangeQuery) parseEndpoints() (minVal, maxVal float64, err error) { + minVal = math.Inf(-1) + maxVal = math.Inf(1) if !q.start.IsZero() { if !isDatetimeCompatible(q.start) { // overflow return 0, 0, fmt.Errorf("invalid/unsupported date range, start: %v", q.start) } startInt64 := q.start.UnixNano() - min = numeric.Int64ToFloat64(startInt64) + minVal = numeric.Int64ToFloat64(startInt64) } if !q.end.IsZero() { if !isDatetimeCompatible(q.end) { @@ -371,10 +375,10 @@ func (q *DateRangeQuery) parseEndpoints() (min, max float64, err error) { return 0, 0, fmt.Errorf("invalid/unsupported date range, end: %v", q.end) } endInt64 := q.end.UnixNano() - max = numeric.Int64ToFloat64(endInt64) + maxVal = numeric.Int64ToFloat64(endInt64) } - return min, max, nil + return minVal, maxVal, nil } func (q *DateRangeQuery) Validate() error { @@ -1097,18 +1101,18 @@ var MaxNumeric = math.Inf(1) // Either, but not both endpoints can be nil. // The minimum value is inclusive. // The maximum value is exclusive. -func NewNumericRangeQuery(min, max float64) *NumericRangeQuery { - return NewNumericRangeInclusiveQuery(min, max, true, false) +func NewNumericRangeQuery(minVal, maxVal float64) *NumericRangeQuery { + return NewNumericRangeInclusiveQuery(minVal, maxVal, true, false) } // NewNumericRangeInclusiveQuery creates a new Query for ranges // of numeric values. // Either, but not both endpoints can be nil. // Control endpoint inclusion with inclusiveMin, inclusiveMax. -func NewNumericRangeInclusiveQuery(min, max float64, minInclusive, maxInclusive bool) *NumericRangeQuery { +func NewNumericRangeInclusiveQuery(minVal, maxVal float64, minInclusive, maxInclusive bool) *NumericRangeQuery { return &NumericRangeQuery{ - min: min, - max: max, + min: minVal, + max: maxVal, inclusiveMin: minInclusive, inclusiveMax: maxInclusive, } @@ -1334,18 +1338,18 @@ type TermRangeQuery struct { // Either, but not both endpoints can be "". // The minimum value is inclusive. // The maximum value is exclusive. -func NewTermRangeQuery(min, max string) *TermRangeQuery { - return NewTermRangeInclusiveQuery(min, max, true, false) +func NewTermRangeQuery(minVal, maxVal string) *TermRangeQuery { + return NewTermRangeInclusiveQuery(minVal, maxVal, true, false) } // NewTermRangeInclusiveQuery creates a new Query for ranges // of text terms. // Either, but not both endpoints can be "". // Control endpoint inclusion with inclusiveMin, inclusiveMax. -func NewTermRangeInclusiveQuery(min, max string, minInclusive, maxInclusive bool) *TermRangeQuery { +func NewTermRangeInclusiveQuery(minVal, maxVal string, minInclusive, maxInclusive bool) *TermRangeQuery { return &TermRangeQuery{ - min: min, - max: max, + min: minVal, + max: maxVal, inclusiveMin: minInclusive, inclusiveMax: maxInclusive, } diff --git a/search/searcher/search_disjunction.go b/search/searcher/search_disjunction.go index 68f840a..20376ff 100644 --- a/search/searcher/search_disjunction.go +++ b/search/searcher/search_disjunction.go @@ -35,9 +35,9 @@ var DisjunctionMaxClauseCount = 0 var DisjunctionHeapTakeover = 10 func NewDisjunctionSearcher(indexReader search.Reader, - qsearchers []search.Searcher, min int, scorer search.CompositeScorer, options search.SearcherOptions) ( + qsearchers []search.Searcher, minMatch int, scorer search.CompositeScorer, options search.SearcherOptions) ( search.Searcher, error) { - return newDisjunctionSearcher(indexReader, qsearchers, min, scorer, options, true) + return newDisjunctionSearcher(indexReader, qsearchers, minMatch, scorer, options, true) } func optionsDisjunctionOptimizable(options search.SearcherOptions) bool { @@ -46,12 +46,12 @@ func optionsDisjunctionOptimizable(options search.SearcherOptions) bool { } func newDisjunctionSearcher(indexReader search.Reader, - qsearchers []search.Searcher, min int, scorer search.CompositeScorer, options search.SearcherOptions, + qsearchers []search.Searcher, minMatch int, scorer search.CompositeScorer, options search.SearcherOptions, limit bool) (search.Searcher, error) { // attempt the "unadorned" disjunction optimization only when we // do not need extra information like freq-norm's or term vectors // and the requested min is simple - if len(qsearchers) > 1 && min <= 1 && + if len(qsearchers) > 1 && minMatch <= 1 && optionsDisjunctionOptimizable(options) { rv, err := optimizeCompositeSearcher("disjunction:unadorned", indexReader, qsearchers, options) @@ -61,10 +61,10 @@ func newDisjunctionSearcher(indexReader search.Reader, } if len(qsearchers) > DisjunctionHeapTakeover { - return newDisjunctionHeapSearcher(qsearchers, min, scorer, options, + return newDisjunctionHeapSearcher(qsearchers, minMatch, scorer, options, limit) } - return newDisjunctionSliceSearcher(qsearchers, min, scorer, options, + return newDisjunctionSliceSearcher(qsearchers, minMatch, scorer, options, limit) } diff --git a/search/searcher/search_disjunction_heap.go b/search/searcher/search_disjunction_heap.go index 4572b4a..a7c338f 100644 --- a/search/searcher/search_disjunction_heap.go +++ b/search/searcher/search_disjunction_heap.go @@ -40,7 +40,7 @@ type DisjunctionHeapSearcher struct { options search.SearcherOptions } -func newDisjunctionHeapSearcher(searchers []search.Searcher, min int, scorer search.CompositeScorer, options search.SearcherOptions, +func newDisjunctionHeapSearcher(searchers []search.Searcher, minMatch int, scorer search.CompositeScorer, options search.SearcherOptions, limit bool) ( *DisjunctionHeapSearcher, error) { if limit && tooManyClauses(len(searchers)) { @@ -52,7 +52,7 @@ func newDisjunctionHeapSearcher(searchers []search.Searcher, min int, scorer sea searchers: searchers, numSearchers: len(searchers), scorer: scorer, - min: min, + min: minMatch, matching: make([]*search.DocumentMatch, len(searchers)), matchingCurrs: make([]*searcherCurr, len(searchers)), heap: make([]*searcherCurr, 0, len(searchers)), diff --git a/search/searcher/search_disjunction_slice.go b/search/searcher/search_disjunction_slice.go index 40b4d94..4ce6818 100644 --- a/search/searcher/search_disjunction_slice.go +++ b/search/searcher/search_disjunction_slice.go @@ -34,7 +34,7 @@ type DisjunctionSliceSearcher struct { options search.SearcherOptions } -func newDisjunctionSliceSearcher(qsearchers []search.Searcher, min int, scorer search.CompositeScorer, options search.SearcherOptions, +func newDisjunctionSliceSearcher(qsearchers []search.Searcher, minMatch int, scorer search.CompositeScorer, options search.SearcherOptions, limit bool) ( *DisjunctionSliceSearcher, error) { if limit && tooManyClauses(len(qsearchers)) { @@ -51,7 +51,7 @@ func newDisjunctionSliceSearcher(qsearchers []search.Searcher, min int, scorer s numSearchers: len(searchers), currs: make([]*search.DocumentMatch, len(searchers)), scorer: scorer, - min: min, + min: minMatch, matching: make([]*search.DocumentMatch, len(searchers)), matchingIdxs: make([]int, len(searchers)), options: options, diff --git a/search/searcher/search_numeric_range.go b/search/searcher/search_numeric_range.go index 07976da..785c65a 100644 --- a/search/searcher/search_numeric_range.go +++ b/search/searcher/search_numeric_range.go @@ -25,20 +25,20 @@ import ( ) func NewNumericRangeSearcher(indexReader search.Reader, - min, max float64, inclusiveMin, inclusiveMax bool, field string, + minVal, maxVal float64, inclusiveMin, inclusiveMax bool, field string, boost float64, scorer search.Scorer, compScorer search.CompositeScorer, options search.SearcherOptions) (search.Searcher, error) { var minInt64 int64 - if math.IsInf(min, -1) { + if math.IsInf(minVal, -1) { minInt64 = math.MinInt64 } else { - minInt64 = numeric.Float64ToInt64(min) + minInt64 = numeric.Float64ToInt64(minVal) } var maxInt64 int64 - if math.IsInf(max, 1) { + if math.IsInf(maxVal, 1) { maxInt64 = math.MaxInt64 } else { - maxInt64 = numeric.Float64ToInt64(max) + maxInt64 = numeric.Float64ToInt64(maxVal) } // find all the ranges diff --git a/search/searcher/search_numeric_range_test.go b/search/searcher/search_numeric_range_test.go index b66f202..52a3f32 100644 --- a/search/searcher/search_numeric_range_test.go +++ b/search/searcher/search_numeric_range_test.go @@ -22,9 +22,9 @@ import ( ) func TestSplitRange(t *testing.T) { - min := numeric.Float64ToInt64(1.0) - max := numeric.Float64ToInt64(5.0) - ranges := splitInt64Range(min, max, 4) + minBound := numeric.Float64ToInt64(1.0) + maxBound := numeric.Float64ToInt64(5.0) + ranges := splitInt64Range(minBound, maxBound, 4) enumerated := ranges.Enumerate(nil) if len(enumerated) != 135 { t.Errorf("expected 135 terms, got %d", len(enumerated)) diff --git a/search/searcher/search_phrase.go b/search/searcher/search_phrase.go index 92fe4a8..e721619 100644 --- a/search/searcher/search_phrase.go +++ b/search/searcher/search_phrase.go @@ -274,14 +274,20 @@ func (p phrasePath) String() string { // // prevPos - the previous location, 0 on first invocation // phraseTerms - slice containing the phrase terms, -// may contain empty string as placeholder (don't care) +// +// may contain empty string as placeholder (don't care) +// // tlm - the Term Location Map containing all relevant term locations // p - the current path being explored (appended to in recursive calls) -// this is the primary state being built during the traversal +// +// this is the primary state being built during the traversal +// // remainingSlop - amount of sloppiness that's allowed, which is the -// sum of the editDistances from each matching phrase part, -// where 0 means no sloppiness allowed (all editDistances must be 0), -// decremented during recursion +// +// sum of the editDistances from each matching phrase part, +// where 0 means no sloppiness allowed (all editDistances must be 0), +// decremented during recursion +// // rv - the final result being appended to by all the recursive calls // // returns slice of paths, or nil if invocation did not find any successul paths diff --git a/search/searcher/search_term_range.go b/search/searcher/search_term_range.go index e6d0179..b54169c 100644 --- a/search/searcher/search_term_range.go +++ b/search/searcher/search_term_range.go @@ -19,18 +19,18 @@ import ( ) func NewTermRangeSearcher(indexReader search.Reader, - min, max []byte, inclusiveMin, inclusiveMax bool, field string, + minVal, maxVal []byte, inclusiveMin, inclusiveMax bool, field string, boost float64, scorer search.Scorer, compScorer search.CompositeScorer, options search.SearcherOptions) (search.Searcher, error) { - if min == nil { - min = []byte{} + if minVal == nil { + minVal = []byte{} } - if max != nil && inclusiveMax { - max = append(max, 0) + if maxVal != nil && inclusiveMax { + maxVal = append(maxVal, 0) } - fieldDict, err := indexReader.DictionaryIterator(field, nil, min, max) + fieldDict, err := indexReader.DictionaryIterator(field, nil, minVal, maxVal) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewTermRangeSearcher(indexReader search.Reader, return NewMatchNoneSearcher(indexReader, options) } - if !inclusiveMin && min != nil && string(min) == terms[0] { + if !inclusiveMin && minVal != nil && string(minVal) == terms[0] { terms = terms[1:] // check again, as we might have removed only entry if len(terms) < 1 { diff --git a/test/integration_test.go b/test/integration_test.go index 6503069..c46f5ce 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -18,8 +18,8 @@ import ( "context" "flag" "fmt" - "io/ioutil" "math" + "os" "reflect" "sort" "testing" @@ -110,7 +110,7 @@ func TestIntegration(t *testing.T) { } for _, intTest := range integrationTests { - path, err := ioutil.TempDir("", "bluge-integration-test-"+intTest.Name) + path, err := os.MkdirTemp("", "bluge-integration-test-"+intTest.Name) if err != nil { t.Fatal(err) }