Repository: blevesearch/bleve
Pull request #2165 (2025-03-17 20:05:08)

MB-65807: Graceful handling of non-conforming polygon data
Geo's `extract3DCoordinates` does not validate input data which can cause malformed polygon data to cause a panic:

```
panic: reflect: call of reflect.Value.Index on map Value

panic({0x100a9e0c0?, 0x140001163a8?})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:770 +0x124
reflect.Value.Index({0x100a9ffe0?, 0x14000118c00?, 0x14000062c58?}, 0x1008913c8?)
        /opt/homebrew/opt/go/libexec/src/reflect/value.go:1447 +0x170
github.com/blevesearch/bleve/v2/geo.extract3DCoordinates({0x100a9ffe0?, 0x14000118c00?})
        /Users/abhinav.dangeti/Documents/go/src/github.com/blevesearch/bleve/geo/parse.go:245 +0x12c
github.com/blevesearch/bleve/v2/geo.ExtractGeoShapeCoordinates({0x100a9ffe0?, 0x14000118c00?}, {0x100a24659, 0x7})
```

See: https://pkg.go.dev/reflect#Value.IsValid


Patch:
diff --git a/analysis/token/keyword/keyword.go b/analysis/token/keyword/keyword.go
index 0f8c8477..f2e56f39 100644
--- a/analysis/token/keyword/keyword.go
+++ b/analysis/token/keyword/keyword.go
@@ -35,8 +35,7 @@ func NewKeyWordMarkerFilter(keyWords analysis.TokenMap) *KeyWordMarkerFilter {
 
 func (f *KeyWordMarkerFilter) Filter(input analysis.TokenStream) analysis.TokenStream {
 	for _, token := range input {
-		word := string(token.Term)
-		_, isKeyWord := f.keyWords[word]
+		_, isKeyWord := f.keyWords[string(token.Term)]
 		if isKeyWord {
 			token.KeyWord = true
 		}
diff --git a/cmd/bleve/cmd/bulk.go b/cmd/bleve/cmd/bulk.go
index 3f374e76..458c3c71 100644
--- a/cmd/bleve/cmd/bulk.go
+++ b/cmd/bleve/cmd/bulk.go
@@ -67,8 +67,7 @@ var bulkCmd = &cobra.Command{
 					break
 				}
 
-				var doc interface{}
-				doc = b
+				var doc interface{} = b
 				var err error
 				if parseJSON {
 					err = json.Unmarshal(b, &doc)
diff --git a/geo/parse.go b/geo/parse.go
index 34f731a9..ed1d935b 100644
--- a/geo/parse.go
+++ b/geo/parse.go
@@ -236,14 +236,19 @@ func extract2DCoordinates(thing interface{}) [][]float64 {
 
 func extract3DCoordinates(thing interface{}) (c [][][]float64) {
 	coords := reflect.ValueOf(thing)
-	for i := 0; i < coords.Len(); i++ {
-		vals := coords.Index(i)
-
-		edges := vals.Interface()
-		if es, ok := edges.([]interface{}); ok {
-			loop := extract2DCoordinates(es)
-			if len(loop) > 0 {
-				c = append(c, loop)
+	if !coords.IsValid() {
+		return nil
+	}
+
+	if coords.Kind() == reflect.Slice {
+		for i := 0; i < coords.Len(); i++ {
+			vals := coords.Index(i)
+			edges := vals.Interface()
+			if es, ok := edges.([]interface{}); ok {
+				loop := extract2DCoordinates(es)
+				if len(loop) > 0 {
+					c = append(c, loop)
+				}
 			}
 		}
 	}
diff --git a/index/scorch/persister.go b/index/scorch/persister.go
index 9e1dd7d1..8decc7c1 100644
--- a/index/scorch/persister.go
+++ b/index/scorch/persister.go
@@ -240,7 +240,8 @@ OUTER:
 }
 
 func notifyMergeWatchers(lastPersistedEpoch uint64,
-	persistWatchers []*epochWatcher) []*epochWatcher {
+	persistWatchers []*epochWatcher,
+) []*epochWatcher {
 	var watchersNext []*epochWatcher
 	for _, w := range persistWatchers {
 		if w.epoch < lastPersistedEpoch {
@@ -254,8 +255,8 @@ func notifyMergeWatchers(lastPersistedEpoch uint64,
 
 func (s *Scorch) pausePersisterForMergerCatchUp(lastPersistedEpoch uint64,
 	lastMergedEpoch uint64, persistWatchers []*epochWatcher,
-	po *persisterOptions) (uint64, []*epochWatcher) {
-
+	po *persisterOptions,
+) (uint64, []*epochWatcher) {
 	// First, let the watchers proceed if they lag behind
 	persistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)
 
@@ -339,7 +340,8 @@ func (s *Scorch) parsePersisterOptions() (*persisterOptions, error) {
 }
 
 func (s *Scorch) persistSnapshot(snapshot *IndexSnapshot,
-	po *persisterOptions) error {
+	po *persisterOptions,
+) error {
 	// Perform in-memory segment merging only when the memory pressure is
 	// below the configured threshold, else the persister performs the
 	// direct persistence of segments.
@@ -365,7 +367,8 @@ var DefaultMinSegmentsForInMemoryMerge = 2
 // persistSnapshotMaybeMerge examines the snapshot and might merge and
 // persist the in-memory zap segments if there are enough of them
 func (s *Scorch) persistSnapshotMaybeMerge(snapshot *IndexSnapshot) (
-	bool, error) {
+	bool, error,
+) {
 	// collect the in-memory zap segments (SegmentBase instances)
 	var sbs []segment.Segment
 	var sbsDrops []*roaring.Bitmap
@@ -468,7 +471,8 @@ func copyToDirectory(srcPath string, d index.Directory) (int64, error) {
 }
 
 func persistToDirectory(seg segment.UnpersistedSegment, d index.Directory,
-	path string) error {
+	path string,
+) error {
 	if d == nil {
 		return seg.Persist(path)
 	}
@@ -491,7 +495,8 @@ func persistToDirectory(seg segment.UnpersistedSegment, d index.Directory,
 
 func prepareBoltSnapshot(snapshot *IndexSnapshot, tx *bolt.Tx, path string,
 	segPlugin SegmentPlugin, d index.Directory) (
-	[]string, map[uint64]string, error) {
+	[]string, map[uint64]string, error,
+) {
 	snapshotsBucket, err := tx.CreateBucketIfNotExists(boltSnapshotsBucket)
 	if err != nil {
 		return nil, nil, err
@@ -713,16 +718,18 @@ func zapFileName(epoch uint64) string {
 
 // bolt snapshot code
 
-var boltSnapshotsBucket = []byte{'s'}
-var boltPathKey = []byte{'p'}
-var boltDeletedKey = []byte{'d'}
-var boltInternalKey = []byte{'i'}
-var boltMetaDataKey = []byte{'m'}
-var boltMetaDataSegmentTypeKey = []byte("type")
-var boltMetaDataSegmentVersionKey = []byte("version")
-var boltMetaDataTimeStamp = []byte("timeStamp")
-var boltStatsKey = []byte("stats")
-var TotBytesWrittenKey = []byte("TotBytesWritten")
+var (
+	boltSnapshotsBucket           = []byte{'s'}
+	boltPathKey                   = []byte{'p'}
+	boltDeletedKey                = []byte{'d'}
+	boltInternalKey               = []byte{'i'}
+	boltMetaDataKey               = []byte{'m'}
+	boltMetaDataSegmentTypeKey    = []byte("type")
+	boltMetaDataSegmentVersionKey = []byte("version")
+	boltMetaDataTimeStamp         = []byte("timeStamp")
+	boltStatsKey                  = []byte("stats")
+	TotBytesWrittenKey            = []byte("TotBytesWritten")
+)
 
 func (s *Scorch) loadFromBolt() error {
 	return s.rootBolt.View(func(tx *bolt.Tx) error {
@@ -800,7 +807,6 @@ func (s *Scorch) LoadSnapshot(epoch uint64) (rv *IndexSnapshot, err error) {
 }
 
 func (s *Scorch) loadSnapshot(snapshot *bolt.Bucket) (*IndexSnapshot, error) {
-
 	rv := &IndexSnapshot{
 		parent:   s,
 		internal: make(map[string][]byte),
@@ -947,7 +953,8 @@ var RollbackSamplingInterval = 0 * time.Minute
 var RollbackRetentionFactor = float64(0.5)
 
 func getTimeSeriesSnapshots(maxDataPoints int, interval time.Duration,
-	snapshots []*snapshotMetaData) (int, map[uint64]time.Time) {
+	snapshots []*snapshotMetaData,
+) (int, map[uint64]time.Time) {
 	if interval == 0 {
 		return len(snapshots), map[uint64]time.Time{}
 	}
@@ -994,8 +1001,8 @@ func getTimeSeriesSnapshots(maxDataPoints int, interval time.Duration,
 // by a time duration of RollbackSamplingInterval.
 func getProtectedSnapshots(rollbackSamplingInterval time.Duration,
 	numSnapshotsToKeep int,
-	persistedSnapshots []*snapshotMetaData) map[uint64]time.Time {
-
+	persistedSnapshots []*snapshotMetaData,
+) map[uint64]time.Time {
 	lastPoint, protectedEpochs := getTimeSeriesSnapshots(numSnapshotsToKeep,
 		rollbackSamplingInterval, persistedSnapshots)
 	if len(protectedEpochs) < numSnapshotsToKeep {
@@ -1162,7 +1169,8 @@ func (s *Scorch) removeOldZapFiles() error {
 // Hence we try to retain atleast retentionFactor portion worth of old snapshots
 // in such a scenario using the following function
 func getBoundaryCheckPoint(retentionFactor float64,
-	checkPoints []*snapshotMetaData, timeStamp time.Time) time.Time {
+	checkPoints []*snapshotMetaData, timeStamp time.Time,
+) time.Time {
 	if checkPoints != nil {
 		boundary := checkPoints[int(math.Floor(float64(len(checkPoints))*
 			retentionFactor))]
diff --git a/index/scorch/scorch.go b/index/scorch/scorch.go
index 5b704857..514e35bc 100644
--- a/index/scorch/scorch.go
+++ b/index/scorch/scorch.go
@@ -110,7 +110,8 @@ type internalStats struct {
 
 func NewScorch(storeName string,
 	config map[string]interface{},
-	analysisQueue *index.AnalysisQueue) (index.Index, error) {
+	analysisQueue *index.AnalysisQueue,
+) (index.Index, error) {
 	rv := &Scorch{
 		version:              Version,
 		config:               config,
@@ -137,7 +138,9 @@ func NewScorch(storeName string,
 
 	typ, ok := config["spatialPlugin"].(string)
 	if ok {
-		rv.loadSpatialAnalyzerPlugin(typ)
+		if err := rv.loadSpatialAnalyzerPlugin(typ); err != nil {
+			return nil, err
+		}
 	}
 
 	rv.root = &IndexSnapshot{parent: rv, refs: 1, creator: "NewScorch"}
@@ -230,7 +233,7 @@ func (s *Scorch) openBolt() error {
 		s.unsafeBatch = true
 	}
 
-	var rootBoltOpt = *bolt.DefaultOptions
+	rootBoltOpt := *bolt.DefaultOptions
 	if s.readOnly {
 		rootBoltOpt.ReadOnly = true
 		rootBoltOpt.OpenFile = func(path string, flag int, mode os.FileMode) (*os.File, error) {
@@ -244,7 +247,7 @@ func (s *Scorch) openBolt() error {
 		}
 	} else {
 		if s.path != "" {
-			err := os.MkdirAll(s.path, 0700)
+			err := os.MkdirAll(s.path, 0o700)
 			if err != nil {
 				return err
 			}
@@ -263,7 +266,7 @@ func (s *Scorch) openBolt() error {
 	rootBoltPath := s.path + string(os.PathSeparator) + "root.bolt"
 	var err error
 	if s.path != "" {
-		s.rootBolt, err = bolt.Open(rootBoltPath, 0600, &rootBoltOpt)
+		s.rootBolt, err = bolt.Open(rootBoltPath, 0o600, &rootBoltOpt)
 		if err != nil {
 			return err
 		}
@@ -325,7 +328,9 @@ func (s *Scorch) openBolt() error {
 
 	typ, ok := s.config["spatialPlugin"].(string)
 	if ok {
-		s.loadSpatialAnalyzerPlugin(typ)
+		if err := s.loadSpatialAnalyzerPlugin(typ); err != nil {
+			return err
+		}
 	}
 
 	return nil
@@ -481,8 +486,8 @@ func (s *Scorch) Batch(batch *index.Batch) (err error) {
 }
 
 func (s *Scorch) prepareSegment(newSegment segment.Segment, ids []string,
-	internalOps map[string][]byte, persistedCallback index.BatchCallback, stats *fieldStats) error {
-
+	internalOps map[string][]byte, persistedCallback index.BatchCallback, stats *fieldStats,
+) error {
 	// new introduction
 	introduction := &segmentIntroduction{
 		id:                atomic.AddUint64(&s.nextSegmentID, 1),
@@ -576,7 +581,8 @@ func (s *Scorch) BytesReadQueryTime() uint64 {
 }
 
 func (s *Scorch) diskFileStats(rootSegmentPaths map[string]struct{}) (uint64,
-	uint64, uint64) {
+	uint64, uint64,
+) {
 	var numFilesOnDisk, numBytesUsedDisk, numBytesOnDiskByRoot uint64
 	if s.path != "" {
 		files, err := os.ReadDir(s.path)
@@ -832,7 +838,6 @@ func (fs *fieldStats) Store(statName, fieldName string, value uint64) {
 
 // Combine the given stats map with the existing map
 func (fs *fieldStats) Aggregate(stats segment.FieldStats) {
-
 	statMap := stats.Fetch()
 	if statMap == nil {
 		return
diff --git a/index/scorch/snapshot_index.go b/index/scorch/snapshot_index.go
index dc96cac4..91b82044 100644
--- a/index/scorch/snapshot_index.go
+++ b/index/scorch/snapshot_index.go
@@ -134,8 +134,8 @@ func (i *IndexSnapshot) updateSize() {
 
 func (is *IndexSnapshot) newIndexSnapshotFieldDict(field string,
 	makeItr func(i segment.TermDictionary) segment.DictionaryIterator,
-	randomLookup bool) (*IndexSnapshotFieldDict, error) {
-
+	randomLookup bool,
+) (*IndexSnapshotFieldDict, error) {
 	results := make(chan *asynchSegmentResult)
 	var totalBytesRead uint64
 	var fieldCardinality int64
@@ -230,7 +230,8 @@ func calculateExclusiveEndFromInclusiveEnd(inclusiveEnd []byte) []byte {
 }
 
 func (is *IndexSnapshot) FieldDictRange(field string, startTerm []byte,
-	endTerm []byte) (index.FieldDict, error) {
+	endTerm []byte,
+) (index.FieldDict, error) {
 	return is.newIndexSnapshotFieldDict(field, func(is segment.TermDictionary) segment.DictionaryIterator {
 		endTermExclusive := calculateExclusiveEndFromInclusiveEnd(endTerm)
 		return is.AutomatonIterator(nil, startTerm, endTermExclusive)
@@ -256,7 +257,8 @@ func calculateExclusiveEndFromPrefix(in []byte) []byte {
 }
 
 func (is *IndexSnapshot) FieldDictPrefix(field string,
-	termPrefix []byte) (index.FieldDict, error) {
+	termPrefix []byte,
+) (index.FieldDict, error) {
 	termPrefixEnd := calculateExclusiveEndFromPrefix(termPrefix)
 	return is.newIndexSnapshotFieldDict(field, func(is segment.TermDictionary) segment.DictionaryIterator {
 		return is.AutomatonIterator(nil, termPrefix, termPrefixEnd)
@@ -264,18 +266,21 @@ func (is *IndexSnapshot) FieldDictPrefix(field string,
 }
 
 func (is *IndexSnapshot) FieldDictRegexp(field string,
-	termRegex string) (index.FieldDict, error) {
+	termRegex string,
+) (index.FieldDict, error) {
 	fd, _, err := is.FieldDictRegexpAutomaton(field, termRegex)
 	return fd, err
 }
 
 func (is *IndexSnapshot) FieldDictRegexpAutomaton(field string,
-	termRegex string) (index.FieldDict, index.RegexAutomaton, error) {
+	termRegex string,
+) (index.FieldDict, index.RegexAutomaton, error) {
 	return is.fieldDictRegexp(field, termRegex)
 }
 
 func (is *IndexSnapshot) fieldDictRegexp(field string,
-	termRegex string) (index.FieldDict, index.RegexAutomaton, error) {
+	termRegex string,
+) (index.FieldDict, index.RegexAutomaton, error) {
 	// TODO: potential optimization where the literal prefix represents the,
 	//       entire regexp, allowing us to use PrefixIterator(prefixTerm)?
 
@@ -294,7 +299,8 @@ func (is *IndexSnapshot) fieldDictRegexp(field string,
 }
 
 func (is *IndexSnapshot) getLevAutomaton(term string,
-	fuzziness uint8) (vellum.Automaton, error) {
+	fuzziness uint8,
+) (vellum.Automaton, error) {
 	if fuzziness == 1 {
 		return lb1.BuildDfa(term, fuzziness)
 	} else if fuzziness == 2 {
@@ -304,18 +310,21 @@ func (is *IndexSnapshot) getLevAutomaton(term string,
 }
 
 func (is *IndexSnapshot) FieldDictFuzzy(field string,
-	term string, fuzziness int, prefix string) (index.FieldDict, error) {
+	term string, fuzziness int, prefix string,
+) (index.FieldDict, error) {
 	fd, _, err := is.FieldDictFuzzyAutomaton(field, term, fuzziness, prefix)
 	return fd, err
 }
 
 func (is *IndexSnapshot) FieldDictFuzzyAutomaton(field string,
-	term string, fuzziness int, prefix string) (index.FieldDict, index.FuzzyAutomaton, error) {
+	term string, fuzziness int, prefix string,
+) (index.FieldDict, index.FuzzyAutomaton, error) {
 	return is.fieldDictFuzzy(field, term, fuzziness, prefix)
 }
 
 func (is *IndexSnapshot) fieldDictFuzzy(field string,
-	term string, fuzziness int, prefix string) (index.FieldDict, index.FuzzyAutomaton, error) {
+	term string, fuzziness int, prefix string,
+) (index.FieldDict, index.FuzzyAutomaton, error) {
 	a, err := is.getLevAutomaton(term, uint8(fuzziness))
 	if err != nil {
 		return nil, nil, err
@@ -431,7 +440,7 @@ func (is *IndexSnapshot) DocCount() (uint64, error) {
 
 func (is *IndexSnapshot) Document(id string) (rv index.Document, err error) {
 	// FIXME could be done more efficiently directly, but reusing for simplicity
-	tfr, err := is.TermFieldReader(nil, []byte(id), "_id", false, false, false)
+	tfr, err := is.TermFieldReader(context.TODO(), []byte(id), "_id", false, false, false)
 	if err != nil {
 		return nil, err
 	}
@@ -557,7 +566,7 @@ func (is *IndexSnapshot) ExternalID(id index.IndexInternalID) (string, error) {
 
 func (is *IndexSnapshot) InternalID(id string) (rv index.IndexInternalID, err error) {
 	// FIXME could be done more efficiently directly, but reusing for simplicity
-	tfr, err := is.TermFieldReader(nil, []byte(id), "_id", false, false, false)
+	tfr, err := is.TermFieldReader(context.TODO(), []byte(id), "_id", false, false, false)
 	if err != nil {
 		return nil, err
 	}
@@ -576,7 +585,8 @@ func (is *IndexSnapshot) InternalID(id string) (rv index.IndexInternalID, err er
 }
 
 func (is *IndexSnapshot) TermFieldReader(ctx context.Context, term []byte, field string, includeFreq,
-	includeNorm, includeTermVectors bool) (index.TermFieldReader, error) {
+	includeNorm, includeTermVectors bool,
+) (index.TermFieldReader, error) {
 	rv := is.allocTermFieldReaderDicts(field)
 
 	rv.ctx = ctx
@@ -743,7 +753,8 @@ func docInternalToNumber(in index.IndexInternalID) (uint64, error) {
 func (is *IndexSnapshot) documentVisitFieldTermsOnSegment(
 	segmentIndex int, localDocNum uint64, fields []string, cFields []string,
 	visitor index.DocValueVisitor, dvs segment.DocVisitState) (
-	cFieldsOut []string, dvsOut segment.DocVisitState, err error) {
+	cFieldsOut []string, dvsOut segment.DocVisitState, err error,
+) {
 	ss := is.segment[segmentIndex]
 
 	var vFields []string // fields that are visitable via the segment
@@ -800,7 +811,8 @@ func (is *IndexSnapshot) documentVisitFieldTermsOnSegment(
 }
 
 func (is *IndexSnapshot) DocValueReader(fields []string) (
-	index.DocValueReader, error) {
+	index.DocValueReader, error,
+) {
 	return &DocValueReader{i: is, fields: fields, currSegmentIndex: -1}, nil
 }
 
@@ -821,7 +833,8 @@ func (dvr *DocValueReader) BytesRead() uint64 {
 }
 
 func (dvr *DocValueReader) VisitDocValues(id index.IndexInternalID,
-	visitor index.DocValueVisitor) (err error) {
+	visitor index.DocValueVisitor,
+) (err error) {
 	docNum, err := docInternalToNumber(id)
 	if err != nil {
 		return err
@@ -929,7 +942,7 @@ func (is *IndexSnapshot) CopyTo(d index.Directory) error {
 		return fmt.Errorf("invalid root.bolt file found")
 	}
 
-	copyBolt, err := bolt.Open(rootFile.Name(), 0600, nil)
+	copyBolt, err := bolt.Open(rootFile.Name(), 0o600, nil)
 	if err != nil {
 		return err
 	}
@@ -966,7 +979,8 @@ func (is *IndexSnapshot) UpdateIOStats(val uint64) {
 }
 
 func (is *IndexSnapshot) GetSpatialAnalyzerPlugin(typ string) (
-	index.SpatialAnalyzerPlugin, error) {
+	index.SpatialAnalyzerPlugin, error,
+) {
 	var rv index.SpatialAnalyzerPlugin
 	is.m.Lock()
 	rv = is.parent.spatialPlugin
@@ -1041,8 +1055,8 @@ func (is *IndexSnapshot) ThesaurusTermReader(ctx context.Context, thesaurusName
 }
 
 func (is *IndexSnapshot) newIndexSnapshotThesaurusKeys(name string,
-	makeItr func(i segment.Thesaurus) segment.ThesaurusIterator) (*IndexSnapshotThesaurusKeys, error) {
-
+	makeItr func(i segment.Thesaurus) segment.ThesaurusIterator,
+) (*IndexSnapshotThesaurusKeys, error) {
 	results := make(chan *asynchSegmentResult, len(is.segment))
 	var wg sync.WaitGroup
 	wg.Add(len(is.segment))
@@ -1101,7 +1115,8 @@ func (is *IndexSnapshot) ThesaurusKeys(name string) (index.ThesaurusKeys, error)
 }
 
 func (is *IndexSnapshot) ThesaurusKeysFuzzy(name string,
-	term string, fuzziness int, prefix string) (index.ThesaurusKeys, error) {
+	term string, fuzziness int, prefix string,
+) (index.ThesaurusKeys, error) {
 	a, err := is.getLevAutomaton(term, uint8(fuzziness))
 	if err != nil {
 		return nil, err
@@ -1117,7 +1132,8 @@ func (is *IndexSnapshot) ThesaurusKeysFuzzy(name string,
 }
 
 func (is *IndexSnapshot) ThesaurusKeysPrefix(name string,
-	termPrefix []byte) (index.ThesaurusKeys, error) {
+	termPrefix []byte,
+) (index.ThesaurusKeys, error) {
 	termPrefixEnd := calculateExclusiveEndFromPrefix(termPrefix)
 	return is.newIndexSnapshotThesaurusKeys(name, func(is segment.Thesaurus) segment.ThesaurusIterator {
 		return is.AutomatonIterator(nil, termPrefix, termPrefixEnd)
@@ -1125,7 +1141,8 @@ func (is *IndexSnapshot) ThesaurusKeysPrefix(name string,
 }
 
 func (is *IndexSnapshot) ThesaurusKeysRegexp(name string,
-	termRegex string) (index.ThesaurusKeys, error) {
+	termRegex string,
+) (index.ThesaurusKeys, error) {
 	a, prefixBeg, prefixEnd, err := parseRegexp(termRegex)
 	if err != nil {
 		return nil, err
diff --git a/index/scorch/snapshot_index_tfr.go b/index/scorch/snapshot_index_tfr.go
index 9f0315fa..48ba3568 100644
--- a/index/scorch/snapshot_index_tfr.go
+++ b/index/scorch/snapshot_index_tfr.go
@@ -146,7 +146,7 @@ func (i *IndexSnapshotTermFieldReader) Advance(ID index.IndexInternalID, preAllo
 	// FIXME do something better
 	// for now, if we need to seek backwards, then restart from the beginning
 	if i.currPosting != nil && bytes.Compare(i.currID, ID) >= 0 {
-		i2, err := i.snapshot.TermFieldReader(nil, i.term, i.field,
+		i2, err := i.snapshot.TermFieldReader(context.TODO(), i.term, i.field,
 			i.includeFreq, i.includeNorm, i.includeTermVectors)
 		if err != nil {
 			return nil, err
diff --git a/index/upsidedown/row.go b/index/upsidedown/row.go
index fff6d067..622db46c 100644
--- a/index/upsidedown/row.go
+++ b/index/upsidedown/row.go
@@ -26,8 +26,10 @@ import (
 	"github.com/golang/protobuf/proto"
 )
 
-var reflectStaticSizeTermFrequencyRow int
-var reflectStaticSizeTermVector int
+var (
+	reflectStaticSizeTermFrequencyRow int
+	reflectStaticSizeTermVector       int
+)
 
 func init() {
 	var tfr TermFrequencyRow
@@ -322,7 +324,6 @@ func NewDictionaryRowKV(key, value []byte) (*DictionaryRow, error) {
 		return nil, err
 	}
 	return rv, nil
-
 }
 
 func NewDictionaryRowK(key []byte) (*DictionaryRow, error) {
@@ -642,7 +643,7 @@ func (tfr *TermFrequencyRow) parseV(value []byte, includeTermVectors bool) error
 		}
 		currOffset += bytesRead
 
-		var arrayPositionsLen uint64 = 0
+		var arrayPositionsLen uint64
 		arrayPositionsLen, bytesRead = binary.Uvarint(value[currOffset:])
 		if bytesRead <= 0 {
 			return fmt.Errorf("invalid term frequency value, vector contains no arrayPositionLen")
@@ -682,7 +683,6 @@ func NewTermFrequencyRowKV(key, value []byte) (*TermFrequencyRow, error) {
 		return nil, err
 	}
 	return rv, nil
-
 }
 
 type BackIndexRow struct {
@@ -1029,7 +1029,7 @@ func visitBackIndexRow(data []byte, callback backIndexFieldTermVisitor) error {
 				return io.ErrUnexpectedEOF
 			}
 			// don't track unrecognized data
-			//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
+			// m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
 			iNdEx += skippy
 		}
 	}
@@ -1109,7 +1109,7 @@ func visitBackIndexRowFieldTerms(data []byte, callback backIndexFieldTermVisitor
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			//m.Terms = append(m.Terms, string(data[iNdEx:postIndex]))
+			// m.Terms = append(m.Terms, string(data[iNdEx:postIndex]))
 			callback(theField, data[iNdEx:postIndex])
 			iNdEx = postIndex
 		default:
@@ -1132,7 +1132,7 @@ func visitBackIndexRowFieldTerms(data []byte, callback backIndexFieldTermVisitor
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
-			//m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
+			// m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...)
 			iNdEx += skippy
 		}
 	}
diff --git a/index/upsidedown/store/moss/lower.go b/index/upsidedown/store/moss/lower.go
index ccbbc862..d52bc305 100644
--- a/index/upsidedown/store/moss/lower.go
+++ b/index/upsidedown/store/moss/lower.go
@@ -153,7 +153,8 @@ func (s *llStore) decRef() {
 // that the higher level can use which represents this lower level
 // store.
 func (s *llStore) update(ssHigher moss.Snapshot, maxBatchSize uint64) (
-	ssLower moss.Snapshot, err error) {
+	ssLower moss.Snapshot, err error,
+) {
 	if ssHigher != nil {
 		iter, err := ssHigher.StartIterator(nil, nil, moss.IteratorOptions{
 			IncludeDeletions: true,
@@ -319,9 +320,9 @@ func (llss *llSnapshot) decRef() {
 
 // ChildCollectionNames returns an array of child collection name strings.
 func (llss *llSnapshot) ChildCollectionNames() ([]string, error) {
-	var childCollections = make([]string, len(llss.childSnapshots))
+	childCollections := make([]string, len(llss.childSnapshots))
 	idx := 0
-	for name, _ := range llss.childSnapshots {
+	for name := range llss.childSnapshots {
 		childCollections[idx] = name
 		idx++
 	}
@@ -331,7 +332,8 @@ func (llss *llSnapshot) ChildCollectionNames() ([]string, error) {
 // ChildCollectionSnapshot returns a Snapshot on a given child
 // collection by its name.
 func (llss *llSnapshot) ChildCollectionSnapshot(childCollectionName string) (
-	moss.Snapshot, error) {
+	moss.Snapshot, error,
+) {
 	childSnapshot, exists := llss.childSnapshots[childCollectionName]
 	if !exists {
 		return nil, nil
@@ -347,7 +349,8 @@ func (llss *llSnapshot) Close() error {
 }
 
 func (llss *llSnapshot) Get(key []byte,
-	readOptions moss.ReadOptions) ([]byte, error) {
+	readOptions moss.ReadOptions,
+) ([]byte, error) {
 	rs, ok := llss.kvReader.(readerSource)
 	if ok {
 		r2, err := rs.Reader()
@@ -367,7 +370,8 @@ func (llss *llSnapshot) Get(key []byte,
 
 func (llss *llSnapshot) StartIterator(
 	startKeyInclusive, endKeyExclusive []byte,
-	iteratorOptions moss.IteratorOptions) (moss.Iterator, error) {
+	iteratorOptions moss.IteratorOptions,
+) (moss.Iterator, error) {
 	rs, ok := llss.kvReader.(readerSource)
 	if ok {
 		r2, err := rs.Reader()
@@ -436,14 +440,16 @@ func (lli *llIterator) Current() (key, val []byte, err error) {
 }
 
 func (lli *llIterator) CurrentEx() (
-	entryEx moss.EntryEx, key, val []byte, err error) {
+	entryEx moss.EntryEx, key, val []byte, err error,
+) {
 	return moss.EntryEx{}, nil, nil, moss.ErrUnimplemented
 }
 
 // ------------------------------------------------
 
 func InitMossStore(config map[string]interface{}, options moss.CollectionOptions) (
-	moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, statsFunc, error) {
+	moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, statsFunc, error,
+) {
 	path, ok := config["path"].(string)
 	if !ok {
 		return nil, nil, nil, nil, fmt.Errorf("lower: missing path for InitMossStore config")
@@ -452,7 +458,7 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
 		return nil, nil, nil, nil, os.ErrInvalid
 	}
 
-	err := os.MkdirAll(path, 0700)
+	err := os.MkdirAll(path, 0o700)
 	if err != nil {
 		return nil, nil, nil, nil, fmt.Errorf("lower: InitMossStore mkdir,"+
 			" path: %s, err: %v", path, err)
diff --git a/search.go b/search.go
index e13a9370..7b7fa83e 100644
--- a/search.go
+++ b/search.go
@@ -31,8 +31,10 @@ import (
 	"github.com/blevesearch/bleve/v2/util"
 )
 
-var reflectStaticSizeSearchResult int
-var reflectStaticSizeSearchStatus int
+var (
+	reflectStaticSizeSearchResult int
+	reflectStaticSizeSearchStatus int
+)
 
 func init() {
 	var sr SearchResult
@@ -497,7 +499,7 @@ func (sr *SearchResult) String() string {
 		rv = "No matches"
 	}
 	if len(sr.Facets) > 0 {
-		rv += fmt.Sprintf("Facets:\n")
+		rv += "Facets:\n"
 		for fn, f := range sr.Facets {
 			rv += fmt.Sprintf("%s(%d)\n", fn, f.Total)
 			for _, t := range f.Terms.Terms() {
diff --git a/search/facet/facet_builder_datetime.go b/search/facet/facet_builder_datetime.go
index ff5167f2..9fe4cf4c 100644
--- a/search/facet/facet_builder_datetime.go
+++ b/search/facet/facet_builder_datetime.go
@@ -24,8 +24,10 @@ import (
 	"github.com/blevesearch/bleve/v2/size"
 )
 
-var reflectStaticSizeDateTimeFacetBuilder int
-var reflectStaticSizedateTimeRange int
+var (
+	reflectStaticSizeDateTimeFacetBuilder int
+	reflectStaticSizedateTimeRange        int
+)
 
 func init() {
 	var dtfb DateTimeFacetBuilder
@@ -62,12 +64,12 @@ func (fb *DateTimeFacetBuilder) Size() int {
 	sizeInBytes := reflectStaticSizeDateTimeFacetBuilder + size.SizeOfPtr +
 		len(fb.field)
 
-	for k, _ := range fb.termsCount {
+	for k := range fb.termsCount {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfInt
 	}
 
-	for k, _ := range fb.ranges {
+	for k := range fb.ranges {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfPtr + reflectStaticSizedateTimeRange
 	}
diff --git a/search/facet/facet_builder_numeric.go b/search/facet/facet_builder_numeric.go
index f19634d7..13839428 100644
--- a/search/facet/facet_builder_numeric.go
+++ b/search/facet/facet_builder_numeric.go
@@ -23,8 +23,10 @@ import (
 	"github.com/blevesearch/bleve/v2/size"
 )
 
-var reflectStaticSizeNumericFacetBuilder int
-var reflectStaticSizenumericRange int
+var (
+	reflectStaticSizeNumericFacetBuilder int
+	reflectStaticSizenumericRange        int
+)
 
 func init() {
 	var nfb NumericFacetBuilder
@@ -61,12 +63,12 @@ func (fb *NumericFacetBuilder) Size() int {
 	sizeInBytes := reflectStaticSizeNumericFacetBuilder + size.SizeOfPtr +
 		len(fb.field)
 
-	for k, _ := range fb.termsCount {
+	for k := range fb.termsCount {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfInt
 	}
 
-	for k, _ := range fb.ranges {
+	for k := range fb.ranges {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfPtr + reflectStaticSizenumericRange
 	}
diff --git a/search/facet/facet_builder_terms.go b/search/facet/facet_builder_terms.go
index c5a1c831..ad1825c8 100644
--- a/search/facet/facet_builder_terms.go
+++ b/search/facet/facet_builder_terms.go
@@ -50,7 +50,7 @@ func (fb *TermsFacetBuilder) Size() int {
 	sizeInBytes := reflectStaticSizeTermsFacetBuilder + size.SizeOfPtr +
 		len(fb.field)
 
-	for k, _ := range fb.termsCount {
+	for k := range fb.termsCount {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfInt
 	}
diff --git a/search/query/conjunction.go b/search/query/conjunction.go
index 0565e18f..a2043720 100644
--- a/search/query/conjunction.go
+++ b/search/query/conjunction.go
@@ -49,9 +49,7 @@ func (q *ConjunctionQuery) Boost() float64 {
 }
 
 func (q *ConjunctionQuery) AddQuery(aq ...Query) {
-	for _, aaq := range aq {
-		q.Conjuncts = append(q.Conjuncts, aaq)
-	}
+	q.Conjuncts = append(q.Conjuncts, aq...)
 }
 
 func (q *ConjunctionQuery) Searcher(ctx context.Context, i index.IndexReader, m mapping.IndexMapping, options search.SearcherOptions) (search.Searcher, error) {
diff --git a/search/query/disjunction.go b/search/query/disjunction.go
index b307865f..da46478b 100644
--- a/search/query/disjunction.go
+++ b/search/query/disjunction.go
@@ -56,9 +56,7 @@ func (q *DisjunctionQuery) Boost() float64 {
 }
 
 func (q *DisjunctionQuery) AddQuery(aq ...Query) {
-	for _, aaq := range aq {
-		q.Disjuncts = append(q.Disjuncts, aaq)
-	}
+	q.Disjuncts = append(q.Disjuncts, aq...)
 }
 
 func (q *DisjunctionQuery) SetMin(m float64) {
@@ -66,7 +64,8 @@ func (q *DisjunctionQuery) SetMin(m float64) {
 }
 
 func (q *DisjunctionQuery) Searcher(ctx context.Context, i index.IndexReader, m mapping.IndexMapping,
-	options search.SearcherOptions) (search.Searcher, error) {
+	options search.SearcherOptions,
+) (search.Searcher, error) {
 	ss := make([]search.Searcher, 0, len(q.Disjuncts))
 	for _, disjunct := range q.Disjuncts {
 		sr, err := disjunct.Searcher(ctx, i, m, options)
diff --git a/search/query/query.go b/search/query/query.go
index a1f7b340..6df38da3 100644
--- a/search/query/query.go
+++ b/search/query/query.go
@@ -382,9 +382,7 @@ func ParseQuery(input []byte) (Query, error) {
 // reference queries from the input tree or new queries.
 func expandQuery(m mapping.IndexMapping, query Query) (Query, error) {
 	var expand func(query Query) (Query, error)
-	var expandSlice func(queries []Query) ([]Query, error)
-
-	expandSlice = func(queries []Query) ([]Query, error) {
+	var expandSlice func(queries []Query) ([]Query, error) = func(queries []Query) ([]Query, error) {
 		expanded := []Query{}
 		for _, q := range queries {
 			exp, err := expand(q)
@@ -518,8 +516,8 @@ const (
 // associated with the field. The synonyms are then added to the provided map.
 // The map is returned and may be nil if no synonyms were found.
 func ExtractSynonyms(ctx context.Context, m mapping.SynonymMapping, r index.ThesaurusReader,
-	query Query, rv search.FieldTermSynonymMap) (search.FieldTermSynonymMap, error) {
-
+	query Query, rv search.FieldTermSynonymMap,
+) (search.FieldTermSynonymMap, error) {
 	if r == nil || m == nil || query == nil {
 		return rv, nil
 	}
@@ -683,7 +681,8 @@ func ExtractSynonyms(ctx context.Context, m mapping.SynonymMapping, r index.Thes
 // addFuzzySynonymsForTerm finds all terms that match the given term with the
 // given fuzziness and adds their synonyms to the provided map.
 func addSynonymsForTermWithMatchType(ctx context.Context, matchType int, src, field, term string, fuzziness, prefix int,
-	r index.ThesaurusReader, rv search.FieldTermSynonymMap) (search.FieldTermSynonymMap, error) {
+	r index.ThesaurusReader, rv search.FieldTermSynonymMap,
+) (search.FieldTermSynonymMap, error) {
 	// Determine the terms based on the match type (fuzzy, prefix, or regexp)
 	var thesKeys index.ThesaurusKeys
 	var err error
@@ -751,8 +750,8 @@ func addSynonymsForTermWithMatchType(ctx context.Context, matchType int, src, fi
 }
 
 func addSynonymsForTerm(ctx context.Context, src, field, term string,
-	r index.ThesaurusReader, rv search.FieldTermSynonymMap) (search.FieldTermSynonymMap, error) {
-
+	r index.ThesaurusReader, rv search.FieldTermSynonymMap,
+) (search.FieldTermSynonymMap, error) {
 	termReader, err := r.ThesaurusTermReader(ctx, src, []byte(term))
 	if err != nil {
 		return nil, err
diff --git a/search/query/regexp.go b/search/query/regexp.go
index 6b3da955..189fd5f3 100644
--- a/search/query/regexp.go
+++ b/search/query/regexp.go
@@ -69,12 +69,9 @@ func (q *RegexpQuery) Searcher(ctx context.Context, i index.IndexReader, m mappi
 	// known to interfere with LiteralPrefix() the way ^ does
 	// and removing $ introduces possible ambiguities with escaped \$, \\$, etc
 	actualRegexp := q.Regexp
-	if strings.HasPrefix(actualRegexp, "^") {
-		actualRegexp = actualRegexp[1:] // remove leading ^
-	}
+	actualRegexp = strings.TrimPrefix(actualRegexp, "^") // remove leading ^ if it exists
 
-	return searcher.NewRegexpStringSearcher(ctx, i, actualRegexp, field,
-		q.BoostVal.Value(), options)
+	return searcher.NewRegexpStringSearcher(ctx, i, actualRegexp, field, q.BoostVal.Value(), options)
 }
 
 func (q *RegexpQuery) Validate() error {
diff --git a/search/scorer/scorer_constant.go b/search/scorer/scorer_constant.go
index 10190bd8..c030b856 100644
--- a/search/scorer/scorer_constant.go
+++ b/search/scorer/scorer_constant.go
@@ -103,7 +103,7 @@ func (s *ConstantScorer) Score(ctx *search.SearchContext, id index.IndexInternal
 		if s.options.Explain {
 			scoreExplanation = &search.Explanation{
 				Value:   score,
-				Message: fmt.Sprintf("ConstantScore()"),
+				Message: "ConstantScore()",
 			}
 		}
 
diff --git a/search/search.go b/search/search.go
index 066f8858..5c930bce 100644
--- a/search/search.go
+++ b/search/search.go
@@ -23,9 +23,11 @@ import (
 	index "github.com/blevesearch/bleve_index_api"
 )
 
-var reflectStaticSizeDocumentMatch int
-var reflectStaticSizeSearchContext int
-var reflectStaticSizeLocation int
+var (
+	reflectStaticSizeDocumentMatch int
+	reflectStaticSizeSearchContext int
+	reflectStaticSizeLocation      int
+)
 
 func init() {
 	var dm DocumentMatch
@@ -261,7 +263,7 @@ func (dm *DocumentMatch) Size() int {
 		sizeInBytes += size.SizeOfString + len(entry)
 	}
 
-	for k, _ := range dm.Fields {
+	for k := range dm.Fields {
 		sizeInBytes += size.SizeOfString + len(k) +
 			size.SizeOfPtr
 	}
diff --git a/search/searcher/search_conjunction.go b/search/searcher/search_conjunction.go
index 25e66107..57d8855e 100644
--- a/search/searcher/search_conjunction.go
+++ b/search/searcher/search_conjunction.go
@@ -47,12 +47,11 @@ type ConjunctionSearcher struct {
 
 func NewConjunctionSearcher(ctx context.Context, indexReader index.IndexReader,
 	qsearchers []search.Searcher, options search.SearcherOptions) (
-	search.Searcher, error) {
+	search.Searcher, error,
+) {
 	// build the sorted downstream searchers
 	searchers := make(OrderedSearcherList, len(qsearchers))
-	for i, searcher := range qsearchers {
-		searchers[i] = searcher
-	}
+	copy(searchers, qsearchers)
 	sort.Sort(searchers)
 
 	// attempt the "unadorned" conjunction optimization only when we
diff --git a/search/searcher/search_disjunction_slice.go b/search/searcher/search_disjunction_slice.go
index fadfa59c..6a92ffa0 100644
--- a/search/searcher/search_disjunction_slice.go
+++ b/search/searcher/search_disjunction_slice.go
@@ -52,7 +52,8 @@ type DisjunctionSliceSearcher struct {
 func newDisjunctionSliceSearcher(ctx context.Context, indexReader index.IndexReader,
 	qsearchers []search.Searcher, min float64, options search.SearcherOptions,
 	limit bool) (
-	*DisjunctionSliceSearcher, error) {
+	*DisjunctionSliceSearcher, error,
+) {
 	if limit && tooManyClauses(len(qsearchers)) {
 		return nil, tooManyClausesErr("", len(qsearchers))
 	}
@@ -79,9 +80,7 @@ func newDisjunctionSliceSearcher(ctx context.Context, indexReader index.IndexRea
 		originalPos = sortedSearchers.index
 	} else {
 		searchers = make(OrderedSearcherList, len(qsearchers))
-		for i, searcher := range qsearchers {
-			searchers[i] = searcher
-		}
+		copy(searchers, qsearchers)
 		sort.Sort(searchers)
 	}
 
@@ -210,7 +209,8 @@ func (s *DisjunctionSliceSearcher) SetQueryNorm(qnorm float64) {
 }
 
 func (s *DisjunctionSliceSearcher) Next(ctx *search.SearchContext) (
-	*search.DocumentMatch, error) {
+	*search.DocumentMatch, error,
+) {
 	if !s.initialized {
 		err := s.initSearchers(ctx)
 		if err != nil {
@@ -255,7 +255,8 @@ func (s *DisjunctionSliceSearcher) Next(ctx *search.SearchContext) (
 }
 
 func (s *DisjunctionSliceSearcher) Advance(ctx *search.SearchContext,
-	ID index.IndexInternalID) (*search.DocumentMatch, error) {
+	ID index.IndexInternalID,
+) (*search.DocumentMatch, error) {
 	if !s.initialized {
 		err := s.initSearchers(ctx)
 		if err != nil {
@@ -320,7 +321,8 @@ func (s *DisjunctionSliceSearcher) DocumentMatchPoolSize() int {
 // but only activates on an edge case where the disjunction is a
 // wrapper around a single Optimizable child searcher
 func (s *DisjunctionSliceSearcher) Optimize(kind string, octx index.OptimizableContext) (
-	index.OptimizableContext, error) {
+	index.OptimizableContext, error,
+) {
 	if len(s.searchers) == 1 {
 		o, ok := s.searchers[0].(index.Optimizable)
 		if ok {
diff --git a/search/searcher/search_geoboundingbox.go b/search/searcher/search_geoboundingbox.go
index c889ddce..f9dcf16a 100644
--- a/search/searcher/search_geoboundingbox.go
+++ b/search/searcher/search_geoboundingbox.go
@@ -26,13 +26,16 @@ import (
 
 type filterFunc func(key []byte) bool
 
-var GeoBitsShift1 = geo.GeoBits << 1
-var GeoBitsShift1Minus1 = GeoBitsShift1 - 1
+var (
+	GeoBitsShift1       = geo.GeoBits << 1
+	GeoBitsShift1Minus1 = GeoBitsShift1 - 1
+)
 
 func NewGeoBoundingBoxSearcher(ctx context.Context, indexReader index.IndexReader, minLon, minLat,
 	maxLon, maxLat float64, field string, boost float64,
 	options search.SearcherOptions, checkBoundaries bool) (
-	search.Searcher, error) {
+	search.Searcher, error,
+) {
 	if tp, ok := indexReader.(index.SpatialIndexPlugin); ok {
 		sp, err := tp.GetSpatialAnalyzerPlugin("s2")
 		if err == nil {
@@ -65,7 +68,7 @@ func NewGeoBoundingBoxSearcher(ctx context.Context, indexReader index.IndexReade
 	}
 
 	// do math to produce list of terms needed for this search
-	onBoundaryTerms, notOnBoundaryTerms, err := ComputeGeoRange(nil, 0, GeoBitsShift1Minus1,
+	onBoundaryTerms, notOnBoundaryTerms, err := ComputeGeoRange(context.TODO(), 0, GeoBitsShift1Minus1,
 		minLon, minLat, maxLon, maxLat, checkBoundaries, indexReader, field)
 	if err != nil {
 		return nil, err
@@ -122,16 +125,18 @@ func NewGeoBoundingBoxSearcher(ctx context.Context, indexReader index.IndexReade
 	return NewMatchNoneSearcher(indexReader)
 }
 
-var geoMaxShift = document.GeoPrecisionStep * 4
-var geoDetailLevel = ((geo.GeoBits << 1) - geoMaxShift) / 2
+var (
+	geoMaxShift    = document.GeoPrecisionStep * 4
+	geoDetailLevel = ((geo.GeoBits << 1) - geoMaxShift) / 2
+)
 
 type closeFunc func() error
 
 func ComputeGeoRange(ctx context.Context, term uint64, shift uint,
 	sminLon, sminLat, smaxLon, smaxLat float64, checkBoundaries bool,
 	indexReader index.IndexReader, field string) (
-	onBoundary [][]byte, notOnBoundary [][]byte, err error) {
-
+	onBoundary [][]byte, notOnBoundary [][]byte, err error,
+) {
 	isIndexed, closeF, err := buildIsIndexedFunc(ctx, indexReader, field)
 	if closeF != nil {
 		defer func() {
@@ -192,7 +197,6 @@ func buildIsIndexedFunc(ctx context.Context, indexReader index.IndexReader, fiel
 			_ = reader.Close()
 			return true
 		}
-
 	} else {
 		isIndexed = func([]byte) bool {
 			return true
@@ -202,7 +206,8 @@ func buildIsIndexedFunc(ctx context.Context, indexReader index.IndexReader, fiel
 }
 
 func buildRectFilter(ctx context.Context, dvReader index.DocValueReader, field string,
-	minLon, minLat, maxLon, maxLat float64) FilterFunc {
+	minLon, minLat, maxLon, maxLat float64,
+) FilterFunc {
 	return func(d *search.DocumentMatch) bool {
 		// check geo matches against all numeric type terms indexed
 		var lons, lats []float64
@@ -253,8 +258,7 @@ func (grc *geoRangeCompute) makePrefixCoded(in int64, shift uint) (rv numeric.Pr
 		grc.preallocBytes = make([]byte, grc.preallocBytesLen)
 	}
 
-	rv, grc.preallocBytes, _ =
-		numeric.NewPrefixCodedInt64Prealloc(in, shift, grc.preallocBytes)
+	rv, grc.preallocBytes, _ = numeric.NewPrefixCodedInt64Prealloc(in, shift, grc.preallocBytes)
 
 	return rv
 }
diff --git a/search/searcher/search_geoshape.go b/search/searcher/search_geoshape.go
index ae113107..6cd09771 100644
--- a/search/searcher/search_geoshape.go
+++ b/search/searcher/search_geoshape.go
@@ -27,7 +27,8 @@ import (
 
 func NewGeoShapeSearcher(ctx context.Context, indexReader index.IndexReader, shape index.GeoJSON,
 	relation string, field string, boost float64,
-	options search.SearcherOptions) (search.Searcher, error) {
+	options search.SearcherOptions,
+) (search.Searcher, error) {
 	var err error
 	var spatialPlugin index.SpatialAnalyzerPlugin
 
@@ -54,9 +55,7 @@ func NewGeoShapeSearcher(ctx context.Context, indexReader index.IndexReader, sha
 		return nil, err
 	}
 
-	return NewFilteringSearcher(ctx, mSearcher,
-		buildRelationFilterOnShapes(ctx, dvReader, field, relation, shape)), nil
-
+	return NewFilteringSearcher(ctx, mSearcher, buildRelationFilterOnShapes(ctx, dvReader, field, relation, shape)), nil
 }
 
 // Using the same term splitter slice used in the doc values in zap.
@@ -65,7 +64,8 @@ func NewGeoShapeSearcher(ctx context.Context, indexReader index.IndexReader, sha
 var termSeparatorSplitSlice = []byte{0xff}
 
 func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueReader, field string,
-	relation string, shape index.GeoJSON) FilterFunc {
+	relation string, shape index.GeoJSON,
+) FilterFunc {
 	// this is for accumulating the shape's actual complete value
 	// spread across multiple docvalue visitor callbacks.
 	var dvShapeValue []byte
@@ -73,8 +73,8 @@ func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueRea
 	var reader *bytes.Reader
 
 	var bufPool *s2.GeoBufferPool
-	if ctx != nil {
-		bufPool = ctx.Value(search.GeoBufferPoolCallbackKey).(search.GeoBufferPoolCallbackFunc)()
+	if bufPoolCallback, ok := ctx.Value(search.GeoBufferPoolCallbackKey).(search.GeoBufferPoolCallbackFunc); ok {
+		bufPool = bufPoolCallback()
 	}
 
 	return func(d *search.DocumentMatch) bool {
@@ -82,7 +82,6 @@ func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueRea
 
 		err := dvReader.VisitDocValues(d.IndexInternalID,
 			func(field string, term []byte) {
-
 				// only consider the values which are GlueBytes prefixed or
 				// if it had already started reading the shape bytes from previous callbacks.
 				if startReading || len(term) > geo.GlueBytesOffset {
@@ -110,11 +109,11 @@ func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueRea
 
 					// apply the filter once the entire docvalue is finished reading.
 					if finishReading {
-						v, err := geojson.FilterGeoShapesOnRelation(shape,
-							dvShapeValue, relation, &reader, bufPool)
+						v, err := geojson.FilterGeoShapesOnRelation(shape, dvShapeValue, relation, &reader, bufPool)
 						if err == nil && v {
 							found = true
 						}
+
 						dvShapeValue = dvShapeValue[:0]
 						startReading = false
 						finishReading = false
diff --git a/search/sort.go b/search/sort.go
index b13fa16c..2b757c48 100644
--- a/search/sort.go
+++ b/search/sort.go
@@ -28,8 +28,10 @@ import (
 	"github.com/blevesearch/bleve/v2/util"
 )
 
-var HighTerm = strings.Repeat(string(utf8.MaxRune), 3)
-var LowTerm = string([]byte{0x00})
+var (
+	HighTerm = strings.Repeat(string(utf8.MaxRune), 3)
+	LowTerm  = string([]byte{0x00})
+)
 
 type SearchSort interface {
 	UpdateVisitor(field string, term []byte)
@@ -47,10 +49,15 @@ type SearchSort interface {
 
 func ParseSearchSortObj(input map[string]interface{}) (SearchSort, error) {
 	descending, ok := input["desc"].(bool)
+	if !ok {
+		descending = false
+	}
+
 	by, ok := input["by"].(string)
 	if !ok {
 		return nil, fmt.Errorf("search sort must specify by")
 	}
+
 	switch by {
 	case "id":
 		return &SortDocID{
@@ -612,7 +619,8 @@ var maxDistance = string(numeric.MustNewPrefixCodedInt64(math.MaxInt64, 0))
 // NewSortGeoDistance creates SearchSort instance for sorting documents by
 // their distance from the specified point.
 func NewSortGeoDistance(field, unit string, lon, lat float64, desc bool) (
-	*SortGeoDistance, error) {
+	*SortGeoDistance, error,
+) {
 	rv := &SortGeoDistance{
 		Field: field,
 		Desc:  desc,


Test patch:
diff --git a/geo/parse_test.go b/geo/parse_test.go
index 56145564..28acc6d8 100644
--- a/geo/parse_test.go
+++ b/geo/parse_test.go
@@ -15,12 +15,12 @@
 package geo
 
 import (
+	"encoding/json"
 	"reflect"
 	"testing"
 )
 
 func TestExtractGeoPoint(t *testing.T) {
-
 	tests := []struct {
 		in      interface{}
 		lon     float64
@@ -353,3 +353,103 @@ func TestExtractGeoShape(t *testing.T) {
 		}
 	}
 }
+
+func TestExtractGeoShapeCoordinates(t *testing.T) {
+	tests := []struct {
+		x        []byte
+		typ      string
+		expectOK bool
+	}{
+		{
+			x: []byte(`[
+				[
+					[77.58894681930542,12.976498523818783],
+					[77.58677959442139,12.974533005048169],
+					[77.58894681930542,12.976498523818783]
+				]
+			]`),
+			typ:      PolygonType,
+			expectOK: true,
+		},
+		{ // Invalid construct, but handled
+			x: []byte(`[
+				[
+					{"lon":77.58894681930542,"lat":12.976498523818783},
+					{"lon":77.58677959442139,"lat":12.974533005048169},
+					{"lon":77.58894681930542,"lat":12.976498523818783}
+				]
+			]`),
+			typ:      PolygonType,
+			expectOK: false,
+		},
+		{ // Invalid construct causes panic (within extract3DCoordinates), fix MB-65807
+			x: []byte(`{
+				"coordinates": [
+					[77.58894681930542,12.976498523818783],
+					[77.58677959442139,12.974533005048169],
+					[77.58894681930542,12.976498523818783]
+				]
+			}`),
+			typ:      PolygonType,
+			expectOK: false,
+		},
+		{
+			x: []byte(`[
+				[
+					[
+						[-0.163421630859375,51.531600743186644],
+						[-0.15277862548828125,51.52455221546295],
+						[-0.15895843505859375,51.53693981046689],
+						[-0.163421630859375,51.531600743186644]
+					]
+				],
+				[
+					[
+						[-0.1902008056640625,51.5091698216777],
+						[-0.1599884033203125,51.51322956905176],
+						[-0.1902008056640625,51.5091698216777]
+					]
+				]
+			]`),
+			typ:      MultiPolygonType,
+			expectOK: true,
+		},
+		{ // Invalid construct causes panic (within extract3DCoordinates), fix MB-65807
+			x: []byte(`[
+				{
+					"coordinates": [
+						[-0.163421630859375,51.531600743186644],
+						[-0.15277862548828125,51.52455221546295],
+						[-0.15895843505859375,51.53693981046689],
+						[-0.163421630859375,51.531600743186644]
+					]
+				},
+				{
+					"coordinates": [
+						[-0.1902008056640625,51.5091698216777],
+						[-0.1599884033203125,51.51322956905176],
+						[-0.1902008056640625,51.5091698216777]
+					]
+				}
+			]`),
+			typ:      MultiPolygonType,
+			expectOK: false,
+		},
+	}
+
+	for i := range tests {
+		var x interface{}
+		if err := json.Unmarshal(tests[i].x, &x); err != nil {
+			t.Fatalf("[%d] JSON err: %v", i+1, err)
+		}
+
+		_, typ, ok := ExtractGeoShapeCoordinates(x, tests[i].typ)
+		if ok != tests[i].expectOK {
+			t.Errorf("[%d] expected ok %t, got %t", i+1, tests[i].expectOK, ok)
+		}
+
+		if ok && typ != tests[i].typ {
+			t.Errorf("[%d] expected type %s, got %s", i+1, tests[i].typ, typ)
+		}
+	}
+}
diff --git a/index/scorch/builder_test.go b/index/scorch/builder_test.go
index 92bce97f..3fac77c2 100644
--- a/index/scorch/builder_test.go
+++ b/index/scorch/builder_test.go
@@ -15,6 +15,7 @@
 package scorch
 
 import (
+	"context"
 	"fmt"
 	"os"
 	"testing"
@@ -59,7 +60,6 @@ func TestBuilder(t *testing.T) {
 	}
 
 	checkIndex(t, tmpDir, []byte("hello"), "name", 10)
-
 }
 
 func checkIndex(t *testing.T, path string, term []byte, field string, expectCount int) {
@@ -101,7 +101,7 @@ func checkIndex(t *testing.T, path string, term []byte, field string, expectCoun
 	}
 
 	// run a search for hello
-	tfr, err := r.TermFieldReader(nil, term, field, false, false, false)
+	tfr, err := r.TermFieldReader(context.TODO(), term, field, false, false, false)
 	if err != nil {
 		t.Errorf("error accessing term field reader: %v", err)
 	} else {
diff --git a/index/scorch/field_dict_test.go b/index/scorch/field_dict_test.go
index 6bca8e34..44afe26b 100644
--- a/index/scorch/field_dict_test.go
+++ b/index/scorch/field_dict_test.go
@@ -51,14 +51,12 @@ func TestIndexFieldDict(t *testing.T) {
 		}
 	}()
 
-	var expectedCount uint64
 	doc := document.NewDocument("1")
 	doc.AddField(document.NewTextField("name", []uint64{}, []byte("test")))
 	err = idx.Update(doc)
 	if err != nil {
 		t.Errorf("Error updating index: %v", err)
 	}
-	expectedCount++
 
 	doc = document.NewDocument("2")
 	doc.AddField(document.NewTextFieldWithAnalyzer("name", []uint64{}, []byte("test test test"), testAnalyzer))
@@ -68,7 +66,6 @@ func TestIndexFieldDict(t *testing.T) {
 	if err != nil {
 		t.Errorf("Error updating index: %v", err)
 	}
-	expectedCount++
 
 	indexReader, err := idx.Reader()
 	if err != nil {
diff --git a/index/scorch/reader_test.go b/index/scorch/reader_test.go
index cc33e4e7..a5233346 100644
--- a/index/scorch/reader_test.go
+++ b/index/scorch/reader_test.go
@@ -15,6 +15,7 @@
 package scorch
 
 import (
+	"context"
 	"encoding/binary"
 	"reflect"
 	"testing"
@@ -82,7 +83,7 @@ func TestIndexReader(t *testing.T) {
 	}()
 
 	// first look for a term that doesn't exist
-	reader, err := indexReader.TermFieldReader(nil, []byte("nope"), "name", true, true, true)
+	reader, err := indexReader.TermFieldReader(context.TODO(), []byte("nope"), "name", true, true, true)
 	if err != nil {
 		t.Errorf("Error accessing term field reader: %v", err)
 	}
@@ -95,12 +96,11 @@ func TestIndexReader(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	reader, err = indexReader.TermFieldReader(nil, []byte("test"), "name", true, true, true)
+	reader, err = indexReader.TermFieldReader(context.TODO(), []byte("test"), "name", true, true, true)
 	if err != nil {
 		t.Errorf("Error accessing term field reader: %v", err)
 	}
 
-	expectedCount = 2
 	count = reader.Count()
 	if count != expectedCount {
 		t.Errorf("Expected doc count to be: %d got: %d", expectedCount, count)
@@ -145,7 +145,7 @@ func TestIndexReader(t *testing.T) {
 			},
 		},
 	}
-	tfr, err := indexReader.TermFieldReader(nil, []byte("rice"), "desc", true, true, true)
+	tfr, err := indexReader.TermFieldReader(context.TODO(), []byte("rice"), "desc", true, true, true)
 	if err != nil {
 		t.Errorf("unexpected error: %v", err)
 	}
@@ -163,7 +163,7 @@ func TestIndexReader(t *testing.T) {
 	}
 
 	// now test usage of advance
-	reader, err = indexReader.TermFieldReader(nil, []byte("test"), "name", true, true, true)
+	reader, err = indexReader.TermFieldReader(context.TODO(), []byte("test"), "name", true, true, true)
 	if err != nil {
 		t.Errorf("Error accessing term field reader: %v", err)
 	}
@@ -194,7 +194,7 @@ func TestIndexReader(t *testing.T) {
 	}
 
 	// now test creating a reader for a field that doesn't exist
-	reader, err = indexReader.TermFieldReader(nil, []byte("water"), "doesnotexist", true, true, true)
+	reader, err = indexReader.TermFieldReader(context.TODO(), []byte("water"), "doesnotexist", true, true, true)
 	if err != nil {
 		t.Errorf("Error accessing term field reader: %v", err)
 	}
@@ -216,7 +216,6 @@ func TestIndexReader(t *testing.T) {
 	if match != nil {
 		t.Errorf("expected nil, got %v", match)
 	}
-
 }
 
 func TestIndexDocIdReader(t *testing.T) {
@@ -290,10 +289,17 @@ func TestIndexDocIdReader(t *testing.T) {
 	}()
 
 	id, err := reader.Next()
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	count := uint64(0)
 	for id != nil {
 		count++
 		id, err = reader.Next()
+		if err != nil {
+			t.Fatal(err)
+		}
 	}
 	if count != expectedCount {
 		t.Errorf("expected %d, got %d", expectedCount, count)
@@ -418,6 +424,10 @@ func TestIndexDocIdOnlyReader(t *testing.T) {
 	}()
 
 	id, err := reader.Next()
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	count := uint64(0)
 	for id != nil {
 		count++
@@ -478,10 +488,17 @@ func TestIndexDocIdOnlyReader(t *testing.T) {
 	}()
 
 	id, err = reader3.Next()
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	count = uint64(0)
 	for id != nil {
 		count++
 		id, err = reader3.Next()
+		if err != nil {
+			t.Fatal(err)
+		}
 	}
 	if count != 1 {
 		t.Errorf("expected 1, got %d", count)
@@ -568,7 +585,6 @@ func TestIndexDocIdOnlyReader(t *testing.T) {
 	// if !id.Equals(index.IndexInternalID("9")) {
 	// 	t.Errorf("expected to find id '9', got '%s'", id)
 	// }
-
 }
 
 func TestSegmentIndexAndLocalDocNumFromGlobal(t *testing.T) {
diff --git a/search/collector/topn_test.go b/search/collector/topn_test.go
index 31aef633..39f6a11d 100644
--- a/search/collector/topn_test.go
+++ b/search/collector/topn_test.go
@@ -26,7 +26,6 @@ import (
 )
 
 func TestTop10Scores(t *testing.T) {
-
 	// a stub search with more than 10 matches
 	// the top-10 scores are > 10
 	// everything else is less than 10
@@ -135,7 +134,6 @@ func TestTop10Scores(t *testing.T) {
 }
 
 func TestTop10ScoresSkip10(t *testing.T) {
-
 	// a stub search with more than 10 matches
 	// the top-10 scores are > 10
 	// everything else is less than 10
@@ -232,7 +230,6 @@ func TestTop10ScoresSkip10(t *testing.T) {
 }
 
 func TestTop10ScoresSkip10Only9Hits(t *testing.T) {
-
 	// a stub search with only 10 matches
 	searcher := &stubSearcher{
 		matches: []*search.DocumentMatch{
@@ -294,7 +291,6 @@ func TestTop10ScoresSkip10Only9Hits(t *testing.T) {
 }
 
 func TestPaginationSameScores(t *testing.T) {
-
 	// a stub search with more than 10 matches
 	// all documents have the same score
 	searcher := &stubSearcher{
@@ -551,14 +547,11 @@ func TestStreamResults(t *testing.T) {
 		return nil
 	}
 
-	var handlerMaker search.MakeDocumentMatchHandler
-	handlerMaker = func(ctx *search.SearchContext) (search.DocumentMatchHandler,
-		bool, error) {
+	var handlerMaker search.MakeDocumentMatchHandler = func(ctx *search.SearchContext) (search.DocumentMatchHandler, bool, error) {
 		return docMatchHandler, false, nil
 	}
 
-	ctx := context.WithValue(context.Background(), search.MakeDocumentMatchHandlerKey,
-		handlerMaker)
+	ctx := context.WithValue(context.Background(), search.MakeDocumentMatchHandlerKey, handlerMaker)
 
 	collector := NewTopNCollector(10, 0, search.SortOrder{&search.SortScore{Desc: true}})
 	err := collector.Collect(ctx, searcher, &stubReader{})
@@ -674,9 +667,7 @@ func TestCollectorChaining(t *testing.T) {
 		return nil
 	}
 
-	var handlerMaker search.MakeDocumentMatchHandler
-	handlerMaker = func(ctx *search.SearchContext) (search.DocumentMatchHandler,
-		bool, error) {
+	var handlerMaker search.MakeDocumentMatchHandler = func(ctx *search.SearchContext) (search.DocumentMatchHandler, bool, error) {
 		topNHandler, _, _ = MakeTopNDocumentMatchHandler(ctx)
 		return docMatchHandler, false, nil
 	}
diff --git a/search/searcher/geoshape_contains_test.go b/search/searcher/geoshape_contains_test.go
index fe5b4273..01c043a1 100644
--- a/search/searcher/geoshape_contains_test.go
+++ b/search/searcher/geoshape_contains_test.go
@@ -91,21 +91,18 @@ func TestPointPolygonContains(t *testing.T) {
 	i := setupIndex(t)
 
 	for _, test := range tests {
-		indexReader, closeFn, err := testCaseSetup(t, test.DocShapeName, "polygon",
-			[][][][]float64{test.DocShapeVertices}, i)
+		indexReader, closeFn, err := testCaseSetup(t, test.DocShapeName, "polygon", [][][][]float64{test.DocShapeVertices}, i)
 		if err != nil {
 			t.Error(err.Error())
 		}
 
 		t.Run(test.Desc, func(t *testing.T) {
-			got, err := runGeoShapePointRelationQuery(test.QueryType,
-				false, indexReader, [][]float64{test.QueryShape}, "geometry")
+			got, err := runGeoShapePointRelationQuery(test.QueryType, false, indexReader, [][]float64{test.QueryShape}, "geometry")
 			if err != nil {
 				t.Error(err.Error())
 			}
 			if !reflect.DeepEqual(got, test.Expected) {
-				t.Errorf("expected %v, got %v for point: %+v",
-					test.Expected, got, test.QueryShape)
+				t.Errorf("expected %v, got %v for point: %+v", test.Expected, got, test.QueryShape)
 			}
 		})
 
diff --git a/search/searcher/search_disjunction_test.go b/search/searcher/search_disjunction_test.go
index ed69bc04..fe219c80 100644
--- a/search/searcher/search_disjunction_test.go
+++ b/search/searcher/search_disjunction_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"testing"
 
 	"github.com/blevesearch/bleve/v2/search"
@@ -22,7 +23,6 @@ import (
 )
 
 func TestDisjunctionSearch(t *testing.T) {
-
 	twoDocIndexReader, err := twoDocIndex.Reader()
 	if err != nil {
 		t.Error(err)
@@ -36,37 +36,37 @@ func TestDisjunctionSearch(t *testing.T) {
 
 	explainTrue := search.SearcherOptions{Explain: true}
 
-	martyTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "marty", "name", 1.0, explainTrue)
+	martyTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "marty", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	dustinTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
+	dustinTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	martyOrDustinSearcher, err := NewDisjunctionSearcher(nil, twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher}, 0, explainTrue)
+	martyOrDustinSearcher, err := NewDisjunctionSearcher(context.TODO(), twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher}, 0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	martyTermSearcher2, err := NewTermSearcher(nil, twoDocIndexReader, "marty", "name", 1.0, explainTrue)
+	martyTermSearcher2, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "marty", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	dustinTermSearcher2, err := NewTermSearcher(nil, twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
+	dustinTermSearcher2, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	martyOrDustinSearcher2, err := NewDisjunctionSearcher(nil, twoDocIndexReader, []search.Searcher{martyTermSearcher2, dustinTermSearcher2}, 0, explainTrue)
+	martyOrDustinSearcher2, err := NewDisjunctionSearcher(context.TODO(), twoDocIndexReader, []search.Searcher{martyTermSearcher2, dustinTermSearcher2}, 0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	raviTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "ravi", "name", 1.0, explainTrue)
+	raviTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "ravi", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	nestedRaviOrMartyOrDustinSearcher, err := NewDisjunctionSearcher(nil, twoDocIndexReader, []search.Searcher{raviTermSearcher, martyOrDustinSearcher2}, 0, explainTrue)
+	nestedRaviOrMartyOrDustinSearcher, err := NewDisjunctionSearcher(context.TODO(), twoDocIndexReader, []search.Searcher{raviTermSearcher, martyOrDustinSearcher2}, 0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -145,7 +145,6 @@ func TestDisjunctionSearch(t *testing.T) {
 }
 
 func TestDisjunctionAdvance(t *testing.T) {
-
 	twoDocIndexReader, err := twoDocIndex.Reader()
 	if err != nil {
 		t.Error(err)
@@ -159,15 +158,15 @@ func TestDisjunctionAdvance(t *testing.T) {
 
 	explainTrue := search.SearcherOptions{Explain: true}
 
-	martyTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "marty", "name", 1.0, explainTrue)
+	martyTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "marty", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	dustinTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
+	dustinTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	martyOrDustinSearcher, err := NewDisjunctionSearcher(nil, twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher}, 0, explainTrue)
+	martyOrDustinSearcher, err := NewDisjunctionSearcher(context.TODO(), twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher}, 0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -185,7 +184,6 @@ func TestDisjunctionAdvance(t *testing.T) {
 }
 
 func TestDisjunctionSearchTooMany(t *testing.T) {
-
 	// set to max to a low non-zero value
 	DisjunctionMaxClauseCount = 2
 	defer func() {
@@ -206,19 +204,19 @@ func TestDisjunctionSearchTooMany(t *testing.T) {
 
 	explainTrue := search.SearcherOptions{Explain: true}
 
-	martyTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "marty", "name", 1.0, explainTrue)
+	martyTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "marty", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	dustinTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
+	dustinTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "dustin", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	steveTermSearcher, err := NewTermSearcher(nil, twoDocIndexReader, "steve", "name", 1.0, explainTrue)
+	steveTermSearcher, err := NewTermSearcher(context.TODO(), twoDocIndexReader, "steve", "name", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
-	_, err = NewDisjunctionSearcher(nil, twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher, steveTermSearcher}, 0, explainTrue)
+	_, err = NewDisjunctionSearcher(context.TODO(), twoDocIndexReader, []search.Searcher{martyTermSearcher, dustinTermSearcher, steveTermSearcher}, 0, explainTrue)
 	if err == nil {
 		t.Fatal(err)
 	}
diff --git a/search/searcher/search_docid_test.go b/search/searcher/search_docid_test.go
index 7727de7f..65fedc69 100644
--- a/search/searcher/search_docid_test.go
+++ b/search/searcher/search_docid_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"testing"
 
 	"github.com/blevesearch/bleve/v2/document"
@@ -61,7 +62,7 @@ func testDocIDSearcher(t *testing.T, indexed, searched, wanted []string) {
 
 	explainOff := search.SearcherOptions{Explain: false}
 
-	searcher, err := NewDocIDSearcher(nil, indexReader, searched, 1.0, explainOff)
+	searcher, err := NewDocIDSearcher(context.TODO(), indexReader, searched, 1.0, explainOff)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/search/searcher/search_fuzzy_test.go b/search/searcher/search_fuzzy_test.go
index e6d4c2e4..f6c2b794 100644
--- a/search/searcher/search_fuzzy_test.go
+++ b/search/searcher/search_fuzzy_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"testing"
 
 	"github.com/blevesearch/bleve/v2/search"
@@ -36,22 +37,22 @@ func TestFuzzySearch(t *testing.T) {
 
 	explainTrue := search.SearcherOptions{Explain: true}
 
-	fuzzySearcherbeet, err := NewFuzzySearcher(nil, twoDocIndexReader, "beet", 0, 1, "desc", 1.0, explainTrue)
+	fuzzySearcherbeet, err := NewFuzzySearcher(context.TODO(), twoDocIndexReader, "beet", 0, 1, "desc", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	fuzzySearcherdouches, err := NewFuzzySearcher(nil, twoDocIndexReader, "douches", 0, 2, "desc", 1.0, explainTrue)
+	fuzzySearcherdouches, err := NewFuzzySearcher(context.TODO(), twoDocIndexReader, "douches", 0, 2, "desc", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	fuzzySearcheraplee, err := NewFuzzySearcher(nil, twoDocIndexReader, "aplee", 0, 2, "desc", 1.0, explainTrue)
+	fuzzySearcheraplee, err := NewFuzzySearcher(context.TODO(), twoDocIndexReader, "aplee", 0, 2, "desc", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	fuzzySearcherprefix, err := NewFuzzySearcher(nil, twoDocIndexReader, "water", 3, 2, "desc", 1.0, explainTrue)
+	fuzzySearcherprefix, err := NewFuzzySearcher(context.TODO(), twoDocIndexReader, "water", 3, 2, "desc", 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -143,12 +144,12 @@ func TestFuzzySearch(t *testing.T) {
 
 func TestFuzzySearchLimitErrors(t *testing.T) {
 	explainTrue := search.SearcherOptions{Explain: true}
-	_, err := NewFuzzySearcher(nil, nil, "water", 3, 3, "desc", 1.0, explainTrue)
+	_, err := NewFuzzySearcher(context.TODO(), nil, "water", 3, 3, "desc", 1.0, explainTrue)
 	if err == nil {
 		t.Fatal("`fuzziness exceeds max (2)` error expected")
 	}
 
-	_, err = NewFuzzySearcher(nil, nil, "water", 3, -1, "desc", 1.0, explainTrue)
+	_, err = NewFuzzySearcher(context.TODO(), nil, "water", 3, -1, "desc", 1.0, explainTrue)
 	if err == nil {
 		t.Fatal("`invalid fuzziness, negative` error expected")
 	}
diff --git a/search/searcher/search_geoboundingbox_test.go b/search/searcher/search_geoboundingbox_test.go
index 5f190796..4715b5ba 100644
--- a/search/searcher/search_geoboundingbox_test.go
+++ b/search/searcher/search_geoboundingbox_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -28,7 +29,6 @@ import (
 )
 
 func TestGeoBoundingBox(t *testing.T) {
-
 	tests := []struct {
 		minLon float64
 		minLat float64
@@ -73,7 +73,7 @@ func TestGeoBoundingBox(t *testing.T) {
 
 func testGeoBoundingBoxSearch(i index.IndexReader, minLon, minLat, maxLon, maxLat float64, field string) ([]string, error) {
 	var rv []string
-	gbs, err := NewGeoBoundingBoxSearcher(nil, i, minLon, minLat, maxLon, maxLat, field, 1.0, search.SearcherOptions{}, true)
+	gbs, err := NewGeoBoundingBoxSearcher(context.TODO(), i, minLon, minLat, maxLon, maxLat, field, 1.0, search.SearcherOptions{}, true)
 	if err != nil {
 		return nil, err
 	}
@@ -92,7 +92,6 @@ func testGeoBoundingBoxSearch(i index.IndexReader, minLon, minLat, maxLon, maxLa
 }
 
 func setupGeo(t *testing.T) index.Index {
-
 	analysisQueue := index.NewAnalysisQueue(1)
 	i, err := upsidedown.NewUpsideDownCouch(
 		gtreap.Name,
@@ -184,7 +183,7 @@ func TestComputeGeoRange(t *testing.T) {
 	}
 
 	for testi, test := range tests {
-		onBoundaryRes, offBoundaryRes, err := ComputeGeoRange(nil, 0, GeoBitsShift1Minus1,
+		onBoundaryRes, offBoundaryRes, err := ComputeGeoRange(context.TODO(), 0, GeoBitsShift1Minus1,
 			-1.0*test.degs, -1.0*test.degs, test.degs, test.degs, true, nil, "")
 		if (err != nil) != (test.err != "") {
 			t.Errorf("test: %+v, err: %v", test, err)
@@ -238,14 +237,14 @@ func BenchmarkComputeGeoRange100(b *testing.B) {
 // --------------------------------------------------------------------
 
 func benchmarkComputeGeoRange(b *testing.B,
-	minLon, minLat, maxLon, maxLat float64, onBoundary, offBoundary int) {
+	minLon, minLat, maxLon, maxLat float64, onBoundary, offBoundary int,
+) {
 	checkBoundaries := true
 
 	b.ResetTimer()
 
 	for i := 0; i < b.N; i++ {
-		onBoundaryRes, offBoundaryRes, err :=
-			ComputeGeoRange(nil, 0, GeoBitsShift1Minus1, minLon, minLat, maxLon, maxLat, checkBoundaries, nil, "")
+		onBoundaryRes, offBoundaryRes, err := ComputeGeoRange(context.TODO(), 0, GeoBitsShift1Minus1, minLon, minLat, maxLon, maxLat, checkBoundaries, nil, "")
 		if err != nil {
 			b.Fatalf("expected no err")
 		}
@@ -261,7 +260,8 @@ func benchmarkComputeGeoRange(b *testing.B,
 func origComputeGeoRange(term uint64, shift uint,
 	sminLon, sminLat, smaxLon, smaxLat float64,
 	checkBoundaries bool) (
-	onBoundary [][]byte, notOnBoundary [][]byte) {
+	onBoundary [][]byte, notOnBoundary [][]byte,
+) {
 	split := term | uint64(0x1)<<shift
 	var upperMax uint64
 	if shift < 63 {
@@ -283,7 +283,8 @@ func origComputeGeoRange(term uint64, shift uint,
 func origRelateAndRecurse(start, end uint64, res uint,
 	sminLon, sminLat, smaxLon, smaxLat float64,
 	checkBoundaries bool) (
-	onBoundary [][]byte, notOnBoundary [][]byte) {
+	onBoundary [][]byte, notOnBoundary [][]byte,
+) {
 	minLon := geo.MortonUnhashLon(start)
 	minLat := geo.MortonUnhashLat(start)
 	maxLon := geo.MortonUnhashLon(end)
diff --git a/search/searcher/search_geopointdistance_test.go b/search/searcher/search_geopointdistance_test.go
index 22394348..20f65c8d 100644
--- a/search/searcher/search_geopointdistance_test.go
+++ b/search/searcher/search_geopointdistance_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -24,7 +25,6 @@ import (
 )
 
 func TestGeoPointDistanceSearcher(t *testing.T) {
-
 	tests := []struct {
 		centerLon float64
 		centerLat float64
@@ -66,7 +66,7 @@ func TestGeoPointDistanceSearcher(t *testing.T) {
 
 func testGeoPointDistanceSearch(i index.IndexReader, centerLon, centerLat, dist float64, field string) ([]string, error) {
 	var rv []string
-	gds, err := NewGeoPointDistanceSearcher(nil, i, centerLon, centerLat, dist, field, 1.0, search.SearcherOptions{})
+	gds, err := NewGeoPointDistanceSearcher(context.TODO(), i, centerLon, centerLat, dist, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -110,9 +110,10 @@ func TestGeoPointDistanceCompare(t *testing.T) {
 	for testi, test := range tests {
 		// compares the results from ComputeGeoRange with original, non-optimized version
 		compare := func(desc string,
-			minLon, minLat, maxLon, maxLat float64, checkBoundaries bool) {
+			minLon, minLat, maxLon, maxLat float64, checkBoundaries bool,
+		) {
 			// do math to produce list of terms needed for this search
-			onBoundaryRes, offBoundaryRes, err := ComputeGeoRange(nil, 0, GeoBitsShift1Minus1,
+			onBoundaryRes, offBoundaryRes, err := ComputeGeoRange(context.TODO(), 0, GeoBitsShift1Minus1,
 				minLon, minLat, maxLon, maxLat, checkBoundaries, nil, "")
 			if err != nil {
 				t.Fatal(err)
@@ -136,8 +137,7 @@ func TestGeoPointDistanceCompare(t *testing.T) {
 			t.Fatal(err)
 		}
 
-		topLeftLon, topLeftLat, bottomRightLon, bottomRightLat, err :=
-			geo.RectFromPointDistance(test.centerLon, test.centerLat, dist)
+		topLeftLon, topLeftLat, bottomRightLon, bottomRightLat, err := geo.RectFromPointDistance(test.centerLon, test.centerLat, dist)
 		if err != nil {
 			t.Fatal(err)
 		}
diff --git a/search/searcher/search_geopolygon_test.go b/search/searcher/search_geopolygon_test.go
index 2b300be3..d7dd0e32 100644
--- a/search/searcher/search_geopolygon_test.go
+++ b/search/searcher/search_geopolygon_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -27,7 +28,6 @@ import (
 )
 
 func TestSimpleGeoPolygons(t *testing.T) {
-
 	tests := []struct {
 		polygon []geo.Point
 		field   string
@@ -63,16 +63,22 @@ func TestSimpleGeoPolygons(t *testing.T) {
 }
 
 func TestRealGeoPolygons(t *testing.T) {
-
 	tests := []struct {
 		polygon []geo.Point
 		field   string
 		want    []string
 	}{
-		{[]geo.Point{{Lon: -80.881, Lat: 35.282}, {Lon: -80.858, Lat: 35.281},
-			{Lon: -80.864, Lat: 35.270}}, "loc", []string{"k", "l"}},
-		{[]geo.Point{{Lon: -82.467, Lat: 36.356}, {Lon: -78.127, Lat: 36.321}, {Lon: -80.555, Lat: 32.932},
-			{Lon: -84.807, Lat: 33.111}}, "loc", []string{"k", "l", "m"}},
+		{[]geo.Point{
+			{Lon: -80.881, Lat: 35.282},
+			{Lon: -80.858, Lat: 35.281},
+			{Lon: -80.864, Lat: 35.270},
+		}, "loc", []string{"k", "l"}},
+		{[]geo.Point{
+			{Lon: -82.467, Lat: 36.356},
+			{Lon: -78.127, Lat: 36.321},
+			{Lon: -80.555, Lat: 32.932},
+			{Lon: -84.807, Lat: 33.111},
+		}, "loc", []string{"k", "l", "m"}},
 		// same polygon vertices
 		{[]geo.Point{{Lon: -82.467, Lat: 36.356}, {Lon: -82.467, Lat: 36.356}, {Lon: -82.467, Lat: 36.356}, {Lon: -82.467, Lat: 36.356}}, "loc", nil},
 		// non-overlaping polygon
@@ -81,11 +87,20 @@ func TestRealGeoPolygons(t *testing.T) {
 		{[]geo.Point{{Lon: -71.65, Lat: 42.446}, {Lon: -71.649, Lat: 42.428}, {Lon: -71.640, Lat: 42.445}, {Lon: -71.649, Lat: 42.435}}, "loc", nil},
 		// V like concave polygon with a document 'p' residing inside the bottom corner
 		{[]geo.Point{{Lon: -80.304, Lat: 40.740}, {Lon: -80.038, Lat: 40.239}, {Lon: -79.562, Lat: 40.786}, {Lon: -80.018, Lat: 40.328}}, "loc", []string{"p"}},
-		{[]geo.Point{{Lon: -111.918, Lat: 33.515}, {Lon: -111.938, Lat: 33.494}, {Lon: -111.944, Lat: 33.481}, {Lon: -111.886, Lat: 33.517},
-			{Lon: -111.919, Lat: 33.468}, {Lon: -111.929, Lat: 33.508}}, "loc", []string{"q"}},
+		{[]geo.Point{
+			{Lon: -111.918, Lat: 33.515},
+			{Lon: -111.938, Lat: 33.494},
+			{Lon: -111.944, Lat: 33.481},
+			{Lon: -111.886, Lat: 33.517},
+			{Lon: -111.919, Lat: 33.468},
+			{Lon: -111.929, Lat: 33.508},
+		}, "loc", []string{"q"}},
 		// real points near cb bangalore
-		{[]geo.Point{{Lat: 12.974872, Lon: 77.607749}, {Lat: 12.971725, Lon: 77.610110},
-			{Lat: 12.972530, Lon: 77.606912}, {Lat: 12.975112, Lon: 77.603780},
+		{[]geo.Point{
+			{Lat: 12.974872, Lon: 77.607749},
+			{Lat: 12.971725, Lon: 77.610110},
+			{Lat: 12.972530, Lon: 77.606912},
+			{Lat: 12.975112, Lon: 77.603780},
 		}, "loc", []string{"amoeba", "communiti"}},
 	}
 
@@ -113,13 +128,14 @@ func TestRealGeoPolygons(t *testing.T) {
 }
 
 func TestGeoRectanglePolygon(t *testing.T) {
-
 	tests := []struct {
 		polygon []geo.Point
 		field   string
 		want    []string
 	}{
-		{[]geo.Point{{Lon: 0, Lat: 0}, {Lon: 0, Lat: 50}, {Lon: 50, Lat: 50}, {Lon: 50, Lat: 0}, {Lon: 0, Lat: 0}}, "loc",
+		{
+			[]geo.Point{{Lon: 0, Lat: 0}, {Lon: 0, Lat: 50}, {Lon: 50, Lat: 50}, {Lon: 50, Lat: 0}, {Lon: 0, Lat: 0}},
+			"loc",
 			[]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"},
 		},
 	}
@@ -149,7 +165,7 @@ func TestGeoRectanglePolygon(t *testing.T) {
 
 func testGeoPolygonSearch(i index.IndexReader, polygon []geo.Point, field string) ([]string, error) {
 	var rv []string
-	gbs, err := NewGeoBoundedPolygonSearcher(nil, i, polygon, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoBoundedPolygonSearcher(context.TODO(), i, polygon, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -285,7 +301,6 @@ type geoPoint struct {
 
 // Test points inside a complex self intersecting polygon
 func TestComplexGeoPolygons(t *testing.T) {
-
 	tests := []struct {
 		polygon []geo.Point
 		points  []geoPoint
@@ -299,11 +314,26 @@ func TestComplexGeoPolygons(t *testing.T) {
 			     \/
 		*/
 		// a, b, c - inside and d - on vertices.
-		{[]geo.Point{{Lon: 6.0, Lat: 2.0}, {Lon: 3.0, Lat: 4.0}, {Lon: 9.0, Lat: 6.0},
-			{Lon: 3.0, Lat: 8.0}, {Lon: 6.0, Lat: 10.0}, {Lon: 6.0, Lat: 2.0}},
-			[]geoPoint{{title: "a", lon: 3, lat: 4}, {title: "b", lon: 7, lat: 6}, {title: "c", lon: 4, lat: 8.1},
-				{title: "d", lon: 6, lat: 10.0}, {title: "e", lon: 5, lat: 6}, {title: "f", lon: 7, lat: 5}},
-			"loc", []string{"a", "b", "c", "d"}},
+		{
+			[]geo.Point{
+				{Lon: 6.0, Lat: 2.0},
+				{Lon: 3.0, Lat: 4.0},
+				{Lon: 9.0, Lat: 6.0},
+				{Lon: 3.0, Lat: 8.0},
+				{Lon: 6.0, Lat: 10.0},
+				{Lon: 6.0, Lat: 2.0},
+			},
+			[]geoPoint{
+				{title: "a", lon: 3, lat: 4},
+				{title: "b", lon: 7, lat: 6},
+				{title: "c", lon: 4, lat: 8.1},
+				{title: "d", lon: 6, lat: 10.0},
+				{title: "e", lon: 5, lat: 6},
+				{title: "f", lon: 7, lat: 5},
+			},
+			"loc",
+			[]string{"a", "b", "c", "d"},
+		},
 		/*
 			____
 			\  /
@@ -311,11 +341,25 @@ func TestComplexGeoPolygons(t *testing.T) {
 			 /\
 			/__\
 		*/
-		{[]geo.Point{{Lon: 7.0, Lat: 2.0}, {Lon: 1.0, Lat: 8.0}, {Lon: 1.0, Lat: 2.0},
-			{Lon: 7.0, Lat: 8.0}, {Lon: 7.0, Lat: 2.0}},
-			[]geoPoint{{title: "a", lon: 6, lat: 5}, {title: "b", lon: 5, lat: 5}, {title: "c", lon: 3, lat: 5.0},
-				{title: "d", lon: 2, lat: 4.0}, {title: "e", lon: 5, lat: 3}, {title: "f", lon: 4, lat: 4}},
-			"loc", []string{"a", "b", "c", "d"}},
+		{
+			[]geo.Point{
+				{Lon: 7.0, Lat: 2.0},
+				{Lon: 1.0, Lat: 8.0},
+				{Lon: 1.0, Lat: 2.0},
+				{Lon: 7.0, Lat: 8.0},
+				{Lon: 7.0, Lat: 2.0},
+			},
+			[]geoPoint{
+				{title: "a", lon: 6, lat: 5},
+				{title: "b", lon: 5, lat: 5},
+				{title: "c", lon: 3, lat: 5.0},
+				{title: "d", lon: 2, lat: 4.0},
+				{title: "e", lon: 5, lat: 3},
+				{title: "f", lon: 4, lat: 4},
+			},
+			"loc",
+			[]string{"a", "b", "c", "d"},
+		},
 	}
 
 	for _, test := range tests {
diff --git a/search/searcher/search_geoshape_circle_test.go b/search/searcher/search_geoshape_circle_test.go
index a5d2b562..b4e1fb29 100644
--- a/search/searcher/search_geoshape_circle_test.go
+++ b/search/searcher/search_geoshape_circle_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -34,35 +35,63 @@ func TestGeoJsonCircleIntersectsQuery(t *testing.T) {
 		want           []string
 	}{
 		// test intersecting query circle for polygon1.
-		{[]float64{77.68115043640137, 12.94663769274367}, "200m",
-			"geometry", []string{"polygon1"}},
+		{
+			[]float64{77.68115043640137, 12.94663769274367},
+			"200m",
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test intersecting query circle for polygon1, circle1 and linestring1.
-		{[]float64{77.68115043640137, 12.94663769274367}, "750m",
-			"geometry", []string{"polygon1", "circle1", "linestring1"}},
+		{
+			[]float64{77.68115043640137, 12.94663769274367},
+			"750m",
+			"geometry",
+			[]string{"polygon1", "circle1", "linestring1"},
+		},
 
 		// test intersecting query circle for linestring2.
-		{[]float64{77.69591331481932, 12.92756503709986}, "250m",
-			"geometry", []string{"linestring2"}},
+		{
+			[]float64{77.69591331481932, 12.92756503709986},
+			"250m",
+			"geometry",
+			[]string{"linestring2"},
+		},
 
 		// test intersecting query circle for circle1.
 		{[]float64{77.6767, 12.9422}, "250m", "geometry", []string{"circle1"}},
 
 		// test intersecting query circle for point1, envelope1 and linestring3.
-		{[]float64{81.243896484375, 26.22444694563432}, "90000m",
-			"geometry", []string{"point1", "envelope1", "linestring3"}},
+		{
+			[]float64{81.243896484375, 26.22444694563432},
+			"90000m",
+			"geometry",
+			[]string{"point1", "envelope1", "linestring3"},
+		},
 
 		// test intersecting query circle for envelope.
-		{[]float64{79.98458862304688, 25.339061458818374}, "1250m",
-			"geometry", []string{"envelope1"}},
+		{
+			[]float64{79.98458862304688, 25.339061458818374},
+			"1250m",
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test intersecting query circle for multipoint.
-		{[]float64{81.87346458435059, 25.41505910223247}, "200m",
-			"geometry", []string{"multipoint1"}},
+		{
+			[]float64{81.87346458435059, 25.41505910223247},
+			"200m",
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test intersecting query circle for multilinestring.
-		{[]float64{81.8669843673706, 25.512661276952272}, "90m",
-			"geometry", []string{"multilinestring1"}},
+		{
+			[]float64{81.8669843673706, 25.512661276952272},
+			"90m",
+			"geometry",
+			[]string{"multilinestring1"},
+		},
 	}
 
 	i := setupGeoJsonShapesIndexForCircleQuery(t)
@@ -98,28 +127,52 @@ func TestGeoJsonCircleWithInQuery(t *testing.T) {
 		want           []string
 	}{
 		// test query circle containing polygon2 and multilinestring2.
-		{[]float64{81.85981750488281, 25.546778150624146}, "3700m",
-			"geometry", []string{"polygon2", "multilinestring2"}},
+		{
+			[]float64{81.85981750488281, 25.546778150624146},
+			"3700m",
+			"geometry",
+			[]string{"polygon2", "multilinestring2"},
+		},
 
 		// test query circle containing multilinestring2.
-		{[]float64{81.85981750488281, 25.546778150624146}, "3250m",
-			"geometry", []string{"multilinestring2"}},
+		{
+			[]float64{81.85981750488281, 25.546778150624146},
+			"3250m",
+			"geometry",
+			[]string{"multilinestring2"},
+		},
 
 		// test query circle containing multipoint1.
-		{[]float64{81.88599586486816, 25.425756968727935}, "1650m",
-			"geometry", []string{"multipoint1"}},
+		{
+			[]float64{81.88599586486816, 25.425756968727935},
+			"1650m",
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test query circle containing circle2.
-		{[]float64{82.09362030029297, 25.546313513788725}, "1280m",
-			"geometry", []string{"envelope2", "circle2"}},
+		{
+			[]float64{82.09362030029297, 25.546313513788725},
+			"1280m",
+			"geometry",
+			[]string{"envelope2", "circle2"},
+		},
 
 		// test query circle containing envelope2 and circle2.
-		{[]float64{82.10289001464844, 25.544919592476727}, "700m",
-			"geometry", []string{"envelope2", "circle2"}},
+		{
+			[]float64{82.10289001464844, 25.544919592476727},
+			"700m",
+			"geometry",
+			[]string{"envelope2", "circle2"},
+		},
 
 		// test query circle containing point1 and linestring3.
-		{[]float64{81.27685546875, 26.1899475672235}, "5600m",
-			"geometry", []string{"point1", "linestring3"}},
+		{
+			[]float64{81.27685546875, 26.1899475672235},
+			"5600m",
+			"geometry",
+			[]string{"point1", "linestring3"},
+		},
 	}
 
 	i := setupGeoJsonShapesIndexForCircleQuery(t)
@@ -135,14 +188,12 @@ func TestGeoJsonCircleWithInQuery(t *testing.T) {
 	}()
 
 	for n, test := range tests {
-		got, err := runGeoShapeCircleRelationQuery("within",
-			indexReader, test.centrePoint, test.radiusInMeters, test.field)
+		got, err := runGeoShapeCircleRelationQuery("within", indexReader, test.centrePoint, test.radiusInMeters, test.field)
 		if err != nil {
 			t.Fatal(err)
 		}
 		if !reflect.DeepEqual(got, test.want) {
-			t.Errorf("test %d, expected %v, got %v for polygon: %+v",
-				n, test.want, got, test.centrePoint)
+			t.Errorf("test %d, expected %v, got %v for polygon: %+v", n, test.want, got, test.centrePoint)
 		}
 	}
 }
@@ -155,20 +206,35 @@ func TestGeoJsonCircleContainsQuery(t *testing.T) {
 		want           []string
 	}{
 		// test query circle within polygon3.
-		{[]float64{8.549551963806152, 47.3759038562437}, "180m",
-			"geometry", []string{"polygon3"}},
+		{
+			[]float64{8.549551963806152, 47.3759038562437},
+			"180m",
+			"geometry",
+			[]string{"polygon3"},
+		},
 
 		// test query circle containing envelope3.
-		{[]float64{8.551011085510254, 47.380117626829275}, "75m",
-			"geometry", []string{"envelope3"}},
+		{
+			[]float64{8.551011085510254, 47.380117626829275},
+			"75m",
+			"geometry",
+			[]string{"envelope3"},
+		},
 
 		// test query circle exceeding envelope3 with a few meters.
-		{[]float64{8.551011085510254, 47.380117626829275}, "78m",
-			"geometry", nil},
+		{
+			[]float64{8.551011085510254, 47.380117626829275},
+			"78m",
+			"geometry", nil,
+		},
 
 		// test query circle containing circle3.
-		{[]float64{8.535819053649902, 47.38297989270074}, "185m",
-			"geometry", []string{"circle3"}},
+		{
+			[]float64{8.535819053649902, 47.38297989270074},
+			"185m",
+			"geometry",
+			[]string{"circle3"},
+		},
 	}
 
 	i := setupGeoJsonShapesIndexForCircleQuery(t)
@@ -197,11 +263,12 @@ func TestGeoJsonCircleContainsQuery(t *testing.T) {
 }
 
 func runGeoShapeCircleRelationQuery(relation string, i index.IndexReader,
-	points []float64, radius string, field string) ([]string, error) {
+	points []float64, radius string, field string,
+) ([]string, error) {
 	var rv []string
 	s := geo.NewGeoCircle(points, radius)
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -237,10 +304,14 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{77.67248153686523, 12.957679089615821},
-		{77.67956256866455, 12.948101542434257}, {77.68908977508545, 12.948896200093982},
-		{77.68934726715086, 12.955211547173878}, {77.68016338348389, 12.954291440344619},
-		{77.67248153686523, 12.957679089615821}}}}
+	polygon1 := [][][][]float64{{{
+		{77.67248153686523, 12.957679089615821},
+		{77.67956256866455, 12.948101542434257},
+		{77.68908977508545, 12.948896200093982},
+		{77.68934726715086, 12.955211547173878},
+		{77.68016338348389, 12.954291440344619},
+		{77.67248153686523, 12.957679089615821},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -248,10 +319,15 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 	if err != nil {
 		t.Fatal(err)
 	}
-	polygon2 := [][][][]float64{{{{81.84951782226561, 25.522692102524033},
-		{81.8557834625244, 25.521762640415535}, {81.86264991760254, 25.521762640415535},
-		{81.86676979064941, 25.521607729364224}, {81.89560890197754, 25.542673796271302},
-		{81.88977241516113, 25.543293330460937}, {81.84951782226561, 25.522692102524033}}}}
+	polygon2 := [][][][]float64{{{
+		{81.84951782226561, 25.522692102524033},
+		{81.8557834625244, 25.521762640415535},
+		{81.86264991760254, 25.521762640415535},
+		{81.86676979064941, 25.521607729364224},
+		{81.89560890197754, 25.542673796271302},
+		{81.88977241516113, 25.543293330460937},
+		{81.84951782226561, 25.522692102524033},
+	}}}
 	doc = document.NewDocument("polygon2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon2, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -260,10 +336,15 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon3 := [][][][]float64{{{{8.548071384429932, 47.379216780040124},
-		{8.547642230987549, 47.3771680227784}, {8.545818328857422, 47.37677569847655},
-		{8.546290397644043, 47.37417465983494}, {8.551719188690186, 47.37417465983494},
-		{8.553242683410645, 47.37679022905829}, {8.548071384429932, 47.379216780040124}}}}
+	polygon3 := [][][][]float64{{{
+		{8.548071384429932, 47.379216780040124},
+		{8.547642230987549, 47.3771680227784},
+		{8.545818328857422, 47.37677569847655},
+		{8.546290397644043, 47.37417465983494},
+		{8.551719188690186, 47.37417465983494},
+		{8.553242683410645, 47.37679022905829},
+		{8.548071384429932, 47.379216780040124},
+	}}}
 	doc = document.NewDocument("polygon3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon3, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -281,8 +362,10 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope1 := [][][][]float64{{{{79.9969482421875, 23.895882703682627},
-		{80.7220458984375, 25.750424835909385}}}}
+	envelope1 := [][][][]float64{{{
+		{79.9969482421875, 23.895882703682627},
+		{80.7220458984375, 25.750424835909385},
+	}}}
 	doc = document.NewDocument("envelope1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope1, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -291,8 +374,10 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope2 := [][][][]float64{{{{82.10409164428711, 25.54360309635522},
-		{82.10537910461424, 25.544609829984058}}}}
+	envelope2 := [][][][]float64{{{
+		{82.10409164428711, 25.54360309635522},
+		{82.10537910461424, 25.544609829984058},
+	}}}
 	doc = document.NewDocument("envelope2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope2, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -301,8 +386,10 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope3 := [][][][]float64{{{{8.545668125152588, 47.37942019840244},
-		{8.552148342132568, 47.383778974713124}}}}
+	envelope3 := [][][][]float64{{{
+		{8.545668125152588, 47.37942019840244},
+		{8.552148342132568, 47.383778974713124},
+	}}}
 	doc = document.NewDocument("envelope3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope3, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -331,16 +418,20 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 
 	doc = document.NewDocument("circle3")
 	doc.AddField(document.NewGeoCircleFieldWithIndexingOptions("geometry", []uint64{},
-		[]float64{8.53363037109375,
-			47.38191927423153}, "400m",
+		[]float64{
+			8.53363037109375,
+			47.38191927423153,
+		}, "400m",
 		document.DefaultGeoShapeIndexingOptions))
 	err = i.Update(doc)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	linestring := [][][][]float64{{{{77.68715858459473, 12.944755587650944},
-		{77.69213676452637, 12.945090185150542}}}}
+	linestring := [][][][]float64{{{
+		{77.68715858459473, 12.944755587650944},
+		{77.69213676452637, 12.945090185150542},
+	}}}
 	doc = document.NewDocument("linestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -349,8 +440,10 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring1 := [][][][]float64{{{{77.68913269042969, 12.929614580987227},
-		{77.70252227783203, 12.929698235482276}}}}
+	linestring1 := [][][][]float64{{{
+		{77.68913269042969, 12.929614580987227},
+		{77.70252227783203, 12.929698235482276},
+	}}}
 	doc = document.NewDocument("linestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring1, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -359,8 +452,10 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring2 := [][][][]float64{{{{81.26792907714844, 26.170845301716813},
-		{81.30157470703125, 26.18440207077121}}}}
+	linestring2 := [][][][]float64{{{
+		{81.26792907714844, 26.170845301716813},
+		{81.30157470703125, 26.18440207077121},
+	}}}
 	doc = document.NewDocument("linestring3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring2, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -369,10 +464,16 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring := [][][][]float64{{{{81.86170578002928, 25.430407918899984},
-		{81.86273574829102, 25.421958559611397}}, {{81.88230514526367, 25.437616536907512},
-		{81.90084457397461, 25.431415601111418}}, {{81.86805725097656, 25.514868905100244},
-		{81.86702728271484, 25.502474677473746}}}}
+	multilinestring := [][][][]float64{{{
+		{81.86170578002928, 25.430407918899984},
+		{81.86273574829102, 25.421958559611397},
+	}, {
+		{81.88230514526367, 25.437616536907512},
+		{81.90084457397461, 25.431415601111418},
+	}, {
+		{81.86805725097656, 25.514868905100244},
+		{81.86702728271484, 25.502474677473746},
+	}}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -381,10 +482,14 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring1 := [][][][]float64{{{{81.84642791748047, 25.561335859046192},
-		{81.84230804443358, 25.550495180470026}},
+	multilinestring1 := [][][][]float64{{
+		{
+			{81.84642791748047, 25.561335859046192},
+			{81.84230804443358, 25.550495180470026},
+		},
 		{{81.87423706054688, 25.55142441992021}, {81.88453674316406, 25.555141305670045}},
-		{{81.8642807006836, 25.572175556682115}, {81.87458038330078, 25.567839795359724}}}}
+		{{81.8642807006836, 25.572175556682115}, {81.87458038330078, 25.567839795359724}},
+	}}
 	doc = document.NewDocument("multilinestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring1, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -393,8 +498,11 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{81.87337875366211, 25.432268248708212},
-		{81.87355041503906, 25.416299483230368}, {81.90118789672852, 25.426067037656946}}}}
+	multipoint1 := [][][][]float64{{{
+		{81.87337875366211, 25.432268248708212},
+		{81.87355041503906, 25.416299483230368},
+		{81.90118789672852, 25.426067037656946},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipoint1, "multipoint", document.DefaultGeoShapeIndexingOptions))
@@ -404,12 +512,22 @@ func setupGeoJsonShapesIndexForCircleQuery(t *testing.T) index.Index {
 	}
 
 	polygonWithHole1 := [][][][]float64{{
-		{{77.59991168975829, 12.972232910164502}, {77.6039457321167, 12.97582941279006},
-			{77.60424613952637, 12.98168407323241}, {77.59974002838135, 12.985489528568463},
-			{77.59321689605713, 12.979300406693417}, {77.59991168975829, 12.972232910164502}},
-		{{77.59682178497314, 12.975787593290978}, {77.60295867919922, 12.975787593290978},
-			{77.60295867919922, 12.98143316204164}, {77.59682178497314, 12.98143316204164},
-			{77.59682178497314, 12.975787593290978}}}}
+		{
+			{77.59991168975829, 12.972232910164502},
+			{77.6039457321167, 12.97582941279006},
+			{77.60424613952637, 12.98168407323241},
+			{77.59974002838135, 12.985489528568463},
+			{77.59321689605713, 12.979300406693417},
+			{77.59991168975829, 12.972232910164502},
+		},
+		{
+			{77.59682178497314, 12.975787593290978},
+			{77.60295867919922, 12.975787593290978},
+			{77.60295867919922, 12.98143316204164},
+			{77.59682178497314, 12.98143316204164},
+			{77.59682178497314, 12.975787593290978},
+		},
+	}}
 
 	doc = document.NewDocument("polygonWithHole1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
diff --git a/search/searcher/search_geoshape_envelope_test.go b/search/searcher/search_geoshape_envelope_test.go
index 22a53bde..580fd541 100644
--- a/search/searcher/search_geoshape_envelope_test.go
+++ b/search/searcher/search_geoshape_envelope_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -33,49 +34,92 @@ func TestGeoJsonEnvelopeWithInQuery(t *testing.T) {
 		want   []string
 	}{
 		// test within query envelope for point1.
-		{[][]float64{{76.256103515625, 16.76772739719064},
-			{76.35772705078125, 16.872890378907783}},
-			"geometry", []string{"point1"}},
+		{
+			[][]float64{
+				{76.256103515625, 16.76772739719064},
+				{76.35772705078125, 16.872890378907783},
+			},
+			"geometry",
+			[]string{"point1"},
+		},
 
 		// test within query envelope for multipoint1.
-		{[][]float64{{81.046142578125, 17.156537255486093},
-			{81.331787109375, 17.96305758238804}},
-			"geometry", []string{"multipoint1"}},
+		{
+			[][]float64{
+				{81.046142578125, 17.156537255486093},
+				{81.331787109375, 17.96305758238804},
+			},
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test within query envelope for partial points in a multipoint1.
-		{[][]float64{{81.05987548828125, 17.16178591271515},
-			{81.36199951171875, 17.861132899477624}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{81.05987548828125, 17.16178591271515},
+				{81.36199951171875, 17.861132899477624},
+			},
+			"geometry", nil,
+		},
 
 		// test within query envelope for polygon2 and point1.
-		{[][]float64{{76.00341796875, 16.573022719182777},
-			{76.717529296875, 17.006888277600524}},
-			"geometry", []string{"polygon2", "point1"}},
+		{
+			[][]float64{
+				{76.00341796875, 16.573022719182777},
+				{76.717529296875, 17.006888277600524},
+			},
+			"geometry",
+			[]string{"polygon2", "point1"},
+		},
 
 		// test within query envelope for linestring1.
-		{[][]float64{{76.84112548828125, 16.86500518090961},
-			{77.62115478515625, 17.531439701706244}},
-			"geometry", []string{"linestring1"}},
+		{
+			[][]float64{
+				{76.84112548828125, 16.86500518090961},
+				{77.62115478515625, 17.531439701706244},
+			},
+			"geometry",
+			[]string{"linestring1"},
+		},
 
 		// test within query envelope for multilinestring1.
-		{[][]float64{{81.683349609375, 17.104042525557904},
-			{81.99234008789062, 17.66495983051931}},
-			"geometry", []string{"multilinestring1"}},
+		{
+			[][]float64{
+				{81.683349609375, 17.104042525557904},
+				{81.99234008789062, 17.66495983051931},
+			},
+			"geometry",
+			[]string{"multilinestring1"},
+		},
 
 		// test within query envelope that is intersecting multilinestring1.
-		{[][]float64{{81.65725708007812, 17.2601707001208},
-			{81.95114135742186, 17.66495983051931}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{81.65725708007812, 17.2601707001208},
+				{81.95114135742186, 17.66495983051931},
+			},
+			"geometry", nil,
+		},
 
 		// test within query envelope for envelope1 and circle1.
-		{[][]float64{{74.75372314453125, 17.36636733709516},
-			{75.509033203125, 18.038809662036805}},
-			"geometry", []string{"envelope1", "circle1"}},
+		{
+			[][]float64{
+				{74.75372314453125, 17.36636733709516},
+				{75.509033203125, 18.038809662036805},
+			},
+			"geometry",
+			[]string{"envelope1", "circle1"},
+		},
 
 		// test within query envelope for envelope1.
-		{[][]float64{{74.783935546875, 17.38209494787749},
-			{75.96221923828125, 17.727758609852284}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][]float64{
+				{74.783935546875, 17.38209494787749},
+				{75.96221923828125, 17.727758609852284},
+			},
+			"geometry",
+			[]string{"envelope1"},
+		},
 	}
 	i := setupGeoJsonShapesIndexForEnvelopeQuery(t)
 	indexReader, err := i.Reader()
@@ -108,31 +152,55 @@ func TestGeoJsonEnvelopeIntersectsQuery(t *testing.T) {
 		field  string
 		want   []string
 	}{
-
 		// test intersecting query envelope for partial points in a multipoint1.
-		{[][]float64{{81.00769042968749, 17.80622614478282},
-			{81.199951171875, 17.983957957423037}},
-			"geometry", []string{"multipoint1"}},
+		{
+			[][]float64{
+				{81.00769042968749, 17.80622614478282},
+				{81.199951171875, 17.983957957423037},
+			},
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test intersecting query envelope that is intersecting multilinestring1.
-		{[][]float64{{81.65725708007812, 17.2601707001208},
-			{81.95114135742186, 17.66495983051931}},
-			"geometry", []string{"multilinestring1"}},
+		{
+			[][]float64{
+				{81.65725708007812, 17.2601707001208},
+				{81.95114135742186, 17.66495983051931},
+			},
+			"geometry",
+			[]string{"multilinestring1"},
+		},
 
 		// test intersecting query envelope for linestring2.
-		{[][]float64{{81.9854736328125, 18.27369419984127},
-			{82.14752197265625, 18.633232565431218}},
-			"geometry", []string{"linestring2"}},
+		{
+			[][]float64{
+				{81.9854736328125, 18.27369419984127},
+				{82.14752197265625, 18.633232565431218},
+			},
+			"geometry",
+			[]string{"linestring2"},
+		},
 
 		// test intersecting query envelope for circle2.
-		{[][]float64{{82.6336669921875, 17.82714499951342},
-			{82.66387939453125, 17.861132899477624}},
-			"geometry", []string{"circle2"}},
+		{
+			[][]float64{
+				{82.6336669921875, 17.82714499951342},
+				{82.66387939453125, 17.861132899477624},
+			},
+			"geometry",
+			[]string{"circle2"},
+		},
 
 		// test intersecting query envelope for polygon3.
-		{[][]float64{{82.92343139648438, 17.739530934289657},
-			{82.98797607421874, 17.79184300887134}},
-			"geometry", []string{"polygon3"}},
+		{
+			[][]float64{
+				{82.92343139648438, 17.739530934289657},
+				{82.98797607421874, 17.79184300887134},
+			},
+			"geometry",
+			[]string{"polygon3"},
+		},
 	}
 	i := setupGeoJsonShapesIndexForEnvelopeQuery(t)
 	indexReader, err := i.Reader()
@@ -147,14 +215,12 @@ func TestGeoJsonEnvelopeIntersectsQuery(t *testing.T) {
 	}()
 
 	for n, test := range tests {
-		got, err := runGeoShapeEnvelopeRelationQuery("intersects",
-			indexReader, test.points, test.field)
+		got, err := runGeoShapeEnvelopeRelationQuery("intersects", indexReader, test.points, test.field)
 		if err != nil {
 			t.Fatal(err)
 		}
 		if !reflect.DeepEqual(got, test.want) {
-			t.Errorf("test %d, expected %v, got %v for polygon: %+v",
-				n, test.want, got, test.points)
+			t.Errorf("test %d, expected %v, got %v for polygon: %+v", n, test.want, got, test.points)
 		}
 	}
 }
@@ -165,31 +231,52 @@ func TestGeoJsonEnvelopeContainsQuery(t *testing.T) {
 		field  string
 		want   []string
 	}{
-
 		// test envelope contained within polygon1.
-		{[][]float64{{8.548285961151123, 47.376092756617446},
-			{8.551225662231445, 47.37764752629426}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][]float64{
+				{8.548285961151123, 47.376092756617446},
+				{8.551225662231445, 47.37764752629426},
+			},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test envelope partially contained within polygon1.
-		{[][]float64{{8.549273014068604, 47.376194471922986},
-			{8.551654815673828, 47.37827232736301}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{8.549273014068604, 47.376194471922986},
+				{8.551654815673828, 47.37827232736301},
+			},
+			"geometry", nil,
+		},
 
 		// test envelope partially contained within polygon1.
-		{[][]float64{{8.549273014068604, 47.376194471922986},
-			{8.551654815673828, 47.37827232736301}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{8.549273014068604, 47.376194471922986},
+				{8.551654815673828, 47.37827232736301},
+			},
+			"geometry", nil,
+		},
 
 		// test envelope fully contained within circle3.
-		{[][]float64{{8.532772064208984, 47.380379160110856},
-			{8.534531593322752, 47.38299442157271}},
-			"geometry", []string{"circle3"}},
+		{
+			[][]float64{
+				{8.532772064208984, 47.380379160110856},
+				{8.534531593322752, 47.38299442157271},
+			},
+			"geometry",
+			[]string{"circle3"},
+		},
 
 		// test envelope partially contained within circle3.
-		{[][]float64{{8.532836437225342, 47.38010309716447},
-			{8.538415431976318, 47.383081594720466}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{8.532836437225342, 47.38010309716447},
+				{8.538415431976318, 47.383081594720466},
+			},
+			"geometry", nil,
+		},
 	}
 	i := setupGeoJsonShapesIndexForEnvelopeQuery(t)
 	indexReader, err := i.Reader()
@@ -217,11 +304,12 @@ func TestGeoJsonEnvelopeContainsQuery(t *testing.T) {
 }
 
 func runGeoShapeEnvelopeRelationQuery(relation string, i index.IndexReader,
-	points [][]float64, field string) ([]string, error) {
+	points [][]float64, field string,
+) ([]string, error) {
 	var rv []string
 	s := geo.NewGeoEnvelope(points)
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -257,10 +345,15 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{8.548071384429932, 47.379216780040124},
-		{8.547642230987549, 47.3771680227784}, {8.545818328857422, 47.37677569847655},
-		{8.546290397644043, 47.37417465983494}, {8.551719188690186, 47.37417465983494},
-		{8.553242683410645, 47.37679022905829}, {8.548071384429932, 47.379216780040124}}}}
+	polygon1 := [][][][]float64{{{
+		{8.548071384429932, 47.379216780040124},
+		{8.547642230987549, 47.3771680227784},
+		{8.545818328857422, 47.37677569847655},
+		{8.546290397644043, 47.37417465983494},
+		{8.551719188690186, 47.37417465983494},
+		{8.553242683410645, 47.37679022905829},
+		{8.548071384429932, 47.379216780040124},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -269,9 +362,12 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon2 := [][][][]float64{{{{76.70379638671874, 16.828203242420393},
-		{76.36322021484375, 16.58881695544584}, {76.70928955078125, 16.720385051694},
-		{76.70379638671874, 16.828203242420393}}}}
+	polygon2 := [][][][]float64{{{
+		{76.70379638671874, 16.828203242420393},
+		{76.36322021484375, 16.58881695544584},
+		{76.70928955078125, 16.720385051694},
+		{76.70379638671874, 16.828203242420393},
+	}}}
 	doc = document.NewDocument("polygon2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon2, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -280,10 +376,15 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon3 := [][][][]float64{{{{82.9522705078125, 17.749994573141873},
-		{82.94952392578125, 17.692436998627272}, {82.87673950195312, 17.64009591883757},
-		{82.76412963867188, 17.58643052828743}, {82.8094482421875, 17.522272941245202},
-		{82.99621582031249, 17.64009591883757}, {82.9522705078125, 17.749994573141873}}}}
+	polygon3 := [][][][]float64{{{
+		{82.9522705078125, 17.749994573141873},
+		{82.94952392578125, 17.692436998627272},
+		{82.87673950195312, 17.64009591883757},
+		{82.76412963867188, 17.58643052828743},
+		{82.8094482421875, 17.522272941245202},
+		{82.99621582031249, 17.64009591883757},
+		{82.9522705078125, 17.749994573141873},
+	}}}
 	doc = document.NewDocument("polygon3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon3, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -292,8 +393,10 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope1 := [][][][]float64{{{{74.89654541015625, 17.403062993328923},
-		{74.92401123046875, 17.66495983051931}}}}
+	envelope1 := [][][][]float64{{{
+		{74.89654541015625, 17.403062993328923},
+		{74.92401123046875, 17.66495983051931},
+	}}}
 	doc = document.NewDocument("envelope1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope1, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -322,8 +425,10 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 
 	doc = document.NewDocument("circle3")
 	doc.AddField(document.NewGeoCircleFieldWithIndexingOptions("geometry", []uint64{},
-		[]float64{8.53363037109375,
-			47.38191927423153}, "400m",
+		[]float64{
+			8.53363037109375,
+			47.38191927423153,
+		}, "400m",
 		document.DefaultGeoShapeIndexingOptions))
 	err = i.Update(doc)
 	if err != nil {
@@ -340,8 +445,10 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring1 := [][][][]float64{{{{76.85211181640624, 17.51048642597462},
-		{77.24212646484374, 16.93070509876554}}}}
+	linestring1 := [][][][]float64{{{
+		{76.85211181640624, 17.51048642597462},
+		{77.24212646484374, 16.93070509876554},
+	}}}
 	doc = document.NewDocument("linestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring1, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -350,8 +457,10 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring2 := [][][][]float64{{{{81.89208984375, 18.555136195095105},
-		{82.21343994140625, 18.059701055000478}}}}
+	linestring2 := [][][][]float64{{{
+		{81.89208984375, 18.555136195095105},
+		{82.21343994140625, 18.059701055000478},
+	}}}
 	doc = document.NewDocument("linestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring2, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -360,9 +469,12 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{81.24938964843749, 17.602139123350838},
-		{81.30432128906249, 17.56548361143177}, {81.29058837890625, 17.180155043474496},
-		{81.09283447265625, 17.87681743233167}}}}
+	multipoint1 := [][][][]float64{{{
+		{81.24938964843749, 17.602139123350838},
+		{81.30432128906249, 17.56548361143177},
+		{81.29058837890625, 17.180155043474496},
+		{81.09283447265625, 17.87681743233167},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipoint1, "multipoint", document.DefaultGeoShapeIndexingOptions))
@@ -371,11 +483,15 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring := [][][][]float64{{{{81.69708251953125, 17.641404631355755},
-		{81.90994262695312, 17.642713334367667}},
+	multilinestring := [][][][]float64{{
+		{
+			{81.69708251953125, 17.641404631355755},
+			{81.90994262695312, 17.642713334367667},
+		},
 		{{81.6998291015625, 17.620464090732245}, {81.69708251953125, 17.468572623463153}},
 		{{81.70120239257811, 17.458092664041494}, {81.81243896484375, 17.311310073048123}},
-		{{81.815185546875, 17.3034434020238}, {81.81243896484375, 17.109292665395643}}}}
+		{{81.815185546875, 17.3034434020238}, {81.81243896484375, 17.109292665395643}},
+	}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -384,10 +500,14 @@ func setupGeoJsonShapesIndexForEnvelopeQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring1 := [][][][]float64{{{{77.6015853881836, 12.990089451715061},
-		{77.60476112365723, 12.987747683302153}},
+	multilinestring1 := [][][][]float64{{
+		{
+			{77.6015853881836, 12.990089451715061},
+			{77.60476112365723, 12.987747683302153},
+		},
 		{{77.59875297546387, 12.988751301039581}, {77.59446144104004, 12.98197680263484}},
-		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}}}}
+		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}},
+	}}
 	doc = document.NewDocument("multilinestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring1, "multilinestring", document.DefaultGeoShapeIndexingOptions))
diff --git a/search/searcher/search_geoshape_geometrycollection_test.go b/search/searcher/search_geoshape_geometrycollection_test.go
index bba53f21..f9dd3122 100644
--- a/search/searcher/search_geoshape_geometrycollection_test.go
+++ b/search/searcher/search_geoshape_geometrycollection_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -34,48 +35,97 @@ func TestGeoJSONIntersectsQueryAgainstGeometryCollection(t *testing.T) {
 		want   []string
 	}{
 		// test intersects geometrycollection query for gc_polygon1_linestring1.
-		{[][][][][]float64{
-			{{{{-120.80017089843749, 36.54053616262899}, {-120.67932128906249, 36.33725319397006},
-				{-120.30578613281251, 36.90597988519294},
-				{-120.80017089843749, 36.54053616262899}}}},
-			{{{{-118.24584960937499, 35.32184842037683}, {-117.8668212890625, 35.06597313798418}}}}},
-			[]string{"polygon", "linestring"}, "geometry", []string{"gc_polygon1_linestring1"}},
+		{
+			[][][][][]float64{
+				{{{
+					{-120.80017089843749, 36.54053616262899},
+					{-120.67932128906249, 36.33725319397006},
+					{-120.30578613281251, 36.90597988519294},
+					{-120.80017089843749, 36.54053616262899},
+				}}},
+				{{{{-118.24584960937499, 35.32184842037683}, {-117.8668212890625, 35.06597313798418}}}},
+			},
+			[]string{"polygon", "linestring"},
+			"geometry",
+			[]string{"gc_polygon1_linestring1"},
+		},
 
 		// test intersects geometrycollection query for gc_polygon1_linestring1.
-		{[][][][][]float64{
-			{{{{-118.3172607421875, 35.250105158539355}, {-117.50976562499999, 35.37561413174875}},
-				{{-118.69628906249999, 34.6241677899049}, {-118.3172607421875, 35.03899204678081}},
-				{{-117.94921874999999, 35.146862906756304}, {-117.674560546875, 34.41144164327245}}}},
-			{{{{-117.04284667968749, 35.263561862152095}, {-116.8505859375, 35.263561862152095},
-				{-116.8505859375, 35.33529320309328},
-				{-117.04284667968749, 35.33529320309328}, {-117.04284667968749, 35.263561862152095}}}}},
-			[]string{"multilinestring", "polygon"}, "geometry", []string{"gc_polygon1_linestring1"}},
+		{
+			[][][][][]float64{
+				{{
+					{{-118.3172607421875, 35.250105158539355}, {-117.50976562499999, 35.37561413174875}},
+					{{-118.69628906249999, 34.6241677899049}, {-118.3172607421875, 35.03899204678081}},
+					{{-117.94921874999999, 35.146862906756304}, {-117.674560546875, 34.41144164327245}},
+				}},
+				{{{
+					{-117.04284667968749, 35.263561862152095},
+					{-116.8505859375, 35.263561862152095},
+					{-116.8505859375, 35.33529320309328},
+					{-117.04284667968749, 35.33529320309328},
+					{-117.04284667968749, 35.263561862152095},
+				}}},
+			},
+			[]string{"multilinestring", "polygon"},
+			"geometry",
+			[]string{"gc_polygon1_linestring1"},
+		},
 
 		// test intersects geometrycollection query for gc_multipolygon1_multilinestring1.
-		{[][][][][]float64{
-			{{{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
-				{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}}}},
-			{{{{-116.64905548095702, 37.94920616351679}}}}},
-			[]string{"multilinestring", "point"}, "geometry", []string{"gc_multipolygon1_multilinestring1"}},
+		{
+			[][][][][]float64{
+				{{
+					{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
+					{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}},
+				}},
+				{{{{-116.64905548095702, 37.94920616351679}}}},
+			},
+			[]string{"multilinestring", "point"},
+			"geometry",
+			[]string{"gc_multipolygon1_multilinestring1"},
+		},
 
 		// test intersects geometrycollection query for gc_polygon1_linestring1 and gc_multipolygon1_multilinestring1.
-		{[][][][][]float64{
-			{{{{-116.64905548095702, 37.94920616351679}, {-118.29528808593751, 34.52466147177172}}}},
-			{{{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
-				{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}}}}},
-			[]string{"multipoint", "multilinestring"}, "geometry", []string{"gc_polygon1_linestring1",
-				"gc_multipolygon1_multilinestring1"}},
+		{
+			[][][][][]float64{
+				{{{{-116.64905548095702, 37.94920616351679}, {-118.29528808593751, 34.52466147177172}}}},
+				{{
+					{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
+					{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}},
+				}},
+			},
+			[]string{"multipoint", "multilinestring"},
+			"geometry",
+			[]string{
+				"gc_polygon1_linestring1",
+				"gc_multipolygon1_multilinestring1",
+			},
+		},
 
 		// test intersects geometrycollection query for gc_polygon1_linestring1 and gc_multipolygon1_multilinestring1.
-		{[][][][][]float64{
-			{{{{-117.46582031249999, 36.146746777814364}, {-116.70227050781249, 36.146746777814364},
-				{-116.70227050781249, 36.69485094156225}, {-117.46582031249999, 36.69485094156225},
-				{-117.46582031249999, 36.146746777814364}}}, {{{-115.5267333984375, 38.06106741381201},
-				{-115.4937744140625, 37.18220222107978}, {-114.93896484374999, 37.304644804751106},
-				{-115.5267333984375, 38.06106741381201}}}},
-			{{{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
-				{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}}}}},
-			[]string{"multipolygon", "multilinestring"}, "geometry", []string{"gc_point1_multipoint1"}},
+		{
+			[][][][][]float64{
+				{{{
+					{-117.46582031249999, 36.146746777814364},
+					{-116.70227050781249, 36.146746777814364},
+					{-116.70227050781249, 36.69485094156225},
+					{-117.46582031249999, 36.69485094156225},
+					{-117.46582031249999, 36.146746777814364},
+				}}, {{
+					{-115.5267333984375, 38.06106741381201},
+					{-115.4937744140625, 37.18220222107978},
+					{-114.93896484374999, 37.304644804751106},
+					{-115.5267333984375, 38.06106741381201},
+				}}},
+				{{
+					{{-115.8563232421875, 38.53957267203905}, {-115.58166503906251, 38.54816542304656}},
+					{{-115.8343505859375, 38.45789034424927}, {-115.81237792968749, 38.19502155795575}},
+				}},
+			},
+			[]string{"multipolygon", "multilinestring"},
+			"geometry",
+			[]string{"gc_point1_multipoint1"},
+		},
 	}
 	i := setupGeoJsonShapesIndexForGeometryCollectionQuery(t)
 	indexReader, err := i.Reader()
@@ -110,49 +160,113 @@ func TestGeoJSONWithInQueryAgainstGeometryCollection(t *testing.T) {
 		want   []string
 	}{
 		// test within geometrycollection query for gc_multipoint2_multipolygon2_multiline2.
-		{[][][][][]float64{
-			{{{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}}}},
-			{{{{-122.42511749267578, 37.760808496517235}, {-122.42314338684082, 37.74248523826606},
-				{-122.40082740783691, 37.756669194195815}, {-122.42511749267578, 37.760808496517235}}}},
-			{{{{-122.46339797973633, 37.76637243960179}, {-122.46176719665527, 37.7502901437285},
-				{-122.43644714355469, 37.75911208915015}, {-122.46339797973633, 37.76637243960179}}},
-				{{{-122.43653297424315, 37.714720253587004}, {-122.40563392639159, 37.714720253587004},
-					{-122.40563392639159, 37.72904529863455}, {-122.43653297424315, 37.72904529863455},
-					{-122.43653297424315, 37.714720253587004}}}}},
-			[]string{"linestring", "polygon", "multipolygon"}, "geometry",
-			[]string{"gc_multipoint2_multipolygon2_multiline2"}},
+		{
+			[][][][][]float64{
+				{{{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}}}},
+				{{{
+					{-122.42511749267578, 37.760808496517235},
+					{-122.42314338684082, 37.74248523826606},
+					{-122.40082740783691, 37.756669194195815},
+					{-122.42511749267578, 37.760808496517235},
+				}}},
+				{
+					{{
+						{-122.46339797973633, 37.76637243960179},
+						{-122.46176719665527, 37.7502901437285},
+						{-122.43644714355469, 37.75911208915015},
+						{-122.46339797973633, 37.76637243960179},
+					}},
+					{{
+						{-122.43653297424315, 37.714720253587004},
+						{-122.40563392639159, 37.714720253587004},
+						{-122.40563392639159, 37.72904529863455},
+						{-122.43653297424315, 37.72904529863455},
+						{-122.43653297424315, 37.714720253587004},
+					}},
+				},
+			},
+			[]string{"linestring", "polygon", "multipolygon"},
+			"geometry",
+			[]string{"gc_multipoint2_multipolygon2_multiline2"},
+		},
 
 		// test within geometrycollection query.
-		{[][][][][]float64{
-			{{{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}}}},
-			{{{{-122.46339797973633, 37.76637243960179}, {-122.46176719665527, 37.7502901437285},
-				{-122.43644714355469, 37.75911208915015}, {-122.46339797973633, 37.76637243960179}}},
-				{{{-122.43653297424315, 37.714720253587004}, {-122.40563392639159, 37.714720253587004},
-					{-122.40563392639159, 37.72904529863455}, {-122.43653297424315, 37.72904529863455},
-					{-122.43653297424315, 37.714720253587004}}}}},
-			[]string{"linestring", "multipolygon"}, "geometry", nil},
+		{
+			[][][][][]float64{
+				{{{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}}}},
+				{
+					{{
+						{-122.46339797973633, 37.76637243960179},
+						{-122.46176719665527, 37.7502901437285},
+						{-122.43644714355469, 37.75911208915015},
+						{-122.46339797973633, 37.76637243960179},
+					}},
+					{{
+						{-122.43653297424315, 37.714720253587004},
+						{-122.40563392639159, 37.714720253587004},
+						{-122.40563392639159, 37.72904529863455},
+						{-122.43653297424315, 37.72904529863455},
+						{-122.43653297424315, 37.714720253587004},
+					}},
+				},
+			},
+			[]string{"linestring", "multipolygon"},
+			"geometry", nil,
+		},
 
 		// test within geometrycollection for gc_multipoint2_multipolygon2_multiline2.
-		{[][][][][]float64{
-			{{{{-122.4491500854492, 37.78170504295941}, {-122.4862289428711, 37.747371884118664},
-				{-122.43078231811525, 37.6949593672454}, {-122.3799705505371, 37.72945260537779},
-				{-122.3928451538086, 37.78007695280165}, {-122.4491500854492, 37.78170504295941}}}}},
-			[]string{"polygon"}, "geometry", []string{"gc_multipoint2_multipolygon2_multiline2"}},
+		{
+			[][][][][]float64{
+				{{{
+					{-122.4491500854492, 37.78170504295941},
+					{-122.4862289428711, 37.747371884118664},
+					{-122.43078231811525, 37.6949593672454},
+					{-122.3799705505371, 37.72945260537779},
+					{-122.3928451538086, 37.78007695280165},
+					{-122.4491500854492, 37.78170504295941},
+				}}},
+			},
+			[]string{"polygon"},
+			"geometry",
+			[]string{"gc_multipoint2_multipolygon2_multiline2"},
+		},
 
 		// test within geometrycollection for gc_multipolygon3
 		// gc_multipolygon3's multipolygons within the geometrycollection is covered by the
 		// query's geometric collection of a polygon and a multipolygon.
-		{[][][][][]float64{
-			{{{{86.6162109375, 57.26716357153586}, {85.1220703125, 8119},
-				{84.462890625, 56.27996083172844}, {86.98974609375, 55.70235509327093},
-				{87.802734375, 56.77680831656842}, {86.6162109375, 57.26716357153586}}}},
-			{{{{75.1025390625, 54.3549556895541}, {73.1689453125, 54.29088164657006},
-				{72.7294921875, 53.08082737207479}, {74.091796875, 51.998410382390325},
-				{76.79443359375, 53.396432127095984}, {75.1025390625, 54.3549556895541}}},
-				{{{80.1123046875, 55.57834467218206}, {78.9697265625, 55.65279803318956},
-					{78.5302734375, 54.635697306063854}, {79.87060546875, 54.18815548107151},
-					{80.96923828125, 54.80068486732233}, {80.1123046875, 55.57834467218206}}}}},
-			[]string{"polygon", "multipolygon"}, "geometry", []string{"gc_multipolygon3"}},
+		{
+			[][][][][]float64{
+				{{{
+					{86.6162109375, 57.26716357153586},
+					{85.1220703125, 8119},
+					{84.462890625, 56.27996083172844},
+					{86.98974609375, 55.70235509327093},
+					{87.802734375, 56.77680831656842},
+					{86.6162109375, 57.26716357153586},
+				}}},
+				{
+					{{
+						{75.1025390625, 54.3549556895541},
+						{73.1689453125, 54.29088164657006},
+						{72.7294921875, 53.08082737207479},
+						{74.091796875, 51.998410382390325},
+						{76.79443359375, 53.396432127095984},
+						{75.1025390625, 54.3549556895541},
+					}},
+					{{
+						{80.1123046875, 55.57834467218206},
+						{78.9697265625, 55.65279803318956},
+						{78.5302734375, 54.635697306063854},
+						{79.87060546875, 54.18815548107151},
+						{80.96923828125, 54.80068486732233},
+						{80.1123046875, 55.57834467218206},
+					}},
+				},
+			},
+			[]string{"polygon", "multipolygon"},
+			"geometry",
+			[]string{"gc_multipolygon3"},
+		},
 	}
 
 	i := setupGeoJsonShapesIndexForGeometryCollectionQuery(t)
@@ -168,14 +282,12 @@ func TestGeoJSONWithInQueryAgainstGeometryCollection(t *testing.T) {
 	}()
 
 	for n, test := range tests {
-		got, err := runGeoShapeGeometryCollectionRelationQuery("within",
-			indexReader, test.points, test.types, test.field)
+		got, err := runGeoShapeGeometryCollectionRelationQuery("within", indexReader, test.points, test.types, test.field)
 		if err != nil {
 			t.Fatal(err)
 		}
 		if !reflect.DeepEqual(got, test.want) {
-			t.Errorf("test %d, expected %v, got %v for polygon: %+v",
-				n, test.want, got, test.points)
+			t.Errorf("test %d, expected %v, got %v for polygon: %+v", n, test.want, got, test.points)
 		}
 	}
 }
@@ -189,68 +301,123 @@ func TestGeoJSONContainsQueryAgainstGeometryCollection(t *testing.T) {
 	}{
 		// test contains for a geometrycollection that comprises of a linestring,
 		// polygon, multipolygon, point and multipoint for polygon2.
-		{[][][][][]float64{
-			// linestring
-			{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
-			// polygon
-			{{{{7.466454505920409, 46.965054389418476}, {7.46143341064453, 46.9641171865865},
-				{7.466325759887694, 46.96101258493027}, {7.466454505920409, 46.965054389418476}}}},
-			// multipolygon
-			{{{{7.4811744689941415, 46.957966385567474}, {7.478899955749511, 46.95492001277476},
-				{7.484478950500488, 46.95509576976545}, {7.4811744689941415, 46.957966385567474}}},
-				{{{7.466540336608888, 46.94753769790697}, {7.464609146118165, 46.946219320241674},
-					{7.468342781066894, 46.94592634301753}, {7.466540336608888, 46.94753769790697}}},
-				{{{7.504348754882812, 47.00425575323296}, {7.501087188720703, 47.001680295206874},
-					{7.507266998291015, 47.00191443288521}, {7.504348754882812, 47.00425575323296}}}},
-			// point
-			{{{{7.449932098388673, 46.95817142366062}}}},
-			// multipoint
-			{{{{7.479157447814942, 46.96370715518446}, {7.4532365798950195, 46.96657730900153}}}},
+		{
+			[][][][][]float64{
+				// linestring
+				{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
+				// polygon
+				{{{
+					{7.466454505920409, 46.965054389418476},
+					{7.46143341064453, 46.9641171865865},
+					{7.466325759887694, 46.96101258493027},
+					{7.466454505920409, 46.965054389418476},
+				}}},
+				// multipolygon
+				{
+					{{
+						{7.4811744689941415, 46.957966385567474},
+						{7.478899955749511, 46.95492001277476},
+						{7.484478950500488, 46.95509576976545},
+						{7.4811744689941415, 46.957966385567474},
+					}},
+					{{
+						{7.466540336608888, 46.94753769790697},
+						{7.464609146118165, 46.946219320241674},
+						{7.468342781066894, 46.94592634301753},
+						{7.466540336608888, 46.94753769790697},
+					}},
+					{{
+						{7.504348754882812, 47.00425575323296},
+						{7.501087188720703, 47.001680295206874},
+						{7.507266998291015, 47.00191443288521},
+						{7.504348754882812, 47.00425575323296},
+					}},
+				},
+				// point
+				{{{{7.449932098388673, 46.95817142366062}}}},
+				// multipoint
+				{{{{7.479157447814942, 46.96370715518446}, {7.4532365798950195, 46.96657730900153}}}},
+			},
+			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"},
+			"geometry",
+			[]string{"multipolygon4"},
 		},
-			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"}, "geometry",
-			[]string{"multipolygon4"}},
 
 		// test contains for a geometrycollection query with one point inside the multipoint lying outside
 		// polygon2.
-		{[][][][][]float64{
-			// linestring
-			{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
-			// polygon
-			{{{{7.466454505920409, 46.965054389418476}, {7.46143341064453, 46.9641171865865},
-				{7.466325759887694, 46.96101258493027}, {7.466454505920409, 46.965054389418476}}}},
-			// multipolygon
-			{{{{7.4811744689941415, 46.957966385567474}, {7.478899955749511, 46.95492001277476},
-				{7.484478950500488, 46.95509576976545}, {7.4811744689941415, 46.957966385567474}}},
-				{{{7.466540336608888, 46.94753769790697}, {7.464609146118165, 46.946219320241674},
-					{7.468342781066894, 46.94592634301753}, {7.466540336608888, 46.94753769790697}}}},
-			// point
-			{{{{7.449932098388673, 46.95817142366062}}}},
-			// multipoint
-			{{{{7.479157447814942, 46.96370715518446}, {7.475638389587402, 46.965200825877794}}}},
+		{
+			[][][][][]float64{
+				// linestring
+				{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
+				// polygon
+				{{{
+					{7.466454505920409, 46.965054389418476},
+					{7.46143341064453, 46.9641171865865},
+					{7.466325759887694, 46.96101258493027},
+					{7.466454505920409, 46.965054389418476},
+				}}},
+				// multipolygon
+				{
+					{{
+						{7.4811744689941415, 46.957966385567474},
+						{7.478899955749511, 46.95492001277476},
+						{7.484478950500488, 46.95509576976545},
+						{7.4811744689941415, 46.957966385567474},
+					}},
+					{{
+						{7.466540336608888, 46.94753769790697},
+						{7.464609146118165, 46.946219320241674},
+						{7.468342781066894, 46.94592634301753},
+						{7.466540336608888, 46.94753769790697},
+					}},
+				},
+				// point
+				{{{{7.449932098388673, 46.95817142366062}}}},
+				// multipoint
+				{{{{7.479157447814942, 46.96370715518446}, {7.475638389587402, 46.965200825877794}}}},
+			},
+			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"},
+			"geometry",
+			nil,
 		},
-			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"}, "geometry",
-			nil},
 
 		// test contains for a geometrycollection query with one point inside the multipoint lying outside
 		// polygon2.
-		{[][][][][]float64{
-			// linestring
-			{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
-			// polygon
-			{{{{7.466454505920409, 46.965054389418476}, {7.46143341064453, 46.9641171865865},
-				{7.466325759887694, 46.96101258493027}, {7.466454505920409, 46.965054389418476}}}},
-			// multipolygon
-			{{{{7.4811744689941415, 46.957966385567474}, {7.478899955749511, 46.95492001277476},
-				{7.484478950500488, 46.95509576976545}, {7.4811744689941415, 46.957966385567474}}},
-				{{{7.466540336608888, 46.94753769790697}, {7.464609146118165, 46.946219320241674},
-					{7.468342781066894, 46.94592634301753}, {7.466540336608888, 46.94753769790697}}}},
-			// point
-			{{{{7.449932098388673, 46.95817142366062}}}},
-			// multipoint
-			{{{{7.479157447814942, 46.96370715518446}, {7.4532365798950195, 46.96657730900153}}}},
+		{
+			[][][][][]float64{
+				// linestring
+				{{{{7.457013130187988, 46.966401589723894}, {7.482891082763671, 46.94554547022893}}}},
+				// polygon
+				{{{
+					{7.466454505920409, 46.965054389418476},
+					{7.46143341064453, 46.9641171865865},
+					{7.466325759887694, 46.96101258493027},
+					{7.466454505920409, 46.965054389418476},
+				}}},
+				// multipolygon
+				{
+					{{
+						{7.4811744689941415, 46.957966385567474},
+						{7.478899955749511, 46.95492001277476},
+						{7.484478950500488, 46.95509576976545},
+						{7.4811744689941415, 46.957966385567474},
+					}},
+					{{
+						{7.466540336608888, 46.94753769790697},
+						{7.464609146118165, 46.946219320241674},
+						{7.468342781066894, 46.94592634301753},
+						{7.466540336608888, 46.94753769790697},
+					}},
+				},
+				// point
+				{{{{7.449932098388673, 46.95817142366062}}}},
+				// multipoint
+				{{{{7.479157447814942, 46.96370715518446}, {7.4532365798950195, 46.96657730900153}}}},
+			},
+			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"},
+			"geometry",
+			[]string{"polygon2", "multipolygon4"},
 		},
-			[]string{"linestring", "polygon", "multipolygon", "point", "multipoint"}, "geometry",
-			[]string{"polygon2", "multipolygon4"}},
 	}
 
 	i := setupGeoJsonShapesIndexForGeometryCollectionQuery(t)
@@ -279,14 +446,15 @@ func TestGeoJSONContainsQueryAgainstGeometryCollection(t *testing.T) {
 }
 
 func runGeoShapeGeometryCollectionRelationQuery(relation string, i index.IndexReader,
-	points [][][][][]float64, types []string, field string) ([]string, error) {
+	points [][][][][]float64, types []string, field string,
+) ([]string, error) {
 	var rv []string
 	s, _, err := geo.NewGeometryCollection(points, types)
 	if err != nil {
 		return nil, err
 	}
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -323,13 +491,19 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 	}
 
 	// document gc_polygon1_linestring1
-	polygon1 := [][][][]float64{{{{-118.15246582031249, 34.876918445772084},
-		{-118.46557617187499, 34.773203753940734}, {-118.3172607421875, 34.50655662164561},
-		{-117.91625976562499, 34.4793919710481}, {-117.76245117187499, 34.76417891445512},
-		{-118.15246582031249, 34.876918445772084}}}}
+	polygon1 := [][][][]float64{{{
+		{-118.15246582031249, 34.876918445772084},
+		{-118.46557617187499, 34.773203753940734},
+		{-118.3172607421875, 34.50655662164561},
+		{-117.91625976562499, 34.4793919710481},
+		{-117.76245117187499, 34.76417891445512},
+		{-118.15246582031249, 34.876918445772084},
+	}}}
 
-	linestring1 := [][][][]float64{{{{-120.78918457031251, 36.87522650673951},
-		{-118.9215087890625, 34.95349314197422}}}}
+	linestring1 := [][][][]float64{{{
+		{-120.78918457031251, 36.87522650673951},
+		{-118.9215087890625, 34.95349314197422},
+	}}}
 
 	coordinates := [][][][][]float64{polygon1, linestring1}
 	types := []string{"polygon", "linestring"}
@@ -343,17 +517,28 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 	}
 
 	// document gc_multipolygon1_multilinestring1
-	multipolygon1 := [][][][]float64{{{{-117.24609374999999, 37.67512527892127},
-		{-117.61962890624999, 37.26530995561875}, {-116.597900390625, 37.56199695314352},
-		{-117.24609374999999, 37.67512527892127}}},
-		{{{-117.60864257812501, 38.71123253895224}, {-117.41638183593749, 38.36750215395045},
-			{-117.66357421875, 37.93986540897977}, {-116.6473388671875, 37.94852933714952},
-			{-117.1307373046875, 38.363195134453846}, {-116.75170898437501, 38.7283759182398},
-			{-117.60864257812501, 38.71123253895224}}}}
+	multipolygon1 := [][][][]float64{
+		{{
+			{-117.24609374999999, 37.67512527892127},
+			{-117.61962890624999, 37.26530995561875},
+			{-116.597900390625, 37.56199695314352},
+			{-117.24609374999999, 37.67512527892127},
+		}},
+		{{
+			{-117.60864257812501, 38.71123253895224},
+			{-117.41638183593749, 38.36750215395045},
+			{-117.66357421875, 37.93986540897977},
+			{-116.6473388671875, 37.94852933714952},
+			{-117.1307373046875, 38.363195134453846},
+			{-116.75170898437501, 38.7283759182398},
+			{-117.60864257812501, 38.71123253895224},
+		}},
+	}
 	multilinestring1 := [][][][]float64{{
 		{{-118.9215087890625, 38.74123075381228}, {-118.78967285156249, 38.43207668538207}},
 		{{-118.57543945312501, 38.8225909761771}, {-118.45458984375, 38.522384090200845}},
-		{{-118.94897460937499, 38.788345355085625}, {-118.61938476562499, 38.86965182408357}}}}
+		{{-118.94897460937499, 38.788345355085625}, {-118.61938476562499, 38.86965182408357}},
+	}}
 
 	coordinates = [][][][][]float64{multipolygon1, multilinestring1}
 	types = []string{"multipolygon", "multilinestring"}
@@ -367,9 +552,12 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 
 	// document gc_point1_multipoint1
 	point1 := [][][][]float64{{{{-115.10925292968749, 36.20882309283712}}}}
-	multipoint1 := [][][][]float64{{{{-117.13623046874999, 36.474306755095235},
+	multipoint1 := [][][][]float64{{{
+		{-117.13623046874999, 36.474306755095235},
 		{-118.57543945312501, 36.518465989675875},
-		{-118.58642578124999, 36.90597988519294}, {-119.5477294921875, 37.85316995894978}}}}
+		{-118.58642578124999, 36.90597988519294},
+		{-119.5477294921875, 37.85316995894978},
+	}}}
 
 	coordinates = [][][][][]float64{point1, multipoint1}
 	types = []string{"point", "multipoint"}
@@ -383,16 +571,29 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 	}
 
 	// document gc_multipoint2_multipolygon2_multiline2
-	multipoint2 := [][][][]float64{{{{-122.4052906036377, 37.75626203719391},
-		{-122.42091178894044, 37.74757548736071}}}}
-	multipolygon2 := [][][][]float64{{{{-122.46168136596681, 37.765151122096945},
-		{-122.46168136596681, 37.754972691904946}, {-122.45103836059569, 37.754972691904946},
-		{-122.451810836792, 37.7624370109886}, {-122.46168136596681, 37.765151122096945}}},
-		{{{-122.41902351379395, 37.726194088705576}, {-122.43533134460448, 37.71668926284967},
-			{-122.40777969360353, 37.71634978222733}, {-122.41902351379395, 37.726194088705576}}}}
+	multipoint2 := [][][][]float64{{{
+		{-122.4052906036377, 37.75626203719391},
+		{-122.42091178894044, 37.74757548736071},
+	}}}
+	multipolygon2 := [][][][]float64{
+		{{
+			{-122.46168136596681, 37.765151122096945},
+			{-122.46168136596681, 37.754972691904946},
+			{-122.45103836059569, 37.754972691904946},
+			{-122.451810836792, 37.7624370109886},
+			{-122.46168136596681, 37.765151122096945},
+		}},
+		{{
+			{-122.41902351379395, 37.726194088705576},
+			{-122.43533134460448, 37.71668926284967},
+			{-122.40777969360353, 37.71634978222733},
+			{-122.41902351379395, 37.726194088705576},
+		}},
+	}
 	multilinestring2 := [][][][]float64{{
 		{{-122.41284370422362, 37.73155698786267}, {-122.40700721740721, 37.73338978839743}},
-		{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}}}}
+		{{-122.40434646606444, 37.73400071182758}, {-122.39730834960938, 37.73691949864062}},
+	}}
 
 	coordinates = [][][][][]float64{multipoint2, multipolygon2, multilinestring2}
 	types = []string{"multipoint", "multipolygon", "multiline"}
@@ -407,12 +608,25 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 
 	// document gc_multipolygon3
 	multipolygon3 := [][][][]float64{
-		{{{85.60546875, 57.20771009775018}, {86.396484375, 55.99838095535963},
-			{87.03369140625, 56.71656572651468}, {85.60546875, 57.20771009775018}}},
-		{{{79.56298828125, 55.3915921070334}, {79.60693359375, 54.43171285946844},
-			{80.39794921875, 54.85131525968606}, {79.56298828125, 55.3915921070334}}},
-		{{{74.35546875, 54.13669645687002}, {74.1796875, 52.802761415419674},
-			{75.87158203125, 53.44880683542759}, {74.35546875, 54.13669645687002}}}}
+		{{
+			{85.60546875, 57.20771009775018},
+			{86.396484375, 55.99838095535963},
+			{87.03369140625, 56.71656572651468},
+			{85.60546875, 57.20771009775018},
+		}},
+		{{
+			{79.56298828125, 55.3915921070334},
+			{79.60693359375, 54.43171285946844},
+			{80.39794921875, 54.85131525968606},
+			{79.56298828125, 55.3915921070334},
+		}},
+		{{
+			{74.35546875, 54.13669645687002},
+			{74.1796875, 52.802761415419674},
+			{75.87158203125, 53.44880683542759},
+			{74.35546875, 54.13669645687002},
+		}},
+	}
 
 	coordinates = [][][][][]float64{multipolygon3}
 	types = []string{"multipolygon"}
@@ -425,11 +639,16 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 		t.Fatal(err)
 	}
 
-	polygon2 := [][][][]float64{{{{7.452635765075683, 46.96692874582506},
-		{7.449803352355956, 46.95817142366062}, {7.4573564529418945, 46.95149263607834},
-		{7.462162971496582, 46.945955640812095}, {7.483148574829102, 46.945311085627445},
-		{7.487225532531738, 46.957029058564686}, {7.4793291091918945, 46.96388288331302},
-		{7.464480400085448, 46.96903731827891}, {7.452635765075683, 46.96692874582506},
+	polygon2 := [][][][]float64{{{
+		{7.452635765075683, 46.96692874582506},
+		{7.449803352355956, 46.95817142366062},
+		{7.4573564529418945, 46.95149263607834},
+		{7.462162971496582, 46.945955640812095},
+		{7.483148574829102, 46.945311085627445},
+		{7.487225532531738, 46.957029058564686},
+		{7.4793291091918945, 46.96388288331302},
+		{7.464480400085448, 46.96903731827891},
+		{7.452635765075683, 46.96692874582506},
 	}}}
 
 	doc = document.NewDocument("polygon2")
@@ -440,14 +659,25 @@ func setupGeoJsonShapesIndexForGeometryCollectionQuery(t *testing.T) index.Index
 		t.Fatal(err)
 	}
 
-	multipolygon4 := [][][][]float64{{{{7.452635765075683, 46.96692874582506},
-		{7.449803352355956, 46.95817142366062}, {7.4573564529418945, 46.95149263607834},
-		{7.462162971496582, 46.945955640812095}, {7.483148574829102, 46.945311085627445},
-		{7.487225532531738, 46.957029058564686}, {7.4793291091918945, 46.96388288331302},
-		{7.464480400085448, 46.96903731827891}, {7.452635765075683, 46.96692874582506}}},
-		{{{7.4478721618652335, 47.00015837528636}, {7.5110435485839835, 47.00015837528636},
-			{7.5110435485839835, 47.00683108710118}, {7.4478721618652335, 47.00683108710118},
-			{7.4478721618652335, 47.00015837528636}}},
+	multipolygon4 := [][][][]float64{
+		{{
+			{7.452635765075683, 46.96692874582506},
+			{7.449803352355956, 46.95817142366062},
+			{7.4573564529418945, 46.95149263607834},
+			{7.462162971496582, 46.945955640812095},
+			{7.483148574829102, 46.945311085627445},
+			{7.487225532531738, 46.957029058564686},
+			{7.4793291091918945, 46.96388288331302},
+			{7.464480400085448, 46.96903731827891},
+			{7.452635765075683, 46.96692874582506},
+		}},
+		{{
+			{7.4478721618652335, 47.00015837528636},
+			{7.5110435485839835, 47.00015837528636},
+			{7.5110435485839835, 47.00683108710118},
+			{7.4478721618652335, 47.00683108710118},
+			{7.4478721618652335, 47.00015837528636},
+		}},
 	}
 
 	doc = document.NewDocument("multipolygon4")
diff --git a/search/searcher/search_geoshape_linestring_test.go b/search/searcher/search_geoshape_linestring_test.go
index b222a281..dc82df35 100644
--- a/search/searcher/search_geoshape_linestring_test.go
+++ b/search/searcher/search_geoshape_linestring_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -33,45 +34,85 @@ func TestGeoJsonLinestringIntersectsQuery(t *testing.T) {
 		want  []string
 	}{
 		// test intersecting linestring query for polygon1.
-		{[][]float64{{74.85860824584961, 22.407219759334023},
-			{74.8663330078125, 22.382936446589863}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][]float64{
+				{74.85860824584961, 22.407219759334023},
+				{74.8663330078125, 22.382936446589863},
+			},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test intersecting linestring query for polygon1 and polygon2.
-		{[][]float64{{74.82461929321289, 22.393729553598526},
-			{74.93671417236328, 22.356743809494784}},
-			"geometry", []string{"polygon1", "polygon2"}},
+		{
+			[][]float64{
+				{74.82461929321289, 22.393729553598526},
+				{74.93671417236328, 22.356743809494784},
+			},
+			"geometry",
+			[]string{"polygon1", "polygon2"},
+		},
 
 		// test intersecting linestring query for envelope1.
-		{[][]float64{{74.83938217163086, 22.325782524687973},
-			{74.8692512512207, 22.311172762889516}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][]float64{
+				{74.83938217163086, 22.325782524687973},
+				{74.8692512512207, 22.311172762889516},
+			},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test intersecting linestring query for circle.
-		{[][]float64{{74.94546890258789, 22.310815439776572},
-			{74.93276596069336, 22.303708490145645}},
-			"geometry", []string{"circle1"}},
+		{
+			[][]float64{
+				{74.94546890258789, 22.310815439776572},
+				{74.93276596069336, 22.303708490145645},
+			},
+			"geometry",
+			[]string{"circle1"},
+		},
 
 		// test intersecting linestring query for linestring1.
-		{[][]float64{{74.938645362854, 22.321614134448936},
-			{74.94070529937744, 22.320224643365446}},
-			"geometry", []string{"linestring1"}},
+		{
+			[][]float64{
+				{74.938645362854, 22.321614134448936},
+				{74.94070529937744, 22.320224643365446},
+			},
+			"geometry",
+			[]string{"linestring1"},
+		},
 
 		// test intersecting linestring query for multilinestring1.
-		{[][]float64{{74.9241828918457, 22.307996525380194},
-			{74.94100570678711, 22.293781977618558}},
-			"geometry", []string{"multilinestring1"}},
+		{
+			[][]float64{
+				{74.9241828918457, 22.307996525380194},
+				{74.94100570678711, 22.293781977618558},
+			},
+			"geometry",
+			[]string{"multilinestring1"},
+		},
 
 		// test intersecting linestring query for multipolygon1.
-		{[][]float64{{36.22072219848633, 50.007132228568786},
-			{36.22218132019043, 49.99791917183082}},
-			"geometry", []string{"multipolygon1"}},
+		{
+			[][]float64{
+				{36.22072219848633, 50.007132228568786},
+				{36.22218132019043, 49.99791917183082},
+			},
+			"geometry",
+			[]string{"multipolygon1"},
+		},
 
 		// test intersecting linestring query for envelope2, circle2,
 		// multipolygon1 and gc_polygonInGc_multipolygonInGc.
-		{[][]float64{{36.19840621948242, 50.03834418692451},
-			{36.25720024108887, 50.02136210283289}}, "geometry",
-			[]string{"envelope2", "circle2", "multipolygon1", "gc_polygonInGc_multipolygonInGc"}},
+		{
+			[][]float64{
+				{36.19840621948242, 50.03834418692451},
+				{36.25720024108887, 50.02136210283289},
+			},
+			"geometry",
+			[]string{"envelope2", "circle2", "multipolygon1", "gc_polygonInGc_multipolygonInGc"},
+		},
 	}
 	i := setupGeoJsonShapesIndexForLinestringQuery(t)
 	indexReader, err := i.Reader()
@@ -105,34 +146,60 @@ func TestGeoJsonLinestringContainsQuery(t *testing.T) {
 		want  []string
 	}{
 		// test a linestring query for multipolygon1.
-		{[][]float64{{36.21668815612793, 50.040494087443996},
-			{36.226301193237305, 50.03861982057644}},
-			"geometry", []string{"multipolygon1"}},
+		{
+			[][]float64{
+				{36.21668815612793, 50.040494087443996},
+				{36.226301193237305, 50.03861982057644},
+			},
+			"geometry",
+			[]string{"multipolygon1"},
+		},
 
 		// test a linestring query with endspoints on two
 		// different polygons in a multipolygon.
-		{[][]float64{{36.19746208190918, 50.038564693972646},
-			{36.21565818786621, 50.03718650830641}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{36.19746208190918, 50.038564693972646},
+				{36.21565818786621, 50.03718650830641},
+			},
+			"geometry", nil,
+		},
 
 		// test a linestring query for envelope2.
-		{[][]float64{{36.25290870666503, 50.03018471417061},
-			{36.23110771179199, 50.01854955486945}},
-			"geometry", []string{"envelope2"}},
+		{
+			[][]float64{
+				{36.25290870666503, 50.03018471417061},
+				{36.23110771179199, 50.01854955486945},
+			},
+			"geometry",
+			[]string{"envelope2"},
+		},
 
 		// test a linestring query for circle2.
-		{[][]float64{{36.220550537109375, 50.02930252595981},
-			{36.224327087402344, 50.02847545979485}},
-			"geometry", []string{"circle2"}},
+		{
+			[][]float64{
+				{36.220550537109375, 50.02930252595981},
+				{36.224327087402344, 50.02847545979485},
+			},
+			"geometry",
+			[]string{"circle2"},
+		},
 
 		// test a linestring query for polygonWithHole2.
-		{[][]float64{{36.27367973327637, 49.89883638369706},
-			{36.27445220947265, 49.89596137883285}},
-			"geometry", []string{"polygonWithHole2"}},
+		{
+			[][]float64{
+				{36.27367973327637, 49.89883638369706},
+				{36.27445220947265, 49.89596137883285},
+			},
+			"geometry",
+			[]string{"polygonWithHole2"},
+		},
 
 		// test a linestring query within the hole of polygonWithHole2.
-		{[][]float64{{36.261234283447266, 49.89540847364305},
-			{36.26243591308594, 49.89087441212101}}, "geometry", nil},
+		{[][]float64{
+			{36.261234283447266, 49.89540847364305},
+			{36.26243591308594, 49.89087441212101},
+		}, "geometry", nil},
 	}
 	i := setupGeoJsonShapesIndexForLinestringQuery(t)
 	indexReader, err := i.Reader()
@@ -166,51 +233,101 @@ func TestGeoJsonMultiLinestringContainsQuery(t *testing.T) {
 		want  []string
 	}{
 		// test a multilinestring query for multipolygon1.
-		{[][][]float64{{{36.21668815612793, 50.040494087443996},
-			{36.226301193237305, 50.03861982057644}},
-			{{36.226816177368164, 49.999463999158},
-				{36.234025955200195, 50.00271900853649}}},
-			"geometry", []string{"multipolygon1"}},
+		{
+			[][][]float64{
+				{
+					{36.21668815612793, 50.040494087443996},
+					{36.226301193237305, 50.03861982057644},
+				},
+				{
+					{36.226816177368164, 49.999463999158},
+					{36.234025955200195, 50.00271900853649},
+				},
+			},
+			"geometry",
+			[]string{"multipolygon1"},
+		},
 
 		// test a multilinestring query that is covered by the geometryCollection.
-		{[][][]float64{{{36.28664016723633, 49.96574238290487},
-			{36.30251884460449, 49.96369956194569}}, {{36.19179725646973, 50.03983258984584},
-			{36.19420051574707, 50.03801342445342}}}, "geometry",
-			[]string{"gc_polygonInGc_multipolygonInGc"}},
+		{
+			[][][]float64{{
+				{36.28664016723633, 49.96574238290487},
+				{36.30251884460449, 49.96369956194569},
+			}, {
+				{36.19179725646973, 50.03983258984584},
+				{36.19420051574707, 50.03801342445342},
+			}},
+			"geometry",
+			[]string{"gc_polygonInGc_multipolygonInGc"},
+		},
 
 		// test a multilinestring query for envelope2.
-		{[][][]float64{{{36.23213768005371, 50.02913711386621},
-			{36.25187873840332, 50.02902683882067}},
-			{{36.231794357299805, 50.018935600613254},
-				{36.2314510345459, 50.025883893582055}}}, "geometry",
-			[]string{"envelope2"}},
+		{
+			[][][]float64{
+				{
+					{36.23213768005371, 50.02913711386621},
+					{36.25187873840332, 50.02902683882067},
+				},
+				{
+					{36.231794357299805, 50.018935600613254},
+					{36.2314510345459, 50.025883893582055},
+				},
+			},
+			"geometry",
+			[]string{"envelope2"},
+		},
 
 		// test a multilinestring query with one linestring outside of envelope2.
-		{[][][]float64{{{36.23213768005371, 50.02913711386621},
-			{36.25187873840332, 50.02902683882067}},
-			{{36.231794357299805, 50.018935600613254}, {36.2314510345459, 50.025883893582055}},
-			{{36.25659942626953, 50.024284772330844}, {36.24406814575195, 50.01518531066489}}},
-			"geometry", nil},
+		{
+			[][][]float64{
+				{
+					{36.23213768005371, 50.02913711386621},
+					{36.25187873840332, 50.02902683882067},
+				},
+				{{36.231794357299805, 50.018935600613254}, {36.2314510345459, 50.025883893582055}},
+				{{36.25659942626953, 50.024284772330844}, {36.24406814575195, 50.01518531066489}},
+			},
+			"geometry", nil,
+		},
 
 		// test a multilinestring query with one linestring
 		// inside the whole of a polygonWithHole2.
-		{[][][]float64{{{36.27367973327637, 49.89883638369706},
-			{36.27445220947265, 49.89596137883285}},
-			{{36.261234283447266, 49.89540847364305}, {36.26243591308594, 49.89087441212101}}},
-			"geometry", nil},
+		{
+			[][][]float64{
+				{
+					{36.27367973327637, 49.89883638369706},
+					{36.27445220947265, 49.89596137883285},
+				},
+				{{36.261234283447266, 49.89540847364305}, {36.26243591308594, 49.89087441212101}},
+			},
+			"geometry", nil,
+		},
 
 		// test a multilinestring query for polygonWithHole2.
-		{[][][]float64{{{36.27367973327637, 49.89883638369706},
-			{36.27445220947265, 49.89596137883285}},
-			{{36.279258728027344, 49.894302644257856}, {36.28166198730469, 49.887335336408235}}},
-			"geometry", []string{"polygonWithHole2"}},
+		{
+			[][][]float64{
+				{
+					{36.27367973327637, 49.89883638369706},
+					{36.27445220947265, 49.89596137883285},
+				},
+				{{36.279258728027344, 49.894302644257856}, {36.28166198730469, 49.887335336408235}},
+			},
+			"geometry",
+			[]string{"polygonWithHole2"},
+		},
 
 		// test a multilinestring query for polygonWithHole2 with last line cross the hole.
-		{[][][]float64{{{36.27367973327637, 49.89883638369706},
-			{36.27445220947265, 49.89596137883285}},
-			{{36.279258728027344, 49.894302644257856}, {36.28166198730469, 49.887335336408235}},
-			{{36.254024505615234, 49.89839408640621}, {36.27016067504883, 49.90038439228633}}},
-			"geometry", nil},
+		{
+			[][][]float64{
+				{
+					{36.27367973327637, 49.89883638369706},
+					{36.27445220947265, 49.89596137883285},
+				},
+				{{36.279258728027344, 49.894302644257856}, {36.28166198730469, 49.887335336408235}},
+				{{36.254024505615234, 49.89839408640621}, {36.27016067504883, 49.90038439228633}},
+			},
+			"geometry", nil,
+		},
 	}
 	i := setupGeoJsonShapesIndexForLinestringQuery(t)
 	indexReader, err := i.Reader()
@@ -238,23 +355,24 @@ func TestGeoJsonMultiLinestringContainsQuery(t *testing.T) {
 }
 
 func runGeoShapeMultiLinestringQueryWithRelation(relation string, i index.IndexReader,
-	points [][][]float64, field string) ([]string, error) {
-
+	points [][][]float64, field string,
+) ([]string, error) {
 	s := geo.NewGeoJsonMultilinestring(points)
 	return executeSearch(relation, i, s, field)
 }
 
 func runGeoShapeLinestringQueryWithRelation(relation string, i index.IndexReader,
-	points [][]float64, field string) ([]string, error) {
-
+	points [][]float64, field string,
+) ([]string, error) {
 	s := geo.NewGeoJsonLinestring(points)
 	return executeSearch(relation, i, s, field)
 }
 
 func executeSearch(relation string, i index.IndexReader,
-	s index.GeoJSON, field string) ([]string, error) {
+	s index.GeoJSON, field string,
+) ([]string, error) {
 	var rv []string
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -290,11 +408,16 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{74.84642028808594, 22.402776071459712},
-		{74.83234405517578, 22.39039647758608}, {74.86719131469727, 22.38801566009795},
-		{74.85139846801758, 22.39103135536648}, {74.86461639404297, 22.394840561182853},
+	polygon1 := [][][][]float64{{{
+		{74.84642028808594, 22.402776071459712},
+		{74.83234405517578, 22.39039647758608},
+		{74.86719131469727, 22.38801566009795},
+		{74.85139846801758, 22.39103135536648},
+		{74.86461639404297, 22.394840561182853},
 		{74.8495101928711, 22.397697397065034},
-		{74.86186981201172, 22.401982540816856}, {74.84642028808594, 22.402776071459712}}}}
+		{74.86186981201172, 22.401982540816856},
+		{74.84642028808594, 22.402776071459712},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, polygon1, "polygon",
@@ -304,12 +427,17 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon2 := [][][][]float64{{{{74.93431091308592, 22.376428433285266},
-		{74.92898941040039, 22.39103135536648}, {74.9241828918457, 22.37722210974017},
-		{74.90821838378906, 22.37388863821397}, {74.92504119873047, 22.369920115637292},
-		{74.92864608764648, 22.355632497760894}, {74.93207931518555, 22.370396344320053},
+	polygon2 := [][][][]float64{{{
+		{74.93431091308592, 22.376428433285266},
+		{74.92898941040039, 22.39103135536648},
+		{74.9241828918457, 22.37722210974017},
+		{74.90821838378906, 22.37388863821397},
+		{74.92504119873047, 22.369920115637292},
+		{74.92864608764648, 22.355632497760894},
+		{74.93207931518555, 22.370396344320053},
 		{74.94855880737305, 22.3743648533201},
-		{74.93431091308592, 22.376428433285266}}}}
+		{74.93431091308592, 22.376428433285266},
+	}}}
 	doc = document.NewDocument("polygon2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, polygon2, "polygon",
@@ -319,8 +447,10 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope1 := [][][][]float64{{{{74.86736297607422, 22.307361269208684},
-		{74.87028121948242, 22.345471522338478}}}}
+	envelope1 := [][][][]float64{{{
+		{74.86736297607422, 22.307361269208684},
+		{74.87028121948242, 22.345471522338478},
+	}}}
 	doc = document.NewDocument("envelope1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, envelope1, "envelope",
@@ -330,8 +460,10 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	envelope2 := [][][][]float64{{{{36.23007774353027, 50.01810835593541},
-		{36.25333786010742, 50.03068093791795}}}}
+	envelope2 := [][][][]float64{{{
+		{36.23007774353027, 50.01810835593541},
+		{36.25333786010742, 50.03068093791795},
+	}}}
 	doc = document.NewDocument("envelope2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, envelope2, "envelope",
@@ -359,8 +491,10 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring := [][][][]float64{{{{74.92697238922119, 22.320343743143248},
-		{74.94036197662354, 22.32054224254707}}}}
+	linestring := [][][][]float64{{{
+		{74.92697238922119, 22.320343743143248},
+		{74.94036197662354, 22.32054224254707},
+	}}}
 	doc = document.NewDocument("linestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, linestring, "linestring",
@@ -370,8 +504,10 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring1 := [][][][]float64{{{{77.60188579559325, 12.982604078764705},
-		{77.60557651519775, 12.987329508048184}}}}
+	linestring1 := [][][][]float64{{{
+		{77.60188579559325, 12.982604078764705},
+		{77.60557651519775, 12.987329508048184},
+	}}}
 	doc = document.NewDocument("linestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, linestring1, "linestring",
@@ -381,10 +517,14 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring := [][][][]float64{{{{74.92203712463379, 22.3113315728684},
-		{74.92323875427246, 22.307798008137024}},
+	multilinestring := [][][][]float64{{
+		{
+			{74.92203712463379, 22.3113315728684},
+			{74.92323875427246, 22.307798008137024},
+		},
 		{{74.92405414581299, 22.307559787072712}, {74.92735862731934, 22.310021385140573}},
-		{{74.9223804473877, 22.311688894660474}, {74.92534160614014, 22.30930673210729}}}}
+		{{74.9223804473877, 22.311688894660474}, {74.92534160614014, 22.30930673210729}},
+	}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, multilinestring, "multilinestring",
@@ -394,10 +534,14 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring1 := [][][][]float64{{{{77.6015853881836, 12.990089451715061},
-		{77.60476112365723, 12.987747683302153}},
+	multilinestring1 := [][][][]float64{{
+		{
+			{77.6015853881836, 12.990089451715061},
+			{77.60476112365723, 12.987747683302153},
+		},
 		{{77.59875297546387, 12.988751301039581}, {77.59446144104004, 12.98197680263484}},
-		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}}}}
+		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}},
+	}}
 	doc = document.NewDocument("multilinestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, multilinestring1, "multilinestring",
@@ -407,9 +551,11 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{77.56618022918701, 12.958180959662695},
+	multipoint1 := [][][][]float64{{{
+		{77.56618022918701, 12.958180959662695},
 		{77.56407737731932, 12.951614746607163},
-		{77.56922721862793, 12.956173473406446}}}}
+		{77.56922721862793, 12.956173473406446},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, multipoint1, "multipoint",
@@ -420,12 +566,22 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 	}
 
 	polygonWithHole1 := [][][][]float64{{
-		{{77.59991168975829, 12.972232910164502}, {77.6039457321167, 12.97582941279006},
-			{77.60424613952637, 12.98168407323241}, {77.59974002838135, 12.985489528568463},
-			{77.59321689605713, 12.979300406693417}, {77.59991168975829, 12.972232910164502}},
-		{{77.59682178497314, 12.975787593290978}, {77.60295867919922, 12.975787593290978},
-			{77.60295867919922, 12.98143316204164}, {77.59682178497314, 12.98143316204164},
-			{77.59682178497314, 12.975787593290978}}}}
+		{
+			{77.59991168975829, 12.972232910164502},
+			{77.6039457321167, 12.97582941279006},
+			{77.60424613952637, 12.98168407323241},
+			{77.59974002838135, 12.985489528568463},
+			{77.59321689605713, 12.979300406693417},
+			{77.59991168975829, 12.972232910164502},
+		},
+		{
+			{77.59682178497314, 12.975787593290978},
+			{77.60295867919922, 12.975787593290978},
+			{77.60295867919922, 12.98143316204164},
+			{77.59682178497314, 12.98143316204164},
+			{77.59682178497314, 12.975787593290978},
+		},
+	}}
 
 	doc = document.NewDocument("polygonWithHole1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
@@ -437,15 +593,25 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 	}
 
 	polygonWithHole2 := [][][][]float64{{
-		{{36.261234283447266, 49.90712870720605}, {36.2479305267334, 49.89480027061714},
-			{36.254539489746094, 49.883408870659736}, {36.280717849731445, 49.883408870659736},
-			{36.28741264343262, 49.890432041848264}, {36.27788543701172, 49.90276159448742},
-			{36.261234283447266, 49.90712870720605}},
+		{
+			{36.261234283447266, 49.90712870720605},
+			{36.2479305267334, 49.89480027061714},
+			{36.254539489746094, 49.883408870659736},
+			{36.280717849731445, 49.883408870659736},
+			{36.28741264343262, 49.890432041848264},
+			{36.27788543701172, 49.90276159448742},
+			{36.261234283447266, 49.90712870720605},
+		},
 
-		{{36.264581680297844, 49.905249238801304}, {36.25368118286133, 49.89673543545543},
-			{36.253509521484375, 49.88578690918283}, {36.270332336425774, 49.886174020645804},
+		{
+			{36.264581680297844, 49.905249238801304},
+			{36.25368118286133, 49.89673543545543},
+			{36.253509521484375, 49.88578690918283},
+			{36.270332336425774, 49.886174020645804},
 			{36.27127647399902, 49.89579550794111},
-			{36.264581680297844, 49.905249238801304}}}}
+			{36.264581680297844, 49.905249238801304},
+		},
+	}}
 
 	doc = document.NewDocument("polygonWithHole2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
@@ -456,16 +622,29 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipolygon1 := [][][][]float64{{{{36.1875057220459, 50.04363607656457},
-		{36.192398071289055, 50.034871067327856}, {36.20218276977539, 50.03955696315653},
-		{36.1875057220459, 50.04363607656457}}}, // polygon1
-		{{{36.2123966217041, 50.03795829715335}, {36.218318939208984, 50.0333273779768},
-			{36.226558685302734, 50.03867494711694}, {36.217031478881836, 50.04286437899031},
-			{36.2123966217041, 50.03795829715335}}}, // polygon2
-		{{{36.221065521240234, 50.00365685169585}, {36.226301193237305, 49.998029518286025},
-			{36.23342514038086, 49.9995743420677}, {36.23531341552734, 50.002994846659156},
-			{36.231021881103516, 50.00630478067617}, {36.22810363769531, 50.00663576154257},
-			{36.226043701171875, 50.004815338573046}, {36.221065521240234, 50.00365685169585}}}}
+	multipolygon1 := [][][][]float64{{{
+		{36.1875057220459, 50.04363607656457},
+		{36.192398071289055, 50.034871067327856},
+		{36.20218276977539, 50.03955696315653},
+		{36.1875057220459, 50.04363607656457},
+	}}, // polygon1
+		{{
+			{36.2123966217041, 50.03795829715335},
+			{36.218318939208984, 50.0333273779768},
+			{36.226558685302734, 50.03867494711694},
+			{36.217031478881836, 50.04286437899031},
+			{36.2123966217041, 50.03795829715335},
+		}}, // polygon2
+		{{
+			{36.221065521240234, 50.00365685169585},
+			{36.226301193237305, 49.998029518286025},
+			{36.23342514038086, 49.9995743420677},
+			{36.23531341552734, 50.002994846659156},
+			{36.231021881103516, 50.00630478067617},
+			{36.22810363769531, 50.00663576154257},
+			{36.226043701171875, 50.004815338573046},
+			{36.221065521240234, 50.00365685169585},
+		}}}
 	doc = document.NewDocument("multipolygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry",
 		[]uint64{}, multipolygon1, "multipolygon",
@@ -475,14 +654,24 @@ func setupGeoJsonShapesIndexForLinestringQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygonInGc := [][][][]float64{{{{36.1875057220459, 50.04363607656457},
-		{36.192398071289055, 50.034871067327856}, {36.20218276977539, 50.03955696315653},
-		{36.1875057220459, 50.04363607656457}}}}
-	multipolygonInGc := [][][][]float64{{{{36.29015922546387, 49.980150089789376},
-		{36.28337860107422, 49.961656654293485}, {36.307411193847656, 49.96033147865059},
-		{36.29015922546387, 49.980150089789376}}}, // polygon1
-		{{{36.16106986999512, 50.00387751801547}, {36.161842346191406, 49.9908012905034},
-			{36.17900848388672, 49.99841572888488}, {36.16106986999512, 50.00387751801547}}}}
+	polygonInGc := [][][][]float64{{{
+		{36.1875057220459, 50.04363607656457},
+		{36.192398071289055, 50.034871067327856},
+		{36.20218276977539, 50.03955696315653},
+		{36.1875057220459, 50.04363607656457},
+	}}}
+	multipolygonInGc := [][][][]float64{{{
+		{36.29015922546387, 49.980150089789376},
+		{36.28337860107422, 49.961656654293485},
+		{36.307411193847656, 49.96033147865059},
+		{36.29015922546387, 49.980150089789376},
+	}}, // polygon1
+		{{
+			{36.16106986999512, 50.00387751801547},
+			{36.161842346191406, 49.9908012905034},
+			{36.17900848388672, 49.99841572888488},
+			{36.16106986999512, 50.00387751801547},
+		}}}
 	coordinates := [][][][][]float64{polygonInGc, multipolygonInGc}
 	types := []string{"polygon", "multipolygon"}
 	doc = document.NewDocument("gc_polygonInGc_multipolygonInGc")
diff --git a/search/searcher/search_geoshape_points_test.go b/search/searcher/search_geoshape_points_test.go
index adaf465e..21fe3a9f 100644
--- a/search/searcher/search_geoshape_points_test.go
+++ b/search/searcher/search_geoshape_points_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -33,44 +34,70 @@ func TestGeoJsonPointContainsQuery(t *testing.T) {
 		want  []string
 	}{
 		// test points inside the polygon1.
-		{[]float64{77.58334636688232, 12.948268838994263},
-			"geometry", []string{"polygon1"}},
+		{
+			[]float64{77.58334636688232, 12.948268838994263},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test points inside the circle1.
-		{[]float64{77.58553504943848, 12.954040501528555},
-			"geometry", []string{"circle1"}},
+		{
+			[]float64{77.58553504943848, 12.954040501528555},
+			"geometry",
+			[]string{"circle1"},
+		},
 
 		// test points inside the polygon1 and the circle.
-		{[]float64{77.59293794631958, 12.948896200093982},
-			"geometry", []string{"polygon1", "circle1"}},
+		{
+			[]float64{77.59293794631958, 12.948896200093982},
+			"geometry",
+			[]string{"polygon1", "circle1"},
+		},
 
 		// test points outside the polygon1 and the circle1.
-		{[]float64{77.5614595413208, 12.953287683563568},
-			"geometry", nil},
+		{
+			[]float64{77.5614595413208, 12.953287683563568},
+			"geometry", nil,
+		},
 
 		// test point within the envelope1.
-		{[]float64{81.28166198730469, 26.34203746601541},
-			"geometry", []string{"envelope1"}},
+		{
+			[]float64{81.28166198730469, 26.34203746601541},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test point on the linestring vertex.
-		{[]float64{77.57776737213135, 12.952074805390097},
-			"geometry", nil},
+		{
+			[]float64{77.57776737213135, 12.952074805390097},
+			"geometry", nil,
+		},
 
 		// test point on the multilinestring vertex.
-		{[]float64{77.5779390335083, 12.945006535817749},
-			"geometry", nil},
+		{
+			[]float64{77.5779390335083, 12.945006535817749},
+			"geometry", nil,
+		},
 
 		// test point on the multipoint vertex.
-		{[]float64{77.56407737731932, 12.951614746607163},
-			"geometry", []string{"multipoint1"}},
+		{
+			[]float64{77.56407737731932, 12.951614746607163},
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test point within the polygonWithHole1.
-		{[]float64{77.60334491729736, 12.979844051951334},
-			"geometry", []string{"polygonWithHole1"}},
+		{
+			[]float64{77.60334491729736, 12.979844051951334},
+			"geometry",
+			[]string{"polygonWithHole1"},
+		},
 
 		// test point within the hole of the polygonWithHole1.
-		{[]float64{77.60244369506836, 12.976247607394027},
-			"geometry", nil},
+		{
+			[]float64{77.60244369506836, 12.976247607394027},
+			"geometry", nil,
+		},
 	}
 	i := setupGeoJsonShapesIndex(t)
 	indexReader, err := i.Reader()
@@ -104,67 +131,118 @@ func TestGeoJsonMultiPointWithInQuery(t *testing.T) {
 		want       []string
 	}{
 		// test multipoint inside the polygon1.
-		{[][]float64{{77.58334636688232, 12.948268838994263},
-			{77.58467674255371, 12.944295515355652}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][]float64{
+				{77.58334636688232, 12.948268838994263},
+				{77.58467674255371, 12.944295515355652},
+			},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test multipoint inside the circle1.
-		{[][]float64{{77.58553504943848, 12.954040501528555},
-			{77.58643627166747, 12.956089827794571}},
-			"geometry", []string{"circle1"}},
+		{
+			[][]float64{
+				{77.58553504943848, 12.954040501528555},
+				{77.58643627166747, 12.956089827794571},
+			},
+			"geometry",
+			[]string{"circle1"},
+		},
 
 		// test multipoint inside the envelope1.
-		{[][]float64{{81.28166198730469, 26.34203746601541},
-			{80.94314575195312, 26.346960121309415}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][]float64{
+				{81.28166198730469, 26.34203746601541},
+				{80.94314575195312, 26.346960121309415},
+			},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test multipoint inside the polygon1 and the circle.
-		{[][]float64{{77.59293794631958, 12.948896200093982},
-			{77.58532047271729, 12.953789562459688}},
-			"geometry", []string{"polygon1", "circle1"}},
+		{
+			[][]float64{
+				{77.59293794631958, 12.948896200093982},
+				{77.58532047271729, 12.953789562459688},
+			},
+			"geometry",
+			[]string{"polygon1", "circle1"},
+		},
 
 		// test multipoint (only 1 point outside) outside.
-		{[][]float64{{77.58334636688232, 12.948268838994263},
+		{[][]float64{
+			{77.58334636688232, 12.948268838994263},
 			{77.58643627166747, 12.956089827794571},
-			{77.5615, 12.9533}}, "geometry", nil},
+			{77.5615, 12.9533},
+		}, "geometry", nil},
 
 		// test multipoint on the linestring vertex.
-		{[][]float64{{77.5841188430786, 12.957093573282744},
-			{77.57776737213135, 12.952074805390097}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.5841188430786, 12.957093573282744},
+				{77.57776737213135, 12.952074805390097},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint outside the linestring vertex.
-		{[][]float64{{77.5841188430786, 12.957093573282744},
-			{77.57776737213135, 12.952074805390097},
-			{77.58334636688232, 12.948268838994263}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.5841188430786, 12.957093573282744},
+				{77.57776737213135, 12.952074805390097},
+				{77.58334636688232, 12.948268838994263},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint on the multilinestring vertex.
-		{[][]float64{{77.5779390335083, 12.94471376293191},
-			{77.57218837738037, 12.948268838994263}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.5779390335083, 12.94471376293191},
+				{77.57218837738037, 12.948268838994263},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint outside the multilinestring vertex.
-		{[][]float64{{77.5779390335083, 12.94471376293191},
-			{77.57218837738037, 12.948268838994263},
-			{77.58532047271729, 12.953789562459688}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.5779390335083, 12.94471376293191},
+				{77.57218837738037, 12.948268838994263},
+				{77.58532047271729, 12.953789562459688},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint with one inside the hole within the polygonWithHole1.
-		{[][]float64{{77.60334491729736, 12.979844051951334},
-			{77.60244369506836, 12.976247607394027}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.60334491729736, 12.979844051951334},
+				{77.60244369506836, 12.976247607394027},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint with all inside the hole witin the polygonWithHole1.
-		{[][]float64{{77.59656429290771, 12.981767710239714},
-			{77.59888172149658, 12.979969508380469}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.59656429290771, 12.981767710239714},
+				{77.59888172149658, 12.979969508380469},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint with all inside the polygonWithHole1.
-		{[][]float64{{77.60334491729736, 12.979844051951334},
-			{77.59656429290771, 12.981767710239714},
-			{77.59802341461182, 12.9751602999608}},
-			"geometry", []string{"polygonWithHole1"}},
+		{
+			[][]float64{
+				{77.60334491729736, 12.979844051951334},
+				{77.59656429290771, 12.981767710239714},
+				{77.59802341461182, 12.9751602999608},
+			},
+			"geometry",
+			[]string{"polygonWithHole1"},
+		},
 	}
 	i := setupGeoJsonShapesIndex(t)
 	indexReader, err := i.Reader()
@@ -198,69 +276,128 @@ func TestGeoJsonMultiPointIntersectsQuery(t *testing.T) {
 		want       []string
 	}{
 		// test multipoint inside the polygon1.
-		{[][]float64{{77.58334636688232, 12.948268838994263},
-			{77.58467674255371, 12.944295515355652}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][]float64{
+				{77.58334636688232, 12.948268838994263},
+				{77.58467674255371, 12.944295515355652},
+			},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test multipoint inside the circle1.
-		{[][]float64{{77.58553504943848, 12.954040501528555},
-			{77.58643627166747, 12.956089827794571}},
-			"geometry", []string{"circle1"}},
+		{
+			[][]float64{
+				{77.58553504943848, 12.954040501528555},
+				{77.58643627166747, 12.956089827794571},
+			},
+			"geometry",
+			[]string{"circle1"},
+		},
 
 		// test multipoint inside the envelope1. (1 point outside)
-		{[][]float64{{81.28166198730469, 26.34203746601541},
-			{80.94314575195312, 26.346960121309415},
-			{81.12716674804688, 26.353728430338332}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][]float64{
+				{81.28166198730469, 26.34203746601541},
+				{80.94314575195312, 26.346960121309415},
+				{81.12716674804688, 26.353728430338332},
+			},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test multipoint inside the polygon1 and the circle.
-		{[][]float64{{77.59293794631958, 12.948896200093982},
-			{77.58532047271729, 12.953789562459688}},
-			"geometry", []string{"polygon1", "circle1"}},
+		{
+			[][]float64{
+				{77.59293794631958, 12.948896200093982},
+				{77.58532047271729, 12.953789562459688},
+			},
+			"geometry",
+			[]string{"polygon1", "circle1"},
+		},
 
 		// test multipoint (only 1 point outside) intersects.
-		{[][]float64{{77.58334636688232, 12.948268838994263},
-			{77.58643627166747, 12.956089827794571},
-			{77.5615, 12.9533}}, "geometry",
-			[]string{"polygon1", "circle1"}},
+		{
+			[][]float64{
+				{77.58334636688232, 12.948268838994263},
+				{77.58643627166747, 12.956089827794571},
+				{77.5615, 12.9533},
+			},
+			"geometry",
+			[]string{"polygon1", "circle1"},
+		},
 
 		// test multipoint on the linestring vertex.
-		{[][]float64{{77.5841188430786, 12.957093573282744},
-			{77.57776737213135, 12.952074805390097}},
-			"geometry", []string{"linestring1"}},
+		{
+			[][]float64{
+				{77.5841188430786, 12.957093573282744},
+				{77.57776737213135, 12.952074805390097},
+			},
+			"geometry",
+			[]string{"linestring1"},
+		},
 
 		// test multipoint outside the linestring vertex.
-		{[][]float64{{77.5841188430786, 12.957093573282744},
-			{77.57776737213135, 12.952074805390097},
-			{77.58334636688232, 12.948268838994263}},
-			"geometry", []string{"polygon1", "linestring1"}},
+		{
+			[][]float64{
+				{77.5841188430786, 12.957093573282744},
+				{77.57776737213135, 12.952074805390097},
+				{77.58334636688232, 12.948268838994263},
+			},
+			"geometry",
+			[]string{"polygon1", "linestring1"},
+		},
 
 		// test multipoint on the multilinestring vertex.
-		{[][]float64{{77.5779390335083, 12.94471376293191},
-			{77.57218837738037, 12.948268838994263}},
-			"geometry", []string{"multilinestring1"}},
+		{
+			[][]float64{
+				{77.5779390335083, 12.94471376293191},
+				{77.57218837738037, 12.948268838994263},
+			},
+			"geometry",
+			[]string{"multilinestring1"},
+		},
 
 		// test multipoint outside the multilinestring vertex.
-		{[][]float64{{77.5779390335083, 12.94471376293191},
-			{77.57218837738037, 12.948268838994263},
-			{77.58532047271729, 12.953789562459688}},
-			"geometry", []string{"polygon1", "circle1", "multilinestring1"}},
+		{
+			[][]float64{
+				{77.5779390335083, 12.94471376293191},
+				{77.57218837738037, 12.948268838994263},
+				{77.58532047271729, 12.953789562459688},
+			},
+			"geometry",
+			[]string{"polygon1", "circle1", "multilinestring1"},
+		},
 
 		// test multipoint with one inside the hole within the polygonWithHole1.
-		{[][]float64{{77.60334491729736, 12.979844051951334},
-			{77.60244369506836, 12.976247607394027}},
-			"geometry", []string{"polygonWithHole1"}},
+		{
+			[][]float64{
+				{77.60334491729736, 12.979844051951334},
+				{77.60244369506836, 12.976247607394027},
+			},
+			"geometry",
+			[]string{"polygonWithHole1"},
+		},
 
 		// test multipoint with all inside the hole witin the polygonWithHole1.
-		{[][]float64{{77.60244369506836, 12.976247607394027},
-			{77.59888172149658, 12.979969508380469}},
-			"geometry", nil},
+		{
+			[][]float64{
+				{77.60244369506836, 12.976247607394027},
+				{77.59888172149658, 12.979969508380469},
+			},
+			"geometry", nil,
+		},
 
 		// test multipoint with all inside the polygonWithHole1.
-		{[][]float64{{77.60334491729736, 12.979844051951334},
-			{77.59656429290771, 12.981767710239714},
-			{77.59802341461182, 12.9751602999608}},
-			"geometry", []string{"polygonWithHole1"}},
+		{
+			[][]float64{
+				{77.60334491729736, 12.979844051951334},
+				{77.59656429290771, 12.981767710239714},
+				{77.59802341461182, 12.9751602999608},
+			},
+			"geometry",
+			[]string{"polygonWithHole1"},
+		},
 	}
 	i := setupGeoJsonShapesIndex(t)
 	indexReader, err := i.Reader()
@@ -288,7 +425,8 @@ func TestGeoJsonMultiPointIntersectsQuery(t *testing.T) {
 }
 
 func runGeoShapePointRelationQuery(relation string, multi bool,
-	i index.IndexReader, points [][]float64, field string) ([]string, error) {
+	i index.IndexReader, points [][]float64, field string,
+) ([]string, error) {
 	var rv []string
 	var s index.GeoJSON
 	if multi {
@@ -297,7 +435,7 @@ func runGeoShapePointRelationQuery(relation string, multi bool,
 		s = geo.NewGeoJsonPoint(points[0])
 	}
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -337,16 +475,26 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{77.5853419303894, 12.953977766785052},
-		{77.58405447006226, 12.95393594361393}, {77.5819730758667, 12.9495026476557},
-		{77.58068561553955, 12.94883346405509}, {77.58019208908081, 12.948331575175299},
-		{77.57991313934326, 12.943814529775414}, {77.58497714996338, 12.94394000436408},
-		{77.58517026901245, 12.9446301134728}, {77.58572816848755, 12.945508431393435},
-		{77.58785247802734, 12.946365833997325}, {77.58967638015747, 12.946428570657417},
-		{77.59070634841918, 12.947474179333993}, {77.59317398071289, 12.948875288082773},
-		{77.59167194366454, 12.949962710338657}, {77.59077072143555, 12.950276388953625},
-		{77.59098529815674, 12.951196510612728}, {77.58729457855225, 12.952472128200755},
-		{77.5853419303894, 12.953977766785052}}}}
+	polygon1 := [][][][]float64{{{
+		{77.5853419303894, 12.953977766785052},
+		{77.58405447006226, 12.95393594361393},
+		{77.5819730758667, 12.9495026476557},
+		{77.58068561553955, 12.94883346405509},
+		{77.58019208908081, 12.948331575175299},
+		{77.57991313934326, 12.943814529775414},
+		{77.58497714996338, 12.94394000436408},
+		{77.58517026901245, 12.9446301134728},
+		{77.58572816848755, 12.945508431393435},
+		{77.58785247802734, 12.946365833997325},
+		{77.58967638015747, 12.946428570657417},
+		{77.59070634841918, 12.947474179333993},
+		{77.59317398071289, 12.948875288082773},
+		{77.59167194366454, 12.949962710338657},
+		{77.59077072143555, 12.950276388953625},
+		{77.59098529815674, 12.951196510612728},
+		{77.58729457855225, 12.952472128200755},
+		{77.5853419303894, 12.953977766785052},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -356,8 +504,10 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 	}
 
 	// not working envelope
-	envelope1 := [][][][]float64{{{{80.93696594238281, 26.33957605983274},
-		{81.28440856933594, 26.351267272877074}}}}
+	envelope1 := [][][][]float64{{{
+		{80.93696594238281, 26.33957605983274},
+		{81.28440856933594, 26.351267272877074},
+	}}}
 	doc = document.NewDocument("envelope1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope1, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -375,8 +525,10 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring := [][][][]float64{{{{77.5841188430786, 12.957093573282744},
-		{77.57776737213135, 12.952074805390097}}}}
+	linestring := [][][][]float64{{{
+		{77.5841188430786, 12.957093573282744},
+		{77.57776737213135, 12.952074805390097},
+	}}}
 	doc = document.NewDocument("linestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -385,10 +537,14 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring := [][][][]float64{{{{77.57227420806883, 12.948687079902895},
-		{77.57600784301758, 12.954165970968194}, {77.5779390335083, 12.94471376293191},
-		{77.57218837738037, 12.948268838994263}, {77.57781028747559, 12.951740217268595},
-		{77.5779390335083, 12.945006535817749}}}}
+	multilinestring := [][][][]float64{{{
+		{77.57227420806883, 12.948687079902895},
+		{77.57600784301758, 12.954165970968194},
+		{77.5779390335083, 12.94471376293191},
+		{77.57218837738037, 12.948268838994263},
+		{77.57781028747559, 12.951740217268595},
+		{77.5779390335083, 12.945006535817749},
+	}}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -397,8 +553,11 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{77.56618022918701, 12.958180959662695},
-		{77.56407737731932, 12.951614746607163}, {77.56922721862793, 12.956173473406446}}}}
+	multipoint1 := [][][][]float64{{{
+		{77.56618022918701, 12.958180959662695},
+		{77.56407737731932, 12.951614746607163},
+		{77.56922721862793, 12.956173473406446},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipoint1, "multipoint", document.DefaultGeoShapeIndexingOptions))
@@ -408,12 +567,22 @@ func setupGeoJsonShapesIndex(t *testing.T) index.Index {
 	}
 
 	polygonWithHole1 := [][][][]float64{{
-		{{77.59991168975829, 12.972232910164502}, {77.6039457321167, 12.97582941279006},
-			{77.60424613952637, 12.98168407323241}, {77.59974002838135, 12.985489528568463},
-			{77.59321689605713, 12.979300406693417}, {77.59991168975829, 12.972232910164502}},
-		{{77.59682178497314, 12.975787593290978}, {77.60295867919922, 12.975787593290978},
-			{77.60295867919922, 12.98143316204164}, {77.59682178497314, 12.98143316204164},
-			{77.59682178497314, 12.975787593290978}}}}
+		{
+			{77.59991168975829, 12.972232910164502},
+			{77.6039457321167, 12.97582941279006},
+			{77.60424613952637, 12.98168407323241},
+			{77.59974002838135, 12.985489528568463},
+			{77.59321689605713, 12.979300406693417},
+			{77.59991168975829, 12.972232910164502},
+		},
+		{
+			{77.59682178497314, 12.975787593290978},
+			{77.60295867919922, 12.975787593290978},
+			{77.60295867919922, 12.98143316204164},
+			{77.59682178497314, 12.98143316204164},
+			{77.59682178497314, 12.975787593290978},
+		},
+	}}
 
 	doc = document.NewDocument("polygonWithHole1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
diff --git a/search/searcher/search_geoshape_polygon_test.go b/search/searcher/search_geoshape_polygon_test.go
index c322ee20..98be1c48 100644
--- a/search/searcher/search_geoshape_polygon_test.go
+++ b/search/searcher/search_geoshape_polygon_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"reflect"
 	"testing"
 
@@ -33,57 +34,100 @@ func TestGeoJsonPolygonIntersectsQuery(t *testing.T) {
 		want    []string
 	}{
 		// test intersecting query polygon for polygon1.
-		{[][][]float64{{{77.57926940917969, 12.945257483731918},
-			{77.57875442504883, 12.942036966318216}, {77.58278846740721, 12.9424970427816},
-			{77.57926940917969, 12.945257483731918}}}, "geometry", []string{"polygon1"}},
+		{[][][]float64{{
+			{77.57926940917969, 12.945257483731918},
+			{77.57875442504883, 12.942036966318216},
+			{77.58278846740721, 12.9424970427816},
+			{77.57926940917969, 12.945257483731918},
+		}}, "geometry", []string{"polygon1"}},
 
 		// test intersecting query polygon for polygon1, polygon2, circle1.
-		{[][][]float64{{{77.59562015533446, 12.94099133483504},
-			{77.59665012359619, 12.949356263896634}, {77.59313106536865, 12.951321981484776},
-			{77.59085655212402, 12.948477959536318}, {77.59562015533446, 12.94099133483504}}},
-			"geometry", []string{"polygon1", "polygon2", "circle1"}},
+		{
+			[][][]float64{{
+				{77.59562015533446, 12.94099133483504},
+				{77.59665012359619, 12.949356263896634},
+				{77.59313106536865, 12.951321981484776},
+				{77.59085655212402, 12.948477959536318},
+				{77.59562015533446, 12.94099133483504},
+			}},
+			"geometry",
+			[]string{"polygon1", "polygon2", "circle1"},
+		},
 
 		// test intersecting query polygon for polygon1, polygon2 and polygon3.
-		{[][][]float64{{{77.5929594039917, 12.939151012774925},
-			{77.58321762084961, 12.94546660680072}, {77.59737968444824, 12.931998723107322},
-			{77.60111331939697, 12.955169724209911}, {77.59592056274414, 12.936265025833965},
+		{[][][]float64{{
+			{77.5929594039917, 12.939151012774925},
+			{77.58321762084961, 12.94546660680072},
+			{77.59737968444824, 12.931998723107322},
+			{77.60111331939697, 12.955169724209911},
+			{77.59592056274414, 12.936265025833965},
 			{77.5929594039917, 12.939151012774925},
 		}}, "geometry", []string{"polygon1", "polygon2", "polygon3"}},
 
 		// test intersecting query polygon for polygon2 and the circle1.
-		{[][][]float64{{{77.59012699127197, 12.959853852513307},
-			{77.59836673736572, 12.959853852513307}, {77.59836673736572, 12.965541604118611},
-			{77.59012699127197, 12.965541604118611}, {77.59012699127197, 12.959853852513307}}},
-			"geometry", []string{"polygon2", "circle1"}},
+		{
+			[][][]float64{{
+				{77.59012699127197, 12.959853852513307},
+				{77.59836673736572, 12.959853852513307},
+				{77.59836673736572, 12.965541604118611},
+				{77.59012699127197, 12.965541604118611},
+				{77.59012699127197, 12.959853852513307},
+			}},
+			"geometry",
+			[]string{"polygon2", "circle1"},
+		},
 
 		// test intersecting query polygon for linestring2 and multilinestring2.
-		{[][][]float64{{{77.59669303894043, 12.989504011681609},
-			{77.60699272155762, 12.983231353311314}, {77.60115623474121, 12.993183897537897},
-			{77.59669303894043, 12.989504011681609}}},
-			"geometry", []string{"linestring2", "multilinestring2"}},
+		{
+			[][][]float64{{
+				{77.59669303894043, 12.989504011681609},
+				{77.60699272155762, 12.983231353311314},
+				{77.60115623474121, 12.993183897537897},
+				{77.59669303894043, 12.989504011681609},
+			}},
+			"geometry",
+			[]string{"linestring2", "multilinestring2"},
+		},
 
 		// test intersecting query polygon for multilinestring2.
-		{[][][]float64{{{77.60124206542969, 12.987162237749484},
-			{77.60330200195312, 12.992849364713313}, {77.59514808654785, 12.989671280403403},
-			{77.60124206542969, 12.987162237749484}}},
-			"geometry", []string{"multilinestring2"}},
+		{
+			[][][]float64{{
+				{77.60124206542969, 12.987162237749484},
+				{77.60330200195312, 12.992849364713313},
+				{77.59514808654785, 12.989671280403403},
+				{77.60124206542969, 12.987162237749484},
+			}},
+			"geometry",
+			[]string{"multilinestring2"},
+		},
 
 		// test intersecting query polygon for multipoint1.
-		{[][][]float64{{{77.56648063659668, 12.956382587313202},
-			{77.56819725036621, 12.949523559614263}, {77.5718879699707, 12.958222782120954},
-			{77.56648063659668, 12.956382587313202}}},
-			"geometry", []string{"multipoint1"}},
+		{
+			[][][]float64{{
+				{77.56648063659668, 12.956382587313202},
+				{77.56819725036621, 12.949523559614263},
+				{77.5718879699707, 12.958222782120954},
+				{77.56648063659668, 12.956382587313202},
+			}},
+			"geometry",
+			[]string{"multipoint1"},
+		},
 
 		// test intersecting query polygon for envelope1.
-		{[][][]float64{{{36.19986534118652, 50.00034673534484},
+		{[][][]float64{{
+			{36.19986534118652, 50.00034673534484},
 			{36.19351387023926, 50.00464984215712},
 			{36.178321838378906, 49.991573824716205},
-			{36.19986534118652, 50.00034673534484}}}, "geometry", []string{"envelope1"}},
+			{36.19986534118652, 50.00034673534484},
+		}}, "geometry", []string{"envelope1"}},
 
 		// test intersecting query polygon for envelope1.
-		{[][][]float64{{{36.170082092285156, 49.99229116680205},
-			{36.14982604980469, 49.99002874388075}, {36.227073669433594, 49.98754547425633},
-			{36.170082092285156, 49.99229116680205}}}, "geometry", []string{"envelope1"}},
+		{[][][]float64{{
+			{36.170082092285156, 49.99229116680205},
+			{36.14982604980469, 49.99002874388075},
+			{36.227073669433594, 49.98754547425633},
+			{36.170082092285156, 49.99229116680205},
+		}}, "geometry", []string{"envelope1"}},
 	}
 	i := setupGeoJsonShapesIndexForPolygonQuery(t)
 	indexReader, err := i.Reader()
@@ -116,66 +160,126 @@ func TestGeoJsonPolygonContainsQuery(t *testing.T) {
 		field   string
 		want    []string
 	}{
-
 		// test containment query polygon for polygon1.
-		{[][][]float64{{{77.5843334197998, 12.952702156906767},
-			{77.58510589599608, 12.952702156906767}, {77.58510589599608, 12.953622269606669},
-			{77.5843334197998, 12.953622269606669}, {77.5843334197998, 12.952702156906767}}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][][]float64{{
+				{77.5843334197998, 12.952702156906767},
+				{77.58510589599608, 12.952702156906767},
+				{77.58510589599608, 12.953622269606669},
+				{77.5843334197998, 12.953622269606669},
+				{77.5843334197998, 12.952702156906767},
+			}},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test containment query polygon for circle1.
-		{[][][]float64{{{77.59025573730469, 12.953810474058429},
-			{77.59145736694336, 12.953810474058429}, {77.59145736694336, 12.954918786278716},
-			{77.59025573730469, 12.954918786278716}, {77.59025573730469, 12.953810474058429}}},
-			"geometry", []string{"circle1"}},
+		{
+			[][][]float64{{
+				{77.59025573730469, 12.953810474058429},
+				{77.59145736694336, 12.953810474058429},
+				{77.59145736694336, 12.954918786278716},
+				{77.59025573730469, 12.954918786278716},
+				{77.59025573730469, 12.953810474058429},
+			}},
+			"geometry",
+			[]string{"circle1"},
+		},
 
 		// test containment query polygon for polygon2, polygon3.
-		{[][][]float64{{{77.60235786437988, 12.956884459972992},
-			{77.60124206542969, 12.956800814599926}, {77.6008129119873, 12.955713422193524},
-			{77.60244369506836, 12.955211547173878}, {77.60313034057617, 12.955880713641998},
-			{77.60235786437988, 12.956884459972992}}},
-			"geometry", []string{"polygon2", "polygon3"}},
+		{
+			[][][]float64{{
+				{77.60235786437988, 12.956884459972992},
+				{77.60124206542969, 12.956800814599926},
+				{77.6008129119873, 12.955713422193524},
+				{77.60244369506836, 12.955211547173878},
+				{77.60313034057617, 12.955880713641998},
+				{77.60235786437988, 12.956884459972992},
+			}},
+			"geometry",
+			[]string{"polygon2", "polygon3"},
+		},
 
 		// test containment query polygon which resides within a hole in polygonWithHole1.
-		{[][][]float64{{{77.60012626647949, 12.97963495776207},
-			{77.5978946685791, 12.978213112610835}, {77.60089874267577, 12.977962197916442},
-			{77.60012626647949, 12.97963495776207}}},
-			"geometry", nil},
+		{
+			[][][]float64{{
+				{77.60012626647949, 12.97963495776207},
+				{77.5978946685791, 12.978213112610835},
+				{77.60089874267577, 12.977962197916442},
+				{77.60012626647949, 12.97963495776207},
+			}},
+			"geometry", nil,
+		},
 
 		// test containment query polygon which resides within polygonWithHole1.
-		{[][][]float64{{{77.59978294372559, 12.984067716910454},
-			{77.59780883789062, 12.982227713276774}, {77.60089874267577, 12.982227713276774},
-			{77.59978294372559, 12.984067716910454}}},
-			"geometry", []string{"polygonWithHole1"}},
+		{
+			[][][]float64{{
+				{77.59978294372559, 12.984067716910454},
+				{77.59780883789062, 12.982227713276774},
+				{77.60089874267577, 12.982227713276774},
+				{77.59978294372559, 12.984067716910454},
+			}},
+			"geometry",
+			[]string{"polygonWithHole1"},
+		},
 
 		// test with query polygon for polygon4 with a single vertex lying outside.
-		{[][][]float64{{{-121.48138761520384, 38.50964107572585},
-			{-121.48226737976073, 38.509238097766875}, {-121.48115158081055, 38.50781086602439},
-			{-121.48014307022095, 38.50806273250507}, {-121.48138761520384, 38.50964107572585}}},
-			"geometry", nil},
+		{
+			[][][]float64{{
+				{-121.48138761520384, 38.50964107572585},
+				{-121.48226737976073, 38.509238097766875},
+				{-121.48115158081055, 38.50781086602439},
+				{-121.48014307022095, 38.50806273250507},
+				{-121.48138761520384, 38.50964107572585},
+			}},
+			"geometry", nil,
+		},
 
 		// test with query polygon for polygon4.
-		{[][][]float64{{{-121.48381233215332, 38.507974579337045},
-			{-121.48361384868622, 38.507869634948676}, {-121.48361921310425, 38.50765135013098},
-			{-121.48343682289122, 38.50797038156446}, {-121.48381233215332, 38.507974579337045}}},
-			"geometry", []string{"polygon4"}},
+		{
+			[][][]float64{{
+				{-121.48381233215332, 38.507974579337045},
+				{-121.48361384868622, 38.507869634948676},
+				{-121.48361921310425, 38.50765135013098},
+				{-121.48343682289122, 38.50797038156446},
+				{-121.48381233215332, 38.507974579337045},
+			}},
+			"geometry",
+			[]string{"polygon4"},
+		},
 
 		// test with query polygon for multipolygon1.
-		{[][][]float64{{{-121.47578716278075, 38.51617236229197},
-			{-121.47578716278075, 38.51566868518406}, {-121.47546529769896, 38.516105205547866},
-			{-121.47578716278075, 38.51617236229197}}}, "geometry", []string{"multipolygon1"}},
+		{[][][]float64{{
+			{-121.47578716278075, 38.51617236229197},
+			{-121.47578716278075, 38.51566868518406},
+			{-121.47546529769896, 38.516105205547866},
+			{-121.47578716278075, 38.51617236229197},
+		}}, "geometry", []string{"multipolygon1"}},
 
 		// test with query polygon for envelope1.
-		{[][][]float64{{{36.197547912597656, 49.99642946989866},
-			{36.18939399719238, 49.988649165474}, {36.20201110839844, 49.98853879749191},
-			{36.1970329284668, 49.980150089789376}, {36.205787658691406,
-				49.9885939815146}, {36.197547912597656, 49.99642946989866}}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][][]float64{{
+				{36.197547912597656, 49.99642946989866},
+				{36.18939399719238, 49.988649165474},
+				{36.20201110839844, 49.98853879749191},
+				{36.1970329284668, 49.980150089789376},
+				{
+					36.205787658691406,
+					49.9885939815146,
+				},
+				{36.197547912597656, 49.99642946989866},
+			}},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test with query polygon for no hits. (envelope1 has one vertex outside the polygon)
-		{[][][]float64{{{36.19832038879394, 49.99626394461266},
-			{36.19016647338867, 49.98439981533724}, {36.20698928833008, 49.98158510403259},
-			{36.19832038879394, 49.99626394461266}}}, "geometry", nil},
+		{[][][]float64{{
+			{36.19832038879394, 49.99626394461266},
+			{36.19016647338867, 49.98439981533724},
+			{36.20698928833008, 49.98158510403259},
+			{36.19832038879394, 49.99626394461266},
+		}}, "geometry", nil},
 	}
 	i := setupGeoJsonShapesIndexForPolygonQuery(t)
 	indexReader, err := i.Reader()
@@ -208,66 +312,125 @@ func TestGeoJsonPolygonWithInQuery(t *testing.T) {
 		field   string
 		want    []string
 	}{
-
 		// test with query polygon for polygon1.
-		{[][][]float64{{{77.58407592773438, 12.956382587313202},
-			{77.57746696472168, 12.943249893344905}, {77.5920581817627, 12.944086391304364},
-			{77.59454727172852, 12.95353862313803}, {77.58407592773438, 12.956382587313202}}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][][]float64{{
+				{77.58407592773438, 12.956382587313202},
+				{77.57746696472168, 12.943249893344905},
+				{77.5920581817627, 12.944086391304364},
+				{77.59454727172852, 12.95353862313803},
+				{77.58407592773438, 12.956382587313202},
+			}},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test with query polygon for circle1 and polygon3.
-		{[][][]float64{{{77.59248733520508, 12.967841760870071},
-			{77.58261680603027, 12.968594534825176}, {77.57789611816406, 12.957302686416881},
-			{77.58896827697754, 12.945341132980488}, {77.60450363159178, 12.947599652080394},
-			{77.60673522949219, 12.96483064227584}, {77.59248733520508, 12.967841760870071}}},
-			"geometry", []string{"polygon3", "circle1"}},
+		{
+			[][][]float64{{
+				{77.59248733520508, 12.967841760870071},
+				{77.58261680603027, 12.968594534825176},
+				{77.57789611816406, 12.957302686416881},
+				{77.58896827697754, 12.945341132980488},
+				{77.60450363159178, 12.947599652080394},
+				{77.60673522949219, 12.96483064227584},
+				{77.59248733520508, 12.967841760870071},
+			}},
+			"geometry",
+			[]string{"polygon3", "circle1"},
+		},
 
 		// test with query polygon for linestring2, multilinestring2.
-		{[][][]float64{{{77.59909629821777, 12.998118204343788},
-			{77.58931159973145, 12.978882217224443}, {77.61128425598145, 12.983565899088745},
-			{77.59909629821777, 12.998118204343788}}}, "geometry",
-			[]string{"linestring2", "multilinestring2"}},
+		{
+			[][][]float64{{
+				{77.59909629821777, 12.998118204343788},
+				{77.58931159973145, 12.978882217224443},
+				{77.61128425598145, 12.983565899088745},
+				{77.59909629821777, 12.998118204343788},
+			}},
+			"geometry",
+			[]string{"linestring2", "multilinestring2"},
+		},
 
 		// test with query polygon for multipoint1.
-		{[][][]float64{{{77.55703926086426, 12.964245142762644},
-			{77.5631332397461, 12.944253690559432}, {77.57429122924805, 12.957720912158363},
-			{77.55703926086426, 12.964245142762644}}}, "geometry", []string{"multipoint1"}},
+		{[][][]float64{{
+			{77.55703926086426, 12.964245142762644},
+			{77.5631332397461, 12.944253690559432},
+			{77.57429122924805, 12.957720912158363},
+			{77.55703926086426, 12.964245142762644},
+		}}, "geometry", []string{"multipoint1"}},
 
 		// test with query polygon with no results.
 		// (polygon4 has one vertex lying outside the query polygon).
-		{[][][]float64{{{-121.48812532424927, 38.51058134885975},
-			{-121.48258924484252, 38.500153704565065}, {-121.47492885589598, 38.50799556819636},
-			{-121.48630142211913, 38.51147123890908}, {-121.48812532424927, 38.51058134885975}}},
-			"geometry", nil},
+		{
+			[][][]float64{{
+				{-121.48812532424927, 38.51058134885975},
+				{-121.48258924484252, 38.500153704565065},
+				{-121.47492885589598, 38.50799556819636},
+				{-121.48630142211913, 38.51147123890908},
+				{-121.48812532424927, 38.51058134885975},
+			}},
+			"geometry", nil,
+		},
 
 		// test with query polygon for polygon4.
-		{[][][]float64{{{-121.48366212844849, 38.510161585585045},
-			{-121.48533582687377, 38.50841534409804}, {-121.48376941680908, 38.507777283760426},
-			{-121.48370504379272, 38.50250467407243}, {-121.48010015487672, 38.50253825879518},
-			{-121.48018598556519, 38.504502937819765}, {-121.47756814956665, 38.50755899866278},
-			{-121.48113012313843, 38.50866720846446}, {-121.48115158081055, 38.51017837616302},
-			{-121.48366212844849, 38.510161585585045}}}, "geometry", []string{"polygon4"}},
+		{[][][]float64{{
+			{-121.48366212844849, 38.510161585585045},
+			{-121.48533582687377, 38.50841534409804},
+			{-121.48376941680908, 38.507777283760426},
+			{-121.48370504379272, 38.50250467407243},
+			{-121.48010015487672, 38.50253825879518},
+			{-121.48018598556519, 38.504502937819765},
+			{-121.47756814956665, 38.50755899866278},
+			{-121.48113012313843, 38.50866720846446},
+			{-121.48115158081055, 38.51017837616302},
+			{-121.48366212844849, 38.510161585585045},
+		}}, "geometry", []string{"polygon4"}},
 
 		// test with query polygon for envelope1.
-		{[][][]float64{{{36.20587348937988, 50.00470500769241},
-			{36.17969512939453, 49.993946530777606}, {36.19368553161621, 49.971870325635074},
-			{36.21119499206543, 49.983075265826656}, {36.20587348937988, 50.00470500769241}}},
-			"geometry", []string{"envelope1"}},
+		{
+			[][][]float64{{
+				{36.20587348937988, 50.00470500769241},
+				{36.17969512939453, 49.993946530777606},
+				{36.19368553161621, 49.971870325635074},
+				{36.21119499206543, 49.983075265826656},
+				{36.20587348937988, 50.00470500769241},
+			}},
+			"geometry",
+			[]string{"envelope1"},
+		},
 
 		// test with query polygon for linestring2 which lies outside except the endpoints.
-		{[][][]float64{{{8.515305519104004, 47.392597129887},
-			{8.514232635498047, 47.38896544894171}, {8.507537841796875, 47.38815191810328},
-			{8.514318466186523, 47.38725120859953}, {8.516035079956053, 47.383357642070706},
-			{8.516979217529295, 47.38733837470806}, {8.522472381591797, 47.38794853343167},
-			{8.516507148742676, 47.388994503382285}, {8.515305519104004, 47.392597129887}}},
-			"geometry", nil},
+		{
+			[][][]float64{{
+				{8.515305519104004, 47.392597129887},
+				{8.514232635498047, 47.38896544894171},
+				{8.507537841796875, 47.38815191810328},
+				{8.514318466186523, 47.38725120859953},
+				{8.516035079956053, 47.383357642070706},
+				{8.516979217529295, 47.38733837470806},
+				{8.522472381591797, 47.38794853343167},
+				{8.516507148742676, 47.388994503382285},
+				{8.515305519104004, 47.392597129887},
+			}},
+			"geometry", nil,
+		},
 
 		// test with query polygon for all the shapes.
-		{[][][]float64{{{-135.0, -38.0},
-			{149.0, -38.0}, {149.0, 77.0}, {-135.0, 77.0}}},
-			"geometry", []string{"polygon1", "polygon2", "polygon3", "envelope1", "circle1", "linestring1",
+		{
+			[][][]float64{{
+				{-135.0, -38.0},
+				{149.0, -38.0},
+				{149.0, 77.0},
+				{-135.0, 77.0},
+			}},
+			"geometry",
+			[]string{
+				"polygon1", "polygon2", "polygon3", "envelope1", "circle1", "linestring1",
 				"linestring2", "linestring3", "multilinestring1", "multilinestring2", "multipoint1",
-				"polygonWithHole1", "polygon4", "multipolygon1"}},
+				"polygonWithHole1", "polygon4", "multipolygon1",
+			},
+		},
 	}
 
 	i := setupGeoJsonShapesIndexForPolygonQuery(t)
@@ -296,11 +459,12 @@ func TestGeoJsonPolygonWithInQuery(t *testing.T) {
 }
 
 func runGeoShapePolygonQueryWithRelation(relation string, i index.IndexReader,
-	points [][][]float64, field string) ([]string, error) {
+	points [][][]float64, field string,
+) ([]string, error) {
 	var rv []string
 	s := geo.NewGeoJsonPolygon(points)
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation, field, 1.0, search.SearcherOptions{})
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation, field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
 	}
@@ -336,16 +500,26 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{77.5853419303894, 12.953977766785052},
-		{77.58405447006226, 12.95393594361393}, {77.5819730758667, 12.9495026476557},
-		{77.58068561553955, 12.94883346405509}, {77.58019208908081, 12.948331575175299},
-		{77.57991313934326, 12.943814529775414}, {77.58497714996338, 12.94394000436408},
-		{77.58517026901245, 12.9446301134728}, {77.58572816848755, 12.945508431393435},
-		{77.58785247802734, 12.946365833997325}, {77.58967638015747, 12.946428570657417},
-		{77.59070634841918, 12.947474179333993}, {77.59317398071289, 12.948875288082773},
-		{77.59167194366454, 12.949962710338657}, {77.59077072143555, 12.950276388953625},
-		{77.59098529815674, 12.951196510612728}, {77.58729457855225, 12.952472128200755},
-		{77.5853419303894, 12.953977766785052}}}}
+	polygon1 := [][][][]float64{{{
+		{77.5853419303894, 12.953977766785052},
+		{77.58405447006226, 12.95393594361393},
+		{77.5819730758667, 12.9495026476557},
+		{77.58068561553955, 12.94883346405509},
+		{77.58019208908081, 12.948331575175299},
+		{77.57991313934326, 12.943814529775414},
+		{77.58497714996338, 12.94394000436408},
+		{77.58517026901245, 12.9446301134728},
+		{77.58572816848755, 12.945508431393435},
+		{77.58785247802734, 12.946365833997325},
+		{77.58967638015747, 12.946428570657417},
+		{77.59070634841918, 12.947474179333993},
+		{77.59317398071289, 12.948875288082773},
+		{77.59167194366454, 12.949962710338657},
+		{77.59077072143555, 12.950276388953625},
+		{77.59098529815674, 12.951196510612728},
+		{77.58729457855225, 12.952472128200755},
+		{77.5853419303894, 12.953977766785052},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -354,11 +528,16 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon2 := [][][][]float64{{{{77.59527683258057, 12.951112863329588},
-		{77.59420394897461, 12.947976069940545}, {77.59579181671143, 12.946010325958518},
-		{77.60347366333008, 12.950401860289055}, {77.60673522949219, 12.95600618215462},
-		{77.60107040405273, 12.96345053407734}, {77.5984525680542, 12.961861309096507},
-		{77.59527683258057, 12.951112863329588}}}}
+	polygon2 := [][][][]float64{{{
+		{77.59527683258057, 12.951112863329588},
+		{77.59420394897461, 12.947976069940545},
+		{77.59579181671143, 12.946010325958518},
+		{77.60347366333008, 12.950401860289055},
+		{77.60673522949219, 12.95600618215462},
+		{77.60107040405273, 12.96345053407734},
+		{77.5984525680542, 12.961861309096507},
+		{77.59527683258057, 12.951112863329588},
+	}}}
 	doc = document.NewDocument("polygon2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon2, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -367,9 +546,13 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon3 := [][][][]float64{{{{77.59974002838135, 12.953789562459688},
-		{77.60347366333008, 12.953789562459688}, {77.60347366333008, 12.957720912158363},
-		{77.59974002838135, 12.957720912158363}, {77.59974002838135, 12.953789562459688}}}}
+	polygon3 := [][][][]float64{{{
+		{77.59974002838135, 12.953789562459688},
+		{77.60347366333008, 12.953789562459688},
+		{77.60347366333008, 12.957720912158363},
+		{77.59974002838135, 12.957720912158363},
+		{77.59974002838135, 12.953789562459688},
+	}}}
 	doc = document.NewDocument("polygon3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon3, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -392,8 +575,10 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 	}*/
 
 	// not working envelope
-	envelope1 := [][][][]float64{{{{36.18896484375, 49.9799293145682},
-		{36.20613098144531, 49.99714673955337}}}}
+	envelope1 := [][][][]float64{{{
+		{36.18896484375, 49.9799293145682},
+		{36.20613098144531, 49.99714673955337},
+	}}}
 	doc = document.NewDocument("envelope1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		envelope1, "envelope", document.DefaultGeoShapeIndexingOptions))
@@ -411,8 +596,10 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring := [][][][]float64{{{{77.5841188430786, 12.957093573282744},
-		{77.57776737213135, 12.952074805390097}}}}
+	linestring := [][][][]float64{{{
+		{77.5841188430786, 12.957093573282744},
+		{77.57776737213135, 12.952074805390097},
+	}}}
 	doc = document.NewDocument("linestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -421,8 +608,10 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring1 := [][][][]float64{{{{77.60188579559325, 12.982604078764705},
-		{77.60557651519775, 12.987329508048184}}}}
+	linestring1 := [][][][]float64{{{
+		{77.60188579559325, 12.982604078764705},
+		{77.60557651519775, 12.987329508048184},
+	}}}
 	doc = document.NewDocument("linestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring1, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -431,8 +620,10 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	linestring3 := [][][][]float64{{{{8.51539134979248, 47.390592472948434},
-		{8.520884513854979, 47.388006643417924}}}}
+	linestring3 := [][][][]float64{{{
+		{8.51539134979248, 47.390592472948434},
+		{8.520884513854979, 47.388006643417924},
+	}}}
 	doc = document.NewDocument("linestring3")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		linestring3, "linestring", document.DefaultGeoShapeIndexingOptions))
@@ -441,10 +632,14 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring := [][][][]float64{{{{77.57227420806883, 12.948687079902895},
-		{77.57600784301758, 12.954165970968194}},
+	multilinestring := [][][][]float64{{
+		{
+			{77.57227420806883, 12.948687079902895},
+			{77.57600784301758, 12.954165970968194},
+		},
 		{{77.5779390335083, 12.94471376293191}, {77.57218837738037, 12.948268838994263}},
-		{{77.57781028747559, 12.951740217268595}, {77.5779390335083, 12.945006535817749}}}}
+		{{77.57781028747559, 12.951740217268595}, {77.5779390335083, 12.945006535817749}},
+	}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -453,10 +648,14 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring1 := [][][][]float64{{{{77.6015853881836, 12.990089451715061},
-		{77.60476112365723, 12.987747683302153}},
+	multilinestring1 := [][][][]float64{{
+		{
+			{77.6015853881836, 12.990089451715061},
+			{77.60476112365723, 12.987747683302153},
+		},
 		{{77.59875297546387, 12.988751301039581}, {77.59446144104004, 12.98197680263484}},
-		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}}}}
+		{{77.60188579559325, 12.982604078764705}, {77.60557651519775, 12.987329508048184}},
+	}}
 	doc = document.NewDocument("multilinestring2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring1, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -465,9 +664,11 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{77.56618022918701, 12.958180959662695},
+	multipoint1 := [][][][]float64{{{
+		{77.56618022918701, 12.958180959662695},
 		{77.56407737731932, 12.951614746607163},
-		{77.56922721862793, 12.956173473406446}}}}
+		{77.56922721862793, 12.956173473406446},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipoint1, "multipoint", document.DefaultGeoShapeIndexingOptions))
@@ -477,12 +678,22 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 	}
 
 	polygonWithHole1 := [][][][]float64{{
-		{{77.59991168975829, 12.972232910164502}, {77.6039457321167, 12.97582941279006},
-			{77.60424613952637, 12.98168407323241}, {77.59974002838135, 12.985489528568463},
-			{77.59321689605713, 12.979300406693417}, {77.59991168975829, 12.972232910164502}},
-		{{77.59682178497314, 12.975787593290978}, {77.60295867919922, 12.975787593290978},
-			{77.60295867919922, 12.98143316204164}, {77.59682178497314, 12.98143316204164},
-			{77.59682178497314, 12.975787593290978}}}}
+		{
+			{77.59991168975829, 12.972232910164502},
+			{77.6039457321167, 12.97582941279006},
+			{77.60424613952637, 12.98168407323241},
+			{77.59974002838135, 12.985489528568463},
+			{77.59321689605713, 12.979300406693417},
+			{77.59991168975829, 12.972232910164502},
+		},
+		{
+			{77.59682178497314, 12.975787593290978},
+			{77.60295867919922, 12.975787593290978},
+			{77.60295867919922, 12.98143316204164},
+			{77.59682178497314, 12.98143316204164},
+			{77.59682178497314, 12.975787593290978},
+		},
+	}}
 
 	doc = document.NewDocument("polygonWithHole1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
@@ -492,12 +703,18 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon4 := [][][][]float64{{{{-121.48125886917113, 38.51009442323401},
-		{-121.48361921310425, 38.51012800441735}, {-121.48497104644774, 38.50858325377352},
-		{-121.48366212844849, 38.507861239391026}, {-121.48353338241577, 38.50277335141579},
-		{-121.4803147315979, 38.50267259752949}, {-121.48033618927, 38.5046204810195},
-		{-121.47771835327147, 38.50754220747402}, {-121.48123741149902, 38.508616835661655},
-		{-121.48125886917113, 38.51009442323401}}}}
+	polygon4 := [][][][]float64{{{
+		{-121.48125886917113, 38.51009442323401},
+		{-121.48361921310425, 38.51012800441735},
+		{-121.48497104644774, 38.50858325377352},
+		{-121.48366212844849, 38.507861239391026},
+		{-121.48353338241577, 38.50277335141579},
+		{-121.4803147315979, 38.50267259752949},
+		{-121.48033618927, 38.5046204810195},
+		{-121.47771835327147, 38.50754220747402},
+		{-121.48123741149902, 38.508616835661655},
+		{-121.48125886917113, 38.51009442323401},
+	}}}
 
 	doc = document.NewDocument("polygon4")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
@@ -507,12 +724,22 @@ func setupGeoJsonShapesIndexForPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipolygon1 := [][][][]float64{{{{-121.49104356765746, 38.52149433504263},
-		{-121.47857666015625, 38.51592052417851}, {-121.47688150405884, 38.515970891871696},
-		{-121.4770746231079, 38.51714612804143}, {-121.49033546447754, 38.52221621271097},
-		{-121.49104356765746, 38.52149433504263}}},
-		{{{-121.47647380828859, 38.51714612804143}, {-121.47658109664916, 38.51477884701455},
-			{-121.4741563796997, 38.5159876810949}, {-121.47647380828859, 38.51714612804143}}}}
+	multipolygon1 := [][][][]float64{
+		{{
+			{-121.49104356765746, 38.52149433504263},
+			{-121.47857666015625, 38.51592052417851},
+			{-121.47688150405884, 38.515970891871696},
+			{-121.4770746231079, 38.51714612804143},
+			{-121.49033546447754, 38.52221621271097},
+			{-121.49104356765746, 38.52149433504263},
+		}},
+		{{
+			{-121.47647380828859, 38.51714612804143},
+			{-121.47658109664916, 38.51477884701455},
+			{-121.4741563796997, 38.5159876810949},
+			{-121.47647380828859, 38.51714612804143},
+		}},
+	}
 
 	doc = document.NewDocument("multipolygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
@@ -533,48 +760,108 @@ func TestGeoJsonMultiPolygonWithInQuery(t *testing.T) {
 	}{
 		// test within multipolygon query for multipolygon1.
 		// (where each query polygon contains each of the indexed polygons)
-		{[][][][]float64{{
-			{{-121.49458408355713, 38.53270780324851}, {-121.48823261260985, 38.52533866992879},
-				{-121.48048639297485, 38.53253994984147}, {-121.49458408355713, 38.53270780324851}}},
-			{{{-121.48700952529907, 38.53306029412857}, {-121.48160219192505, 38.53306029412857},
-				{-121.48160219192505, 38.53829709805414}, {-121.48700952529907, 38.53829709805414},
-				{-121.48700952529907, 38.53306029412857}}},
-			{{{-121.47344827651976, 38.54475865436684}, {-121.46396398544312, 38.54475865436684},
-				{-121.46396398544312, 38.55366961462033},
-				{-121.47344827651976, 38.55366961462033}, {-121.47344827651976, 38.54475865436684}}}},
-			"geometry", []string{"multipolygon1"}},
+		{
+			[][][][]float64{
+				{
+					{
+						{-121.49458408355713, 38.53270780324851},
+						{-121.48823261260985, 38.52533866992879},
+						{-121.48048639297485, 38.53253994984147},
+						{-121.49458408355713, 38.53270780324851},
+					},
+				},
+				{{
+					{-121.48700952529907, 38.53306029412857},
+					{-121.48160219192505, 38.53306029412857},
+					{-121.48160219192505, 38.53829709805414},
+					{-121.48700952529907, 38.53829709805414},
+					{-121.48700952529907, 38.53306029412857},
+				}},
+				{{
+					{-121.47344827651976, 38.54475865436684},
+					{-121.46396398544312, 38.54475865436684},
+					{-121.46396398544312, 38.55366961462033},
+					{-121.47344827651976, 38.55366961462033},
+					{-121.47344827651976, 38.54475865436684},
+				}},
+			},
+			"geometry",
+			[]string{"multipolygon1"},
+		},
 
 		// test within multipolygon query. (only partial containment of the three
 		// indexed polygons by the two query polygons)
-		{[][][][]float64{{
-			{{-121.49458408355713, 38.53270780324851}, {-121.48823261260985, 38.52533866992879},
-				{-121.48048639297485, 38.53253994984147}, {-121.49458408355713, 38.53270780324851}}},
-			{{{-121.48700952529907, 38.53306029412857}, {-121.48160219192505, 38.53306029412857},
-				{-121.48160219192505, 38.53829709805414}, {-121.48700952529907, 38.53829709805414},
-				{-121.48700952529907, 38.53306029412857}}},
-			{{{-121.4734697341919, 38.544825784372485}, {-121.4644145965576, 38.544825784372485},
-				{-121.4644145965576, 38.5537199558913}, {-121.4734697341919, 38.5537199558913},
-				{-121.4734697341919, 38.544825784372485}}}},
-			"geometry", nil},
+		{
+			[][][][]float64{
+				{
+					{
+						{-121.49458408355713, 38.53270780324851},
+						{-121.48823261260985, 38.52533866992879},
+						{-121.48048639297485, 38.53253994984147},
+						{-121.49458408355713, 38.53270780324851},
+					},
+				},
+				{{
+					{-121.48700952529907, 38.53306029412857},
+					{-121.48160219192505, 38.53306029412857},
+					{-121.48160219192505, 38.53829709805414},
+					{-121.48700952529907, 38.53829709805414},
+					{-121.48700952529907, 38.53306029412857},
+				}},
+				{{
+					{-121.4734697341919, 38.544825784372485},
+					{-121.4644145965576, 38.544825784372485},
+					{-121.4644145965576, 38.5537199558913},
+					{-121.4734697341919, 38.5537199558913},
+					{-121.4734697341919, 38.544825784372485},
+				}},
+			},
+			"geometry", nil,
+		},
 
 		// test within multipolygon query for multilinestring1.
-		{[][][][]float64{{{{-121.49876832962036, 38.551739839324334},
-			{-121.49814605712889, 38.54553064564853}, {-121.49158000946044, 38.54908841140355},
-			{-121.49876832962036, 38.551739839324334}}},
-			{{{-121.49258852005006, 38.54294612052762}, {-121.49117231369017, 38.54294612052762},
-				{-121.49117231369017, 38.54526212788182}, {-121.49258852005006, 38.54526212788182},
-				{-121.49258852005006, 38.54294612052762}},
-			}}, "geometry", []string{"multilinestring1"}},
+		{[][][][]float64{
+			{{
+				{-121.49876832962036, 38.551739839324334},
+				{-121.49814605712889, 38.54553064564853},
+				{-121.49158000946044, 38.54908841140355},
+				{-121.49876832962036, 38.551739839324334},
+			}},
+			{
+				{
+					{-121.49258852005006, 38.54294612052762},
+					{-121.49117231369017, 38.54294612052762},
+					{-121.49117231369017, 38.54526212788182},
+					{-121.49258852005006, 38.54526212788182},
+					{-121.49258852005006, 38.54294612052762},
+				},
+			},
+		}, "geometry", []string{"multilinestring1"}},
 
 		// test within multipolygon query for multipoint1.
-		{[][][][]float64{{{{-121.50286674499512, 38.564810956372185},
-			{-121.49694442749023, 38.56226068115802}, {-121.48406982421875, 38.5675624676039},
-			{-121.4875030517578, 38.57514535565976}, {-121.50286674499512, 38.564810956372185}}},
-			{{{-121.48685932159422, 38.565163289911425}, {-121.48623704910278, 38.56283114531348},
-				{-121.48357629776001, 38.565129734410704}, {-121.48685932159422, 38.565163289911425}}},
-			{{{-121.49430513381958, 38.56195866888961}, {-121.4899492263794, 38.5584518779682},
-				{-121.48842573165892, 38.56194189039304}, {-121.49430513381958, 38.56195866888961}},
-			}}, "geometry", []string{"multipoint1"}},
+		{[][][][]float64{
+			{{
+				{-121.50286674499512, 38.564810956372185},
+				{-121.49694442749023, 38.56226068115802},
+				{-121.48406982421875, 38.5675624676039},
+				{-121.4875030517578, 38.57514535565976},
+				{-121.50286674499512, 38.564810956372185},
+			}},
+			{{
+				{-121.48685932159422, 38.565163289911425},
+				{-121.48623704910278, 38.56283114531348},
+				{-121.48357629776001, 38.565129734410704},
+				{-121.48685932159422, 38.565163289911425},
+			}},
+			{
+				{
+					{-121.49430513381958, 38.56195866888961},
+					{-121.4899492263794, 38.5584518779682},
+					{-121.48842573165892, 38.56194189039304},
+					{-121.49430513381958, 38.56195866888961},
+				},
+			},
+		}, "geometry", []string{"multipoint1"}},
 	}
 	i := setupGeoJsonShapesIndexForMultiPolygonQuery(t)
 	indexReader, err := i.Reader()
@@ -603,11 +890,12 @@ func TestGeoJsonMultiPolygonWithInQuery(t *testing.T) {
 
 func runGeoShapeMultiPolygonQueryWithRelation(relation string,
 	i index.IndexReader,
-	points [][][][]float64, field string) ([]string, error) {
+	points [][][][]float64, field string,
+) ([]string, error) {
 	var rv []string
 	s := geo.NewGeoJsonMultiPolygon(points)
 
-	gbs, err := NewGeoShapeSearcher(nil, i, s, relation,
+	gbs, err := NewGeoShapeSearcher(context.TODO(), i, s, relation,
 		field, 1.0, search.SearcherOptions{})
 	if err != nil {
 		return nil, err
@@ -644,15 +932,28 @@ func setupGeoJsonShapesIndexForMultiPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipolygon1 := [][][][]float64{{{{-121.49140834808348, 38.5320028163074},
-		{-121.49112939834593, 38.52916601331889}, {-121.48889780044556, 38.52913244101627},
-		{-121.4887261390686, 38.527655244193205}, {-121.48559331893921, 38.52794061412457},
-		{-121.48638725280762, 38.53213710006686}, {-121.49140834808348, 38.5320028163074}}}, // polygon1
-		{{{-121.48677349090575, 38.533194575914315}, {-121.48179531097412, 38.533194575914315},
-			{-121.48179531097412, 38.53814604174215}, {-121.48677349090575, 38.53814604174215},
-			{-121.48677349090575, 38.533194575914315}}}, // polygon2
-		{{{-121.47334098815918, 38.553485029658475}, {-121.47329807281494, 38.54485934935182},
-			{-121.46415710449219, 38.54526212788182}, {-121.47334098815918, 38.553485029658475}}}}
+	multipolygon1 := [][][][]float64{{{
+		{-121.49140834808348, 38.5320028163074},
+		{-121.49112939834593, 38.52916601331889},
+		{-121.48889780044556, 38.52913244101627},
+		{-121.4887261390686, 38.527655244193205},
+		{-121.48559331893921, 38.52794061412457},
+		{-121.48638725280762, 38.53213710006686},
+		{-121.49140834808348, 38.5320028163074},
+	}}, // polygon1
+		{{
+			{-121.48677349090575, 38.533194575914315},
+			{-121.48179531097412, 38.533194575914315},
+			{-121.48179531097412, 38.53814604174215},
+			{-121.48677349090575, 38.53814604174215},
+			{-121.48677349090575, 38.533194575914315},
+		}}, // polygon2
+		{{
+			{-121.47334098815918, 38.553485029658475},
+			{-121.47329807281494, 38.54485934935182},
+			{-121.46415710449219, 38.54526212788182},
+			{-121.47334098815918, 38.553485029658475},
+		}}}
 	doc := document.NewDocument("multipolygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipolygon1, "multipolygon", document.DefaultGeoShapeIndexingOptions))
@@ -661,10 +962,14 @@ func setupGeoJsonShapesIndexForMultiPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multilinestring1 := [][][][]float64{{{{-121.4983820915222, 38.55081688500274},
-		{-121.49649381637572, 38.550447699956685}},
+	multilinestring1 := [][][][]float64{{
+		{
+			{-121.4983820915222, 38.55081688500274},
+			{-121.49649381637572, 38.550447699956685},
+		},
 		{{-121.49655818939209, 38.548635309508775}, {-121.49370431900023, 38.54811507788636}},
-		{{-121.49134397506714, 38.54490969679143}, {-121.4919662475586, 38.54304681805045}}}}
+		{{-121.49134397506714, 38.54490969679143}, {-121.4919662475586, 38.54304681805045}},
+	}}
 	doc = document.NewDocument("multilinestring1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multilinestring1, "multilinestring", document.DefaultGeoShapeIndexingOptions))
@@ -673,10 +978,14 @@ func setupGeoJsonShapesIndexForMultiPolygonQuery(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	multipoint1 := [][][][]float64{{{{-121.48960590362547, 38.56066671319285},
-		{-121.4933180809021, 38.56157276247755}, {-121.4973521232605, 38.56318348855919},
-		{-121.48582935333252, 38.56736114108619}, {-121.50104284286498, 38.56449217691959},
-		{-121.4881682395935, 38.57158887950165}}}}
+	multipoint1 := [][][][]float64{{{
+		{-121.48960590362547, 38.56066671319285},
+		{-121.4933180809021, 38.56157276247755},
+		{-121.4973521232605, 38.56318348855919},
+		{-121.48582935333252, 38.56736114108619},
+		{-121.50104284286498, 38.56449217691959},
+		{-121.4881682395935, 38.57158887950165},
+	}}}
 	doc = document.NewDocument("multipoint1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		multipoint1, "multipoint", document.DefaultGeoShapeIndexingOptions))
@@ -705,9 +1014,12 @@ func setupGeoJsonPolygonS2LoopPortingIssue(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{-135.0, -38.0},
-		{149.0, -38.0}, {149.0, 77.0},
-		{-135.0, 77.0}}}}
+	polygon1 := [][][][]float64{{{
+		{-135.0, -38.0},
+		{149.0, -38.0},
+		{149.0, 77.0},
+		{-135.0, 77.0},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -724,18 +1036,29 @@ func TestGeoJsonPolygonContainsQueryS2LoopPortingIssue(t *testing.T) {
 		field   string
 		want    []string
 	}{
-
 		// test containment query polygon for polygon1.
-		{[][][]float64{{{13.007812500000002, 37.99616267972809},
-			{13.559375000000002, 37.99616267972809}, {13.559375000000002, 38.472819658516866},
-			{13.007812500000002, 38.472819658516866}}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][][]float64{{
+				{13.007812500000002, 37.99616267972809},
+				{13.559375000000002, 37.99616267972809},
+				{13.559375000000002, 38.472819658516866},
+				{13.007812500000002, 38.472819658516866},
+			}},
+			"geometry",
+			[]string{"polygon1"},
+		},
 
 		// test containment query polygon for polygon1.
-		{[][][]float64{{{13.007812500000002, 37.99616267972809},
-			{13.359375000000002, 37.99616267972809}, {13.359375000000002, 38.272819658516866},
-			{13.007812500000002, 38.272819658516866}}},
-			"geometry", []string{"polygon1"}},
+		{
+			[][][]float64{{
+				{13.007812500000002, 37.99616267972809},
+				{13.359375000000002, 37.99616267972809},
+				{13.359375000000002, 38.272819658516866},
+				{13.007812500000002, 38.272819658516866},
+			}},
+			"geometry",
+			[]string{"polygon1"},
+		},
 	}
 	i := setupGeoJsonPolygonS2LoopPortingIssue(t)
 	indexReader, err := i.Reader()
@@ -768,30 +1091,53 @@ func TestGeoJsonPolygonIntersectsQuery1(t *testing.T) {
 		field   string
 		want    []string
 	}{
-
 		// test non-intersecting query polygon.
-		{[][][]float64{{{97.745361328125,
-			68.21644657802169},
-			{97.701416015625,
-				67.97051353559428}, {97.80029296875,
-				67.97875365614591},
-			{97.745361328125,
-				68.21644657802169}}}, "geometry", nil},
+		{[][][]float64{{
+			{
+				97.745361328125,
+				68.21644657802169,
+			},
+			{
+				97.701416015625,
+				67.97051353559428,
+			},
+			{
+				97.80029296875,
+				67.97875365614591,
+			},
+			{
+				97.745361328125,
+				68.21644657802169,
+			},
+		}}, "geometry", nil},
 
 		// test intersecting query polygon.
-		{[][][]float64{{{77.59214401245117,
-			12.966043458314124},
-			{77.58853912353516,
-				12.95232574618635}, {77.60943889617919,
-				12.956466232826733},
-			{77.59214401245117,
-				12.966043458314124}}}, "geometry", nil},
+		{[][][]float64{{
+			{
+				77.59214401245117,
+				12.966043458314124,
+			},
+			{
+				77.58853912353516,
+				12.95232574618635,
+			},
+			{
+				77.60943889617919,
+				12.956466232826733,
+			},
+			{
+				77.59214401245117,
+				12.966043458314124,
+			},
+		}}, "geometry", nil},
 
 		// test intersecting query polygon for polygon1.
-		{[][][]float64{{{97.0806884765625, 61.61423180712503},
+		{[][][]float64{{
+			{97.0806884765625, 61.61423180712503},
 			{96.7510986328125, 61.54625879879804},
 			{97.305908203125, 61.367777577924},
-			{97.0806884765625, 61.61423180712503}}}, "geometry", []string{"polygon1"}},
+			{97.0806884765625, 61.61423180712503},
+		}}, "geometry", []string{"polygon1"}},
 	}
 	i := setupGeoJsonShapesIndexForPolygonQuery1(t)
 	indexReader, err := i.Reader()
@@ -835,10 +1181,12 @@ func setupGeoJsonShapesIndexForPolygonQuery1(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon1 := [][][][]float64{{{{96.69202458735312, 61.59480859768306},
+	polygon1 := [][][][]float64{{{
+		{96.69202458735312, 61.59480859768306},
 		{96.79202458735311, 61.39480859768306},
 		{96.79202458735311, 61.59480859768306},
-		{96.69202458735312, 61.59480859768306}}}}
+		{96.69202458735312, 61.59480859768306},
+	}}}
 	doc := document.NewDocument("polygon1")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon1, "polygon", document.DefaultGeoShapeIndexingOptions))
@@ -847,10 +1195,12 @@ func setupGeoJsonShapesIndexForPolygonQuery1(t *testing.T) index.Index {
 		t.Fatal(err)
 	}
 
-	polygon2 := [][][][]float64{{{{91.35604953911839, 65.11164029408492},
+	polygon2 := [][][][]float64{{{
+		{91.35604953911839, 65.11164029408492},
 		{91.45604953911838, 64.91164029408492},
 		{91.45604953911838, 65.11164029408492},
-		{91.35604953911839, 65.11164029408492}}}}
+		{91.35604953911839, 65.11164029408492},
+	}}}
 	doc = document.NewDocument("polygon2")
 	doc.AddField(document.NewGeoShapeFieldWithIndexingOptions("geometry", []uint64{},
 		polygon2, "polygon", document.DefaultGeoShapeIndexingOptions))
diff --git a/search/searcher/search_match_all_test.go b/search/searcher/search_match_all_test.go
index 74e72c32..f3b3d88a 100644
--- a/search/searcher/search_match_all_test.go
+++ b/search/searcher/search_match_all_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"testing"
 
 	"github.com/blevesearch/bleve/v2/search"
@@ -22,7 +23,6 @@ import (
 )
 
 func TestMatchAllSearch(t *testing.T) {
-
 	twoDocIndexReader, err := twoDocIndex.Reader()
 	if err != nil {
 		t.Error(err)
@@ -36,12 +36,12 @@ func TestMatchAllSearch(t *testing.T) {
 
 	explainTrue := search.SearcherOptions{Explain: true}
 
-	allSearcher, err := NewMatchAllSearcher(nil, twoDocIndexReader, 1.0, explainTrue)
+	allSearcher, err := NewMatchAllSearcher(context.TODO(), twoDocIndexReader, 1.0, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	allSearcher2, err := NewMatchAllSearcher(nil, twoDocIndexReader, 1.2, explainTrue)
+	allSearcher2, err := NewMatchAllSearcher(context.TODO(), twoDocIndexReader, 1.2, explainTrue)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/search/searcher/search_phrase_test.go b/search/searcher/search_phrase_test.go
index 207b7b24..178919de 100644
--- a/search/searcher/search_phrase_test.go
+++ b/search/searcher/search_phrase_test.go
@@ -24,7 +24,6 @@ import (
 )
 
 func TestPhraseSearch(t *testing.T) {
-
 	twoDocIndexReader, err := twoDocIndex.Reader()
 	if err != nil {
 		t.Error(err)
@@ -37,7 +36,7 @@ func TestPhraseSearch(t *testing.T) {
 	}()
 
 	soptions := search.SearcherOptions{Explain: true, IncludeTermVectors: true}
-	phraseSearcher, err := NewPhraseSearcher(nil, twoDocIndexReader, []string{"angst", "beer"}, 0, false, "desc", 1.0, soptions)
+	phraseSearcher, err := NewPhraseSearcher(context.TODO(), twoDocIndexReader, []string{"angst", "beer"}, 0, false, "desc", 1.0, soptions)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -56,8 +55,8 @@ func TestPhraseSearch(t *testing.T) {
 					Score:           1.0807601687084403,
 				},
 			},
-			locations:  map[string]map[string][]search.Location{"desc": map[string][]search.Location{"beer": []search.Location{search.Location{Pos: 2, Start: 6, End: 10}}, "angst": []search.Location{search.Location{Pos: 1, Start: 0, End: 5}}}},
-			fieldterms: [][2]string{[2]string{"desc", "beer"}, [2]string{"desc", "angst"}},
+			locations:  map[string]map[string][]search.Location{"desc": {"beer": {{Pos: 2, Start: 6, End: 10}}, "angst": {{Pos: 1, Start: 0, End: 5}}}},
+			fieldterms: [][2]string{{"desc", "beer"}, {"desc", "angst"}},
 		},
 	}
 
@@ -112,7 +111,6 @@ func TestPhraseSearch(t *testing.T) {
 }
 
 func TestMultiPhraseSearch(t *testing.T) {
-
 	soptions := search.SearcherOptions{Explain: true, IncludeTermVectors: true}
 
 	tests := []struct {
@@ -120,7 +118,7 @@ func TestMultiPhraseSearch(t *testing.T) {
 		docids [][]byte
 	}{
 		{
-			phrase: [][]string{[]string{"angst", "what"}, []string{"beer"}},
+			phrase: [][]string{{"angst", "what"}, {"beer"}},
 			docids: [][]byte{[]byte("2")},
 		},
 	}
@@ -131,7 +129,7 @@ func TestMultiPhraseSearch(t *testing.T) {
 		if err != nil {
 			t.Error(err)
 		}
-		searcher, err := NewMultiPhraseSearcher(nil, reader, test.phrase, 0, false, "desc", 1.0, soptions)
+		searcher, err := NewMultiPhraseSearcher(context.TODO(), reader, test.phrase, 0, false, "desc", 1.0, soptions)
 		if err != nil {
 			t.Error(err)
 		}
@@ -165,7 +163,6 @@ func TestMultiPhraseSearch(t *testing.T) {
 }
 
 func TestFuzzyMultiPhraseSearch(t *testing.T) {
-
 	soptions := search.SearcherOptions{Explain: true, IncludeTermVectors: true}
 
 	tests := []struct {
@@ -175,27 +172,27 @@ func TestFuzzyMultiPhraseSearch(t *testing.T) {
 		prefix    int
 	}{
 		{
-			mphrase:   [][]string{[]string{"pale", "anger"}, []string{"best"}, []string{"colon", "porch"}},
+			mphrase:   [][]string{{"pale", "anger"}, {"best"}, {"colon", "porch"}},
 			docids:    [][]byte{[]byte("2"), []byte("3")},
 			fuzziness: 2,
 		},
 		{
-			mphrase:   [][]string{[]string{"pale", "anger"}, []string{}, []string{"colon", "porch", "could"}},
+			mphrase:   [][]string{{"pale", "anger"}, {}, {"colon", "porch", "could"}},
 			docids:    nil,
 			fuzziness: 1,
 		},
 		{
-			mphrase:   [][]string{[]string{"app"}, []string{"best"}, []string{"volume"}},
+			mphrase:   [][]string{{"app"}, {"best"}, {"volume"}},
 			docids:    [][]byte{[]byte("3")},
 			fuzziness: 2,
 		},
 		{
-			mphrase:   [][]string{[]string{"anger", "pale", "bar"}, []string{"beard"}, []string{}, []string{}},
+			mphrase:   [][]string{{"anger", "pale", "bar"}, {"beard"}, {}, {}},
 			docids:    [][]byte{[]byte("1"), []byte("2"), []byte("3"), []byte("4")},
 			fuzziness: 2,
 		},
 		{
-			mphrase:   [][]string{[]string{"anger", "pale", "bar"}, []string{}, []string{"beard"}, []string{}},
+			mphrase:   [][]string{{"anger", "pale", "bar"}, {}, {"beard"}, {}},
 			docids:    [][]byte{[]byte("1"), []byte("4")},
 			fuzziness: 2,
 		},
@@ -248,7 +245,7 @@ func TestFindPhrasePaths(t *testing.T) {
 	}{
 		// simplest matching case
 		{
-			phrase: [][]string{[]string{"cat"}, []string{"dog"}},
+			phrase: [][]string{{"cat"}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -262,7 +259,7 @@ func TestFindPhrasePaths(t *testing.T) {
 				},
 			},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
@@ -270,7 +267,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// second term missing, no match
 		{
-			phrase: [][]string{[]string{"cat"}, []string{"dog"}},
+			phrase: [][]string{{"cat"}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -282,7 +279,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// second term exists but in wrong position
 		{
-			phrase: [][]string{[]string{"cat"}, []string{"dog"}},
+			phrase: [][]string{{"cat"}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -299,7 +296,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// matches multiple times
 		{
-			phrase: [][]string{[]string{"cat"}, []string{"dog"}},
+			phrase: [][]string{{"cat"}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -319,11 +316,11 @@ func TestFindPhrasePaths(t *testing.T) {
 				},
 			},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 8}},
 					phrasePart{"dog", &search.Location{Pos: 9}},
 				},
@@ -331,7 +328,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// match over gaps
 		{
-			phrase: [][]string{[]string{"cat"}, []string{""}, []string{"dog"}},
+			phrase: [][]string{{"cat"}, {""}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -345,7 +342,7 @@ func TestFindPhrasePaths(t *testing.T) {
 				},
 			},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 3}},
 				},
@@ -353,7 +350,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// match with leading ""
 		{
-			phrase: [][]string{[]string{""}, []string{"cat"}, []string{"dog"}},
+			phrase: [][]string{{""}, {"cat"}, {"dog"}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -367,7 +364,7 @@ func TestFindPhrasePaths(t *testing.T) {
 				},
 			},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 2}},
 					phrasePart{"dog", &search.Location{Pos: 3}},
 				},
@@ -375,7 +372,7 @@ func TestFindPhrasePaths(t *testing.T) {
 		},
 		// match with trailing ""
 		{
-			phrase: [][]string{[]string{"cat"}, []string{"dog"}, []string{""}},
+			phrase: [][]string{{"cat"}, {"dog"}, {""}},
 			tlm: search.TermLocationMap{
 				"cat": search.Locations{
 					&search.Location{
@@ -389,7 +386,7 @@ func TestFindPhrasePaths(t *testing.T) {
 				},
 			},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 2}},
 					phrasePart{"dog", &search.Location{Pos: 3}},
 				},
@@ -442,15 +439,15 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 	}{
 		// no match
 		{
-			phrase: [][]string{[]string{"one"}, []string{"five"}},
+			phrase: [][]string{{"one"}, {"five"}},
 			slop:   2,
 		},
 		// should match
 		{
-			phrase: [][]string{[]string{"one"}, []string{"five"}},
+			phrase: [][]string{{"one"}, {"five"}},
 			slop:   3,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"one", &search.Location{Pos: 1}},
 					phrasePart{"five", &search.Location{Pos: 5}},
 				},
@@ -458,10 +455,10 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		},
 		// slop 0 finds exact match
 		{
-			phrase: [][]string{[]string{"four"}, []string{"five"}},
+			phrase: [][]string{{"four"}, {"five"}},
 			slop:   0,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"four", &search.Location{Pos: 4}},
 					phrasePart{"five", &search.Location{Pos: 5}},
 				},
@@ -469,15 +466,15 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		},
 		// slop 0 does not find exact match (reversed)
 		{
-			phrase: [][]string{[]string{"two"}, []string{"one"}},
+			phrase: [][]string{{"two"}, {"one"}},
 			slop:   0,
 		},
 		// slop 1 finds exact match
 		{
-			phrase: [][]string{[]string{"one"}, []string{"two"}},
+			phrase: [][]string{{"one"}, {"two"}},
 			slop:   1,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"one", &search.Location{Pos: 1}},
 					phrasePart{"two", &search.Location{Pos: 2}},
 				},
@@ -485,15 +482,15 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		},
 		// slop 1 *still* does not find exact match (reversed) requires at least 2
 		{
-			phrase: [][]string{[]string{"two"}, []string{"one"}},
+			phrase: [][]string{{"two"}, {"one"}},
 			slop:   1,
 		},
 		// slop 2 does finds exact match reversed
 		{
-			phrase: [][]string{[]string{"two"}, []string{"one"}},
+			phrase: [][]string{{"two"}, {"one"}},
 			slop:   2,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"two", &search.Location{Pos: 2}},
 					phrasePart{"one", &search.Location{Pos: 1}},
 				},
@@ -501,15 +498,15 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		},
 		// slop 2 not enough for this
 		{
-			phrase: [][]string{[]string{"three"}, []string{"one"}},
+			phrase: [][]string{{"three"}, {"one"}},
 			slop:   2,
 		},
 		// slop should be cumulative
 		{
-			phrase: [][]string{[]string{"one"}, []string{"three"}, []string{"five"}},
+			phrase: [][]string{{"one"}, {"three"}, {"five"}},
 			slop:   2,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"one", &search.Location{Pos: 1}},
 					phrasePart{"three", &search.Location{Pos: 3}},
 					phrasePart{"five", &search.Location{Pos: 5}},
@@ -518,15 +515,15 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		},
 		// should require 6
 		{
-			phrase: [][]string{[]string{"five"}, []string{"three"}, []string{"one"}},
+			phrase: [][]string{{"five"}, {"three"}, {"one"}},
 			slop:   5,
 		},
 		// so lets try 6
 		{
-			phrase: [][]string{[]string{"five"}, []string{"three"}, []string{"one"}},
+			phrase: [][]string{{"five"}, {"three"}, {"one"}},
 			slop:   6,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"five", &search.Location{Pos: 5}},
 					phrasePart{"three", &search.Location{Pos: 3}},
 					phrasePart{"one", &search.Location{Pos: 1}},
@@ -539,17 +536,17 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		// hence, 3 initial terms of ark, bat, cat
 		{
 			phrase: [][]string{
-				[]string{"ark"}, []string{"bat"}, []string{"cat"}, []string{"dog"},
+				{"ark"}, {"bat"}, {"cat"}, {"dog"},
 			},
 			slop: 1,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"ark", &search.Location{Pos: 1}},
 					phrasePart{"bat", &search.Location{Pos: 2}},
 					phrasePart{"cat", &search.Location{Pos: 3}},
 					phrasePart{"dog", &search.Location{Pos: 4}},
 				},
-				phrasePath{
+				{
 					phrasePart{"ark", &search.Location{Pos: 1}},
 					phrasePart{"bat", &search.Location{Pos: 2}},
 					phrasePart{"cat", &search.Location{Pos: 3}},
@@ -575,11 +572,11 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		// test that we don't see multiple hits from the same location
 		{
 			phrase: [][]string{
-				[]string{"cat"}, []string{"dog"}, []string{"dog"},
+				{"cat"}, {"dog"}, {"dog"},
 			},
 			slop: 1,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 					phrasePart{"dog", &search.Location{Pos: 3}},
@@ -598,23 +595,23 @@ func TestFindPhrasePathsSloppy(t *testing.T) {
 		// test that we don't see multiple hits from the same location
 		{
 			phrase: [][]string{
-				[]string{"cat"}, []string{"dog"},
+				{"cat"}, {"dog"},
 			},
 			slop: 10,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 4}},
 				},
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 3}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 3}},
 					phrasePart{"dog", &search.Location{Pos: 4}},
 				},
@@ -676,10 +673,10 @@ func TestFindPhrasePathsSloppyPalyndrome(t *testing.T) {
 	}{
 		// search non palyndrone, exact match
 		{
-			phrase: [][]string{[]string{"two"}, []string{"three"}},
+			phrase: [][]string{{"two"}, {"three"}},
 			slop:   0,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"two", &search.Location{Pos: 2}},
 					phrasePart{"three", &search.Location{Pos: 3}},
 				},
@@ -687,14 +684,14 @@ func TestFindPhrasePathsSloppyPalyndrome(t *testing.T) {
 		},
 		// same with slop 2 (not required) (find it twice)
 		{
-			phrase: [][]string{[]string{"two"}, []string{"three"}},
+			phrase: [][]string{{"two"}, {"three"}},
 			slop:   2,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"two", &search.Location{Pos: 2}},
 					phrasePart{"three", &search.Location{Pos: 3}},
 				},
-				phrasePath{
+				{
 					phrasePart{"two", &search.Location{Pos: 4}},
 					phrasePart{"three", &search.Location{Pos: 3}},
 				},
@@ -702,14 +699,14 @@ func TestFindPhrasePathsSloppyPalyndrome(t *testing.T) {
 		},
 		// palyndrone reversed
 		{
-			phrase: [][]string{[]string{"three"}, []string{"two"}},
+			phrase: [][]string{{"three"}, {"two"}},
 			slop:   2,
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"three", &search.Location{Pos: 3}},
 					phrasePart{"two", &search.Location{Pos: 2}},
 				},
-				phrasePath{
+				{
 					phrasePart{"three", &search.Location{Pos: 3}},
 					phrasePart{"two", &search.Location{Pos: 4}},
 				},
@@ -726,7 +723,6 @@ func TestFindPhrasePathsSloppyPalyndrome(t *testing.T) {
 }
 
 func TestFindMultiPhrasePaths(t *testing.T) {
-
 	tlm := search.TermLocationMap{
 		"cat": search.Locations{
 			&search.Location{
@@ -751,9 +747,9 @@ func TestFindMultiPhrasePaths(t *testing.T) {
 	}{
 		// simplest, one of two possible terms matches
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, []string{"dog"}},
+			phrase: [][]string{{"cat", "rat"}, {"dog"}},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
@@ -761,21 +757,21 @@ func TestFindMultiPhrasePaths(t *testing.T) {
 		},
 		// two possible terms, neither work
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, []string{"chicken"}},
+			phrase: [][]string{{"cat", "rat"}, {"chicken"}},
 		},
 		// two possible terms, one works, but out of position with next
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, []string{"frog"}},
+			phrase: [][]string{{"cat", "rat"}, {"frog"}},
 		},
 		// matches multiple times, with different pairing
 		{
-			phrase: [][]string{[]string{"cat", "dog"}, []string{"dog", "frog"}},
+			phrase: [][]string{{"cat", "dog"}, {"dog", "frog"}},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"dog", &search.Location{Pos: 2}},
 				},
-				phrasePath{
+				{
 					phrasePart{"dog", &search.Location{Pos: 2}},
 					phrasePart{"frog", &search.Location{Pos: 3}},
 				},
@@ -783,9 +779,9 @@ func TestFindMultiPhrasePaths(t *testing.T) {
 		},
 		// multi-match over a gap
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, []string{""}, []string{"frog"}},
+			phrase: [][]string{{"cat", "rat"}, {""}, {"frog"}},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"frog", &search.Location{Pos: 3}},
 				},
@@ -793,9 +789,9 @@ func TestFindMultiPhrasePaths(t *testing.T) {
 		},
 		// multi-match over a gap (same as before, but with empty term list)
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, []string{}, []string{"frog"}},
+			phrase: [][]string{{"cat", "rat"}, {}, {"frog"}},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"frog", &search.Location{Pos: 3}},
 				},
@@ -803,9 +799,9 @@ func TestFindMultiPhrasePaths(t *testing.T) {
 		},
 		// multi-match over a gap (same once again, but nil term list)
 		{
-			phrase: [][]string{[]string{"cat", "rat"}, nil, []string{"frog"}},
+			phrase: [][]string{{"cat", "rat"}, nil, {"frog"}},
 			paths: []phrasePath{
-				phrasePath{
+				{
 					phrasePart{"cat", &search.Location{Pos: 1}},
 					phrasePart{"frog", &search.Location{Pos: 3}},
 				},
diff --git a/search/searcher/search_regexp_test.go b/search/searcher/search_regexp_test.go
index dd0afc72..02131bb8 100644
--- a/search/searcher/search_regexp_test.go
+++ b/search/searcher/search_regexp_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"encoding/binary"
 	"fmt"
 	"os"
@@ -75,7 +76,7 @@ func searcherMaker(t *testing.T, ir index.IndexReader, re, field string) search.
 		t.Fatal(err)
 	}
 
-	regexpSearcher, err := NewRegexpSearcher(nil, ir, pattern, field, 1.0,
+	regexpSearcher, err := NewRegexpSearcher(context.TODO(), ir, pattern, field, 1.0,
 		search.SearcherOptions{Explain: true})
 	if err != nil {
 		t.Fatal(err)
@@ -85,7 +86,7 @@ func searcherMaker(t *testing.T, ir index.IndexReader, re, field string) search.
 }
 
 func searcherStringMaker(t *testing.T, ir index.IndexReader, re, field string) search.Searcher {
-	regexpSearcher, err := NewRegexpStringSearcher(nil, ir, re, field, 1.0,
+	regexpSearcher, err := NewRegexpStringSearcher(context.TODO(), ir, re, field, 1.0,
 		search.SearcherOptions{Explain: true})
 	if err != nil {
 		t.Fatal(err)
@@ -96,7 +97,8 @@ func searcherStringMaker(t *testing.T, ir index.IndexReader, re, field string) s
 
 func testRegexpSearch(t *testing.T, twoDocIndex index.Index,
 	internalIDMaker func(int) index.IndexInternalID,
-	searcherMaker func(t *testing.T, ir index.IndexReader, re, field string) search.Searcher) {
+	searcherMaker func(t *testing.T, ir index.IndexReader, re, field string) search.Searcher,
+) {
 	twoDocIndexReader, err := twoDocIndex.Reader()
 	if err != nil {
 		t.Error(err)
diff --git a/search/searcher/search_term_range_test.go b/search/searcher/search_term_range_test.go
index 8f9c5928..703e54d1 100644
--- a/search/searcher/search_term_range_test.go
+++ b/search/searcher/search_term_range_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"os"
 	"reflect"
 	"sort"
@@ -172,7 +173,7 @@ func TestTermRangeSearch(t *testing.T) {
 
 	for _, test := range tests {
 
-		searcher, err := NewTermRangeSearcher(nil, twoDocIndexReader, test.min, test.max,
+		searcher, err := NewTermRangeSearcher(context.TODO(), twoDocIndexReader, test.min, test.max,
 			&test.inclusiveMin, &test.inclusiveMax, test.field, 1.0, search.SearcherOptions{Explain: true})
 		if err != nil {
 			t.Fatal(err)
@@ -229,7 +230,7 @@ func TestTermRangeSearchTooManyTerms(t *testing.T) {
 
 	want := []string{"1", "3", "4", "5"}
 	truth := true
-	searcher, err := NewTermRangeSearcher(nil, scorchReader, []byte("bobert"), []byte("ravi"),
+	searcher, err := NewTermRangeSearcher(context.TODO(), scorchReader, []byte("bobert"), []byte("ravi"),
 		&truth, &truth, "name", 1.0, search.SearcherOptions{Score: "none", IncludeTermVectors: false})
 	if err != nil {
 		t.Fatal(err)
diff --git a/search/searcher/search_term_test.go b/search/searcher/search_term_test.go
index 0c08d4c5..e87db9df 100644
--- a/search/searcher/search_term_test.go
+++ b/search/searcher/search_term_test.go
@@ -15,6 +15,7 @@
 package searcher
 
 import (
+	"context"
 	"math"
 	"testing"
 
@@ -26,11 +27,10 @@ import (
 )
 
 func TestTermSearcher(t *testing.T) {
-
-	var queryTerm = "beer"
-	var queryField = "desc"
-	var queryBoost = 3.0
-	var queryExplain = search.SearcherOptions{Explain: true}
+	queryTerm := "beer"
+	queryField := "desc"
+	queryBoost := 3.0
+	queryExplain := search.SearcherOptions{Explain: true}
 
 	analysisQueue := index.NewAnalysisQueue(1)
 	i, err := upsidedown.NewUpsideDownCouch(
@@ -118,7 +118,7 @@ func TestTermSearcher(t *testing.T) {
 		}
 	}()
 
-	searcher, err := NewTermSearcher(nil, indexReader, queryTerm, queryField, queryBoost, queryExplain)
+	searcher, err := NewTermSearcher(context.TODO(), indexReader, queryTerm, queryField, queryBoost, queryExplain)
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/search/sort_test.go b/search/sort_test.go
new file mode 100644
index 00000000..009444b5
--- /dev/null
+++ b/search/sort_test.go
@@ -0,0 +1,338 @@
+package search
+
+import (
+	"reflect"
+	"testing"
+)
+
+func TestParseSearchSortObj(t *testing.T) {
+	tests := []struct {
+		name    string
+		input   map[string]interface{}
+		want    SearchSort
+		wantErr bool
+	}{
+		{
+			name: "sort by id",
+			input: map[string]interface{}{
+				"by":   "id",
+				"desc": false,
+			},
+			want: &SortDocID{
+				Desc: false,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by id descending",
+			input: map[string]interface{}{
+				"by":   "id",
+				"desc": true,
+			},
+			want: &SortDocID{
+				Desc: true,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by score",
+			input: map[string]interface{}{
+				"by":   "score",
+				"desc": false,
+			},
+			want: &SortScore{
+				Desc: false,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by score descending",
+			input: map[string]interface{}{
+				"by":   "score",
+				"desc": true,
+			},
+			want: &SortScore{
+				Desc: true,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by geo_distance",
+			input: map[string]interface{}{
+				"by":    "geo_distance",
+				"field": "location",
+				"location": map[string]interface{}{
+					"lon": 1.0,
+					"lat": 2.0,
+				},
+				"unit": "km",
+				"desc": false,
+			},
+			want: &SortGeoDistance{
+				Field:    "location",
+				Desc:     false,
+				Lon:      1.0,
+				Lat:      2.0,
+				Unit:     "km",
+				unitMult: 1000.0,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by field",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"desc":    false,
+				"type":    "auto",
+				"mode":    "default",
+				"missing": "last",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    false,
+				Type:    SortFieldAuto,
+				Mode:    SortFieldDefault,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by field with missing",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"desc":    false,
+				"type":    "auto",
+				"mode":    "default",
+				"missing": "first",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    false,
+				Type:    SortFieldAuto,
+				Mode:    SortFieldDefault,
+				Missing: SortFieldMissingFirst,
+			},
+			wantErr: false,
+		},
+		{
+			name: "sort by field descending",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"desc":    true,
+				"type":    "string",
+				"mode":    "min",
+				"missing": "first",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    true,
+				Type:    SortFieldAsString,
+				Mode:    SortFieldMin,
+				Missing: SortFieldMissingFirst,
+			},
+			wantErr: false,
+		},
+		{
+			name: "missing by",
+			input: map[string]interface{}{
+				"desc": true,
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "unknown by",
+			input: map[string]interface{}{
+				"by": "unknown",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "missing field for geo_distance",
+			input: map[string]interface{}{
+				"by": "geo_distance",
+				"location": map[string]interface{}{
+					"lon": 1.0,
+					"lat": 2.0,
+				},
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "missing location for geo_distance",
+			input: map[string]interface{}{
+				"by":    "geo_distance",
+				"field": "location",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "invalid unit for geo_distance",
+			input: map[string]interface{}{
+				"by":    "geo_distance",
+				"field": "location",
+				"location": map[string]interface{}{
+					"lon": 1.0,
+					"lat": 2.0,
+				},
+				"unit": "invalid",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "missing field for field sort",
+			input: map[string]interface{}{
+				"by": "field",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "unknown type for field sort",
+			input: map[string]interface{}{
+				"by":    "field",
+				"field": "name",
+				"type":  "unknown",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "number type for field sort with desc",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"type":    "number",
+				"mode":    "default",
+				"desc":    true,
+				"missing": "last",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    true,
+				Type:    SortFieldAsNumber,
+				Mode:    SortFieldDefault,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "date type for field sort with desc",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"type":    "date",
+				"mode":    "default",
+				"desc":    true,
+				"missing": "last",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    true,
+				Type:    SortFieldAsDate,
+				Mode:    SortFieldDefault,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "unknown type for field sort with missing",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"type":    "unknown",
+				"mode":    "default",
+				"missing": "last",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "unknown mode for field sort",
+			input: map[string]interface{}{
+				"by":    "field",
+				"field": "name",
+				"mode":  "unknown",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+		{
+			name: "default mode for field sort",
+			input: map[string]interface{}{
+				"by":    "field",
+				"field": "name",
+				"mode":  "default",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    false,
+				Type:    SortFieldAuto,
+				Mode:    SortFieldDefault,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "max mode for field sort",
+			input: map[string]interface{}{
+				"by":    "field",
+				"field": "name",
+				"mode":  "max",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    false,
+				Type:    SortFieldAuto,
+				Mode:    SortFieldMax,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "min mode for field sort",
+			input: map[string]interface{}{
+				"by":    "field",
+				"field": "name",
+				"mode":  "min",
+			},
+			want: &SortField{
+				Field:   "name",
+				Desc:    false,
+				Type:    SortFieldAuto,
+				Mode:    SortFieldMin,
+				Missing: SortFieldMissingLast,
+			},
+			wantErr: false,
+		},
+		{
+			name: "unknown missing for field sort",
+			input: map[string]interface{}{
+				"by":      "field",
+				"field":   "name",
+				"missing": "unknown",
+			},
+			want:    nil,
+			wantErr: true,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			got, err := ParseSearchSortObj(tt.input)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("ParseSearchSortObj() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("ParseSearchSortObj() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}