diff --git a/README.md b/README.md index 085ac6c..3fe39df 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ GOOS=openbsd make vendor ## Install +**Requirements:** +* tesseract +* pdftotext + See the `scripts/` directory on how to install docstore on Linux or OpenBSD. ## Config @@ -53,6 +57,7 @@ See the `scripts/` directory on how to install docstore on Linux or OpenBSD. ## Features * Fulltext indexing of documents + * Query Syntax: https://github.com/bcampbell/qs/blob/master/syntax.md * The `Index All` button tries add every file not already indexed to the index * Custom regex based tags (see https://golang.org/pkg/regexp/syntax/) * The `Retag All` button will reapply the current tags to all indexed documents diff --git a/go.mod b/go.mod index 6a4c77f..59b541d 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( git.giftfish.de/ston1th/godrop/v2 v2.1.0 git.giftfish.de/ston1th/jwt/v3 v3.2.0 github.com/RoaringBitmap/roaring v0.4.17 // indirect + github.com/bcampbell/qs v0.0.0-20161004022730-15caa99abd01 github.com/blevesearch/bleve v0.8.0 github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 // indirect github.com/blevesearch/go-porterstemmer v1.0.2 // indirect diff --git a/go.sum b/go.sum index 407066a..a8ee9ef 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ git.giftfish.de/ston1th/jwt/v3 v3.2.0 h1:V6Lh7OjXn4D3HPd/LoDf7w5N7cyiSXEPAQCIfSV git.giftfish.de/ston1th/jwt/v3 v3.2.0/go.mod h1:jDALrW7OKeIaqYuMxs3GWyPRnQZmk/R+Lu9p/Em3Ziw= github.com/RoaringBitmap/roaring v0.4.17 h1:oCYFIFEMSQZrLHpywH7919esI1VSrQZ0pJXkZPGIJ78= github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI= +github.com/bcampbell/qs v0.0.0-20161004022730-15caa99abd01 h1:ZkEYngtmNszw0BJt4GoWW5rdn5U6MaFlLAUD4S3KEas= +github.com/bcampbell/qs v0.0.0-20161004022730-15caa99abd01/go.mod h1:ZgSGz2VRprXTqsfbn6HAH1ePnGiVCrlA3kflJ6Sjxqg= github.com/blevesearch/bleve v0.8.0 h1:DCoCrxscCXrlzVWK92k7Vq4d28lTAFuigVmcgIX0VCo= github.com/blevesearch/bleve v0.8.0/go.mod h1:Y2lmIkzV6mcNfAnAdOd+ZxHkHchhBfU/xroGIp61wfw= github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 h1:U6vnxZrTfItfiUiYx0lf/LgHjRSfaKK5QHSom3lEbnA= diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 10801de..3d0fe41 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -125,6 +125,30 @@ func loadConfig() error { if err != nil { return err } + if config.RunDir == "" { + config.RunDir = defRunDir + } + if config.User == "" { + config.User = defRunUser + } + if config.Group == "" { + config.Group = defRunGroup + } + if config.ListenAddr == "" { + config.ListenAddr = defListen + } + if config.LogFile == "" { + config.LogFile = defLogFile + } + if config.CMDTimeout == 0 { + config.CMDTimeout = defTimeout + } + if config.TesseractThreads == 0 { + config.TesseractThreads = tesseractThreads + } + if config.TesseractOEM == 0 { + config.TesseractOEM = tesseractOEM + } return file.Close() } diff --git a/pkg/core/types.go b/pkg/core/types.go index 169c9a5..78e006f 100644 --- a/pkg/core/types.go +++ b/pkg/core/types.go @@ -17,7 +17,7 @@ type User struct { type Result struct { ID string Path string - Tags string + Tags []string HTML template.HTML } diff --git a/pkg/index/index.go b/pkg/index/index.go index 6047a3a..cedc7ba 100644 --- a/pkg/index/index.go +++ b/pkg/index/index.go @@ -5,6 +5,7 @@ package index import ( "errors" "git.giftfish.de/ston1th/docstore/pkg/core" + "github.com/bcampbell/qs" "github.com/blevesearch/bleve" "github.com/blevesearch/bleve/document" "github.com/blevesearch/bleve/mapping" @@ -107,7 +108,11 @@ func (i *Index) Delete(id string) error { } func (i *Index) Search(search string) (results core.Results, err error) { - req := bleve.NewSearchRequest(bleve.NewQueryStringQuery(search)) + q, err := qs.Parse(search) + if err != nil { + return + } + req := bleve.NewSearchRequest(q) req.Highlight = bleve.NewHighlightWithStyle("html") req.Size = maxSearchResult res, err := i.i.Search(req) @@ -129,7 +134,7 @@ func (i *Index) Search(search string) (results core.Results, err error) { for _, f := range frags { t += f } - r.Tags = strings.ReplaceAll(strings.ReplaceAll(t, "", ""), "", "") + r.Tags = append(r.Tags, strings.ReplaceAll(strings.ReplaceAll(t, "", ""), "", "")) } if fragField == textField || fragField == createdField { for _, f := range frags { diff --git a/pkg/server/templates.go b/pkg/server/templates.go index bafc871..1774ec4 100644 --- a/pkg/server/templates.go +++ b/pkg/server/templates.go @@ -297,6 +297,13 @@ const (

