andTrigrams returns q AND the OR of the AND of the trigrams present in each string.
(t stringSet)
| 258 | |
| 259 | // andTrigrams returns q AND the OR of the AND of the trigrams present in each string. |
| 260 | func (q *Query) andTrigrams(t stringSet) *Query { |
| 261 | if t.minLen() < 3 { |
| 262 | // If there is a short string, we can't guarantee |
| 263 | // that any trigrams must be present, so use ALL. |
| 264 | // q AND ALL = q. |
| 265 | return q |
| 266 | } |
| 267 | |
| 268 | //println("andtrigrams", strings.Join(t, ",")) |
| 269 | or := noneQuery |
| 270 | for _, tt := range t { |
| 271 | var trig stringSet |
| 272 | for i := 0; i+3 <= len(tt); i++ { |
| 273 | trig.add(tt[i : i+3]) |
| 274 | } |
| 275 | trig.clean(false) |
| 276 | //println(tt, "trig", strings.Join(trig, ",")) |
| 277 | or = or.or(&Query{Op: QAnd, Trigram: trig}) |
| 278 | } |
| 279 | q = q.and(or) |
| 280 | return q |
| 281 | } |
| 282 | |
| 283 | func (q *Query) String() string { |
| 284 | if q == nil { |