func NewRegexpStringSearcher(indexReader index.IndexReader, pattern string,
	field string, boost float64, options search.SearcherOptions) (
	search.Searcher, error) {
	ir, ok := indexReader.(index.IndexReaderRegexp)
	if !ok {
		r, err := regexp.Compile(pattern)
		if err != nil {
			return nil, err
		}
		return NewRegexpSearcher(indexReader, r, field, boost, options)
	}
	fieldDict, err := ir.FieldDictRegexp(field, pattern)
	if err != nil {
		return nil, err
	}
	defer func() {
		if cerr := fieldDict.Close(); cerr != nil && err == nil {
			err = cerr
		}
	}()
	var candidateTerms []string
	tfd, err := fieldDict.Next()
	for err == nil && tfd != nil {
		candidateTerms = append(candidateTerms, tfd.Term)
		tfd, err = fieldDict.Next()
	}
	if err != nil {
		return nil, err
	}
	return NewMultiTermSearcher(indexReader, candidateTerms, field, boost,
		options, true)
}
NewRegexpStringSearcher is similar to NewRegexpSearcher, but
additionally optimizes for index readers that handle regexp's.
package searcher
import (
	"regexp"
	"github.com/blevesearch/bleve/v2/search"
	index "github.com/blevesearch/bleve_index_api"
)
type Regexp interface {
	FindStringIndex(s string) (loc []int)
	LiteralPrefix() (prefix string, complete bool)
	String() string
}