{{.BodyTitle}}

+
+
+
+

This log will display error information about batch operations such as Retag All or Index All.

+
+
+
@@ -451,20 +458,22 @@ const ( File - Tag + Tags {{range $item := .Data}} - {{$item.Path}} - {{if $item.HTML}} -
{{$item.HTML}}
- {{end}} + {{$item.Path}} + {{if $item.HTML}} +
{{$item.HTML}}
+ {{end}} - {{if $item.Tags}}{{$item.Tags}}{{end}} + {{range $t := $item.Tags}} + {{$t}} + {{end}} {{end}} @@ -477,9 +486,14 @@ const (

Query Syntax

+

Documentation: https://github.com/bcampbell/qs/blob/master/syntax.md

Fields

tags:insurance
-tags:insurance or tags:invoice
+tags:insurance OR tags:invoice
+# combine tags
+tags:insurance AND tags:invoice
+# exclude tags
+tags:insurance -tags:invoice
 created:<="2016-09-21"

Fulltext

some text here
diff --git a/scripts/install_linux.sh b/scripts/install_linux.sh index ed90c5d..72a75af 100755 --- a/scripts/install_linux.sh +++ b/scripts/install_linux.sh @@ -1,4 +1,5 @@ #!/bin/sh +apt install -y poppler-utils tesseract-ocr tesseract-ocr-deu tesseract-ocr-eng groupadd docstore useradd -g docstore docstore mkdir /var/lib/docstore diff --git a/templates/logs.html b/templates/logs.html index d2f00de..b7b1b53 100644 --- a/templates/logs.html +++ b/templates/logs.html @@ -4,6 +4,13 @@

{{.BodyTitle}}

+
+
+
+

This log will display error information about batch operations such as Retag All or Index All.

+
+
+
diff --git a/templates/search.html b/templates/search.html index 1158011..82f5046 100644 --- a/templates/search.html +++ b/templates/search.html @@ -25,20 +25,22 @@ File - Tag + Tags {{range $item := .Data}} - {{$item.Path}} - {{if $item.HTML}} -
{{$item.HTML}}
- {{end}} + {{$item.Path}} + {{if $item.HTML}} +
{{$item.HTML}}
+ {{end}} - {{if $item.Tags}}{{$item.Tags}}{{end}} + {{range $t := $item.Tags}} + {{$t}} + {{end}} {{end}} @@ -51,9 +53,14 @@

Query Syntax

+

Documentation: https://github.com/bcampbell/qs/blob/master/syntax.md

Fields

tags:insurance
-tags:insurance or tags:invoice
+tags:insurance OR tags:invoice
+# combine tags
+tags:insurance AND tags:invoice
+# exclude tags
+tags:insurance -tags:invoice
 created:<="2016-09-21"

Fulltext

some text here