mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-24 13:58:12 -05:00
* 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>
34 lines
662 B
Go
34 lines
662 B
Go
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
|
|
}
|