Example #1
0
// NewIndexer creates a new Indexer with the received config
func NewIndexer(engine string, config indexer.Config) (index indexer.Handler, err error) {
	switch engine {
	case "bleve":
		index, err = bleve.New(config)
		break
	default:
		index, err = bleve.New(config)
		break
	}
	return
}
Example #2
0
// NewIndexer creates a new Indexer with the received config
func NewIndexer(engine string, config indexer.Config) (index indexer.Handler, err error) {
	name := filepath.Clean(config.IndexDirectory + string(filepath.Separator) + config.HostName)
	switch engine {
	default:
		index, err = bleve.New(name)
	}
	return
}
func BenchmarkPipeline(b *testing.B) {
	b.ReportAllocs()

	os.RemoveAll("/tmp/caddyIndexTest")
	indxr, err := bleve.New("/tmp/caddyIndexTest")

	if err != nil {
		b.Fatal(err)
	}

	pipeline, err2 := search.NewPipeline(&search.Config{}, indxr)
	if err2 != nil {
		b.Fatal(err)
	}

	cwd, _ := os.Getwd()
	path := cwd + "/README.md"

	for i := 0; i < b.N; i++ {
		rec := indxr.Record(path)
		rec.SetFullPath(path)
		pipeline.Pipe(rec)
	}
}