some bug fixes
This commit is contained in:
parent
5649acf6a8
commit
577cf4d482
10 changed files with 83 additions and 17 deletions
|
|
@ -28,6 +28,10 @@ GOOS=openbsd make vendor
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
**Requirements:**
|
||||||
|
* tesseract
|
||||||
|
* pdftotext
|
||||||
|
|
||||||
See the `scripts/` directory on how to install docstore on Linux or OpenBSD.
|
See the `scripts/` directory on how to install docstore on Linux or OpenBSD.
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
@ -53,6 +57,7 @@ See the `scripts/` directory on how to install docstore on Linux or OpenBSD.
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Fulltext indexing of documents
|
* 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
|
* 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/)
|
* Custom regex based tags (see https://golang.org/pkg/regexp/syntax/)
|
||||||
* The `Retag All` button will reapply the current tags to all indexed documents
|
* The `Retag All` button will reapply the current tags to all indexed documents
|
||||||
|
|
|
||||||
1
go.mod
1
go.mod
|
|
@ -6,6 +6,7 @@ require (
|
||||||
git.giftfish.de/ston1th/godrop/v2 v2.1.0
|
git.giftfish.de/ston1th/godrop/v2 v2.1.0
|
||||||
git.giftfish.de/ston1th/jwt/v3 v3.2.0
|
git.giftfish.de/ston1th/jwt/v3 v3.2.0
|
||||||
github.com/RoaringBitmap/roaring v0.4.17 // indirect
|
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/bleve v0.8.0
|
||||||
github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 // indirect
|
github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 // indirect
|
||||||
github.com/blevesearch/go-porterstemmer v1.0.2 // indirect
|
github.com/blevesearch/go-porterstemmer v1.0.2 // indirect
|
||||||
|
|
|
||||||
2
go.sum
2
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=
|
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 h1:oCYFIFEMSQZrLHpywH7919esI1VSrQZ0pJXkZPGIJ78=
|
||||||
github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI=
|
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 h1:DCoCrxscCXrlzVWK92k7Vq4d28lTAFuigVmcgIX0VCo=
|
||||||
github.com/blevesearch/bleve v0.8.0/go.mod h1:Y2lmIkzV6mcNfAnAdOd+ZxHkHchhBfU/xroGIp61wfw=
|
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=
|
github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 h1:U6vnxZrTfItfiUiYx0lf/LgHjRSfaKK5QHSom3lEbnA=
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,30 @@ func loadConfig() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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()
|
return file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ type User struct {
|
||||||
type Result struct {
|
type Result struct {
|
||||||
ID string
|
ID string
|
||||||
Path string
|
Path string
|
||||||
Tags string
|
Tags []string
|
||||||
HTML template.HTML
|
HTML template.HTML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ package index
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"git.giftfish.de/ston1th/docstore/pkg/core"
|
"git.giftfish.de/ston1th/docstore/pkg/core"
|
||||||
|
"github.com/bcampbell/qs"
|
||||||
"github.com/blevesearch/bleve"
|
"github.com/blevesearch/bleve"
|
||||||
"github.com/blevesearch/bleve/document"
|
"github.com/blevesearch/bleve/document"
|
||||||
"github.com/blevesearch/bleve/mapping"
|
"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) {
|
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.Highlight = bleve.NewHighlightWithStyle("html")
|
||||||
req.Size = maxSearchResult
|
req.Size = maxSearchResult
|
||||||
res, err := i.i.Search(req)
|
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 {
|
for _, f := range frags {
|
||||||
t += f
|
t += f
|
||||||
}
|
}
|
||||||
r.Tags = strings.ReplaceAll(strings.ReplaceAll(t, "<mark>", ""), "</mark>", "")
|
r.Tags = append(r.Tags, strings.ReplaceAll(strings.ReplaceAll(t, "<mark>", ""), "</mark>", ""))
|
||||||
}
|
}
|
||||||
if fragField == textField || fragField == createdField {
|
if fragField == textField || fragField == createdField {
|
||||||
for _, f := range frags {
|
for _, f := range frags {
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,13 @@ const (
|
||||||
<h2>{{.BodyTitle}}</h2>
|
<h2>{{.BodyTitle}}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col col-nopad">
|
||||||
|
<div class="alert alert-primary">
|
||||||
|
<p>This log will display error information about batch operations such as <code>Retag All</code> or <code>Index All</code>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row mt-3">
|
<div class="row mt-3">
|
||||||
<textarea class="form-control input-sm md-text mono" rows="30" spellcheck="false" autofocus>{{.Data}}</textarea>
|
<textarea class="form-control input-sm md-text mono" rows="30" spellcheck="false" autofocus>{{.Data}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -451,20 +458,22 @@ const (
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>File</th>
|
<th>File</th>
|
||||||
<th>Tag</th>
|
<th>Tags</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{range $item := .Data}}
|
{{range $item := .Data}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a class="mono" href="{{$item.Path}}"><b>{{$item.Path}}</b></a>
|
<a class="mono" href="{{$item.Path}}"><b>{{$item.Path}}</b></a>
|
||||||
{{if $item.HTML}}
|
{{if $item.HTML}}
|
||||||
<br><pre class="wrap">{{$item.HTML}}</pre>
|
<br><pre class="wrap">{{$item.HTML}}</pre>
|
||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $item.Tags}}<a href="/search?query=tags:{{$item.Tags}}" class="btn badge btn-primary">{{$item.Tags}}</a>{{end}}
|
{{range $t := $item.Tags}}
|
||||||
|
<a href="/search?query=tags:{{$t}}" class="btn badge btn-primary">{{$t}}</a>
|
||||||
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
@ -477,9 +486,14 @@ const (
|
||||||
<div class="col col-nopad">
|
<div class="col col-nopad">
|
||||||
<div class="alert alert-primary">
|
<div class="alert alert-primary">
|
||||||
<h4>Query Syntax</h4>
|
<h4>Query Syntax</h4>
|
||||||
|
<p>Documentation: <a target="_blank" rel="noopener noreferrer" href="https://github.com/bcampbell/qs/blob/master/syntax.md">https://github.com/bcampbell/qs/blob/master/syntax.md</a></p>
|
||||||
<p>Fields</p>
|
<p>Fields</p>
|
||||||
<pre><code>tags:insurance
|
<pre><code>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"</code></pre>
|
created:<="2016-09-21"</code></pre>
|
||||||
<p>Fulltext</p>
|
<p>Fulltext</p>
|
||||||
<pre><code>some text here</code></pre>
|
<pre><code>some text here</code></pre>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
apt install -y poppler-utils tesseract-ocr tesseract-ocr-deu tesseract-ocr-eng
|
||||||
groupadd docstore
|
groupadd docstore
|
||||||
useradd -g docstore docstore
|
useradd -g docstore docstore
|
||||||
mkdir /var/lib/docstore
|
mkdir /var/lib/docstore
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,13 @@
|
||||||
<h2>{{.BodyTitle}}</h2>
|
<h2>{{.BodyTitle}}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col col-nopad">
|
||||||
|
<div class="alert alert-primary">
|
||||||
|
<p>This log will display error information about batch operations such as <code>Retag All</code> or <code>Index All</code>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row mt-3">
|
<div class="row mt-3">
|
||||||
<textarea class="form-control input-sm md-text mono" rows="30" spellcheck="false" autofocus>{{.Data}}</textarea>
|
<textarea class="form-control input-sm md-text mono" rows="30" spellcheck="false" autofocus>{{.Data}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,22 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>File</th>
|
<th>File</th>
|
||||||
<th>Tag</th>
|
<th>Tags</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{range $item := .Data}}
|
{{range $item := .Data}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a class="mono" href="{{$item.Path}}"><b>{{$item.Path}}</b></a>
|
<a class="mono" href="{{$item.Path}}"><b>{{$item.Path}}</b></a>
|
||||||
{{if $item.HTML}}
|
{{if $item.HTML}}
|
||||||
<br><pre class="wrap">{{$item.HTML}}</pre>
|
<br><pre class="wrap">{{$item.HTML}}</pre>
|
||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $item.Tags}}<a href="/search?query=tags:{{$item.Tags}}" class="btn badge btn-primary">{{$item.Tags}}</a>{{end}}
|
{{range $t := $item.Tags}}
|
||||||
|
<a href="/search?query=tags:{{$t}}" class="btn badge btn-primary">{{$t}}</a>
|
||||||
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
@ -51,9 +53,14 @@
|
||||||
<div class="col col-nopad">
|
<div class="col col-nopad">
|
||||||
<div class="alert alert-primary">
|
<div class="alert alert-primary">
|
||||||
<h4>Query Syntax</h4>
|
<h4>Query Syntax</h4>
|
||||||
|
<p>Documentation: <a target="_blank" rel="noopener noreferrer" href="https://github.com/bcampbell/qs/blob/master/syntax.md">https://github.com/bcampbell/qs/blob/master/syntax.md</a></p>
|
||||||
<p>Fields</p>
|
<p>Fields</p>
|
||||||
<pre><code>tags:insurance
|
<pre><code>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"</code></pre>
|
created:<="2016-09-21"</code></pre>
|
||||||
<p>Fulltext</p>
|
<p>Fulltext</p>
|
||||||
<pre><code>some text here</code></pre>
|
<pre><code>some text here</code></pre>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue