forked from dfuse-io/dfuse-eosio
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblevequery.go
More file actions
32 lines (25 loc) · 778 Bytes
/
blevequery.go
File metadata and controls
32 lines (25 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package search
import (
"sort"
"strings"
"github.com/streamingfast/derr"
search "github.com/streamingfast/search"
"google.golang.org/grpc/codes"
)
type BleveQueryValidator struct {
indexedTerms *IndexedTerms
}
func (v *BleveQueryValidator) Validate(q *search.BleveQuery) error {
var unknownFields []string
for _, fieldName := range q.FieldNames {
if !v.indexedTerms.IsIndexed(fieldName) {
unknownFields = append(unknownFields, fieldName)
}
}
if len(unknownFields) <= 0 {
return nil
}
sort.Strings(unknownFields)
invalidArgString := "The following fields you are trying to search are not currently indexed: '%s'. Contact our support team for more."
return derr.Statusf(codes.InvalidArgument, invalidArgString, strings.Join(unknownFields, "', '"))
}