[full-ci] experimental search backport (#5221)
* experimental search backport fix basic extractor resource name move escapeQuery regex into global variable minor pr review changes rename DebounceDuration env variable add document title and content when rebuilding bleve resource Co-authored-by: David Christofas <dchristofas@owncloud.com>
This commit is contained in:
co-authored by
David Christofas
parent
2fa1a3afbe
commit
2404eff48e
@@ -0,0 +1,33 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
)
|
||||
|
||||
// Extractor is responsible to extract content and meta information from documents.
|
||||
//
|
||||
//go:generate mockery --name=Extractor
|
||||
type Extractor interface {
|
||||
Extract(ctx context.Context, ri *provider.ResourceInfo) (Document, error)
|
||||
}
|
||||
|
||||
func getFirstValue(m map[string][]string, key string) (string, error) {
|
||||
if m == nil {
|
||||
return "", errors.New("undefined map")
|
||||
}
|
||||
|
||||
v, ok := m[key]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("unknown key: %v", key)
|
||||
}
|
||||
|
||||
if len(m) == 0 {
|
||||
return "", fmt.Errorf("no values for: %v", key)
|
||||
}
|
||||
|
||||
return v[0], nil
|
||||
}
|
||||
Reference in New Issue
Block a user