simplify tags

This commit is contained in:
ston1th 2019-08-25 12:34:10 +02:00
commit 3c5be25cb3
6 changed files with 28 additions and 31 deletions

View file

@ -6,7 +6,6 @@ import (
"errors"
"git.giftfish.de/ston1th/docstore/pkg/core"
"git.giftfish.de/ston1th/docstore/pkg/log"
"git.giftfish.de/ston1th/docstore/pkg/tags"
)
const (
@ -20,9 +19,9 @@ const (
pathPrefix = "path/"
)
func (db *DB) Reindex(path string, match []core.RTag) (err error) {
if match == nil {
match, err = db.GetAllRTags()
func (db *DB) Reindex(path string, tags core.RTags) (err error) {
if tags == nil {
tags, err = db.GetAllRTags()
if err != nil {
return
}
@ -36,7 +35,7 @@ func (db *DB) Reindex(path string, match []core.RTag) (err error) {
if err != nil {
return
}
doc.Tags = tags.Find(doc.Text, match)
doc.Tags = tags.Match(doc.Text)
err = db.Index.Reindex(id, doc)
if err != nil {
return
@ -53,12 +52,12 @@ func (db *DB) ReindexAll() (err error) {
if err != nil {
return
}
match, err := db.GetAllRTags()
tags, err := db.GetAllRTags()
if err != nil {
return
}
for _, p := range paths {
e := db.Reindex(p, match)
e := db.Reindex(p, tags)
if e != nil {
if err == nil {
err = errors.New("reindexAll had errors")
@ -69,7 +68,7 @@ func (db *DB) ReindexAll() (err error) {
return
}
func (db *DB) GetPaths(res []core.Result) {
func (db *DB) GetPaths(res core.Results) {
for i, v := range res {
err := db.store.Get(pathPrefix+v.ID, &res[i].Path)
if err != nil {