MCPcopy
hub / github.com/dgraph-io/dgraph / defaultMatch

Function defaultMatch

worker/stringfilter.go:50–74  ·  view source on GitHub ↗
(value types.Val, filter *stringFilter)

Source from the content-addressed store, hash-verified

48}
49
50func defaultMatch(value types.Val, filter *stringFilter) bool {
51 tokenMap := map[string]bool{}
52 for _, t := range filter.tokens {
53 tokenMap[t] = false
54 }
55
56 tokens := tokenizeValue(value, filter)
57 cnt := 0
58 for _, token := range tokens {
59 previous, ok := tokenMap[token]
60 if ok {
61 tokenMap[token] = true
62 if !previous { // count only once
63 cnt++
64 }
65 }
66 }
67
68 all := strings.HasPrefix(filter.funcName, "allof") // anyofterms or anyoftext
69
70 if all {
71 return cnt == len(filter.tokens)
72 }
73 return cnt > 0
74}
75
76func ineqMatch(value types.Val, filter *stringFilter) bool {
77 if filter.funcName == eq {

Callers

nothing calls this directly

Calls 1

tokenizeValueFunction · 0.85

Tested by

no test coverage detected