about summary refs log tree commit diff stats
path: root/internal/search/search.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-11 14:43:01 +0200
committerAlan Pearce2024-05-11 14:43:01 +0200
commit76f18d677b9b0bb70f701824e715f2ed10aeb8a0 (patch)
tree3ff2dadebde49f2042535c40f5832ebfa93d1b0b /internal/search/search.go
parentdbe952d1df63522e5c32b4ef3e59c43886ba9257 (diff)
downloadsearchix-76f18d677b9b0bb70f701824e715f2ed10aeb8a0.tar.lz
searchix-76f18d677b9b0bb70f701824e715f2ed10aeb8a0.tar.zst
searchix-76f18d677b9b0bb70f701824e715f2ed10aeb8a0.zip
feat: version search index mapping schema and warn if outdated
Diffstat (limited to 'internal/search/search.go')
-rw-r--r--internal/search/search.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/search/search.go b/internal/search/search.go
index 357698c..829fefe 100644
--- a/internal/search/search.go
+++ b/internal/search/search.go
@@ -26,18 +26,26 @@ type Result struct {
 
 type ReadIndex struct {
 	index bleve.Index
+	meta  *IndexMeta
 }
 
 func Open(dataRoot string) (*ReadIndex, error) {
 	indexPath := path.Join(dataRoot, indexBaseName)
+	metaPath := path.Join(dataRoot, metaBaseName)
 
 	idx, err := bleve.Open(indexPath)
 	if err != nil {
 		return nil, errors.WithMessagef(err, "unable to open index at path %s", indexPath)
 	}
 
+	meta, err := openMeta(metaPath)
+	if err != nil {
+		return nil, errors.WithMessagef(err, "unable to open metadata at path %s", metaPath)
+	}
+
 	return &ReadIndex{
 		idx,
+		meta,
 	}, nil
 }