NewSearch creates a filter that searches records for the given value, which must be of a type other than string. The filter matches a record that contains this value either as the value of any field or inside any set or array. It also matches a record if the string representaton of the search valu
(searchtext string, searchval super.Value, expr Evaluator)
| 85 | // representaton of the search value appears inside inside any string-valued |
| 86 | // field (or inside any element of a set or array of strings). |
| 87 | func NewSearch(searchtext string, searchval super.Value, expr Evaluator) (Evaluator, error) { |
| 88 | if super.TypeUnder(searchval.Type()) == super.TypeNet { |
| 89 | return &searchCIDR{ |
| 90 | net: super.DecodeNet(searchval.Bytes()), |
| 91 | bytes: searchval.Bytes(), |
| 92 | }, nil |
| 93 | } |
| 94 | typedCompare, err := Comparison("==", searchval) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } |
| 98 | return &search{searchtext, typedCompare, expr}, nil |
| 99 | } |
| 100 | |
| 101 | func (s *search) Eval(val super.Value) super.Value { |
| 102 | if s.expr != nil { |
no test coverage detected