// returns a prefiltered list of elements; you still need to do a // full-text search on those. // If it returns null, you have to search all elements static Cl wordIndex_lookupString(WordIndex index, S query) { L ranges = index.wordRanges(query); if (empty(ranges)) null; new L> sets; for (IntRange r : ranges) { // go through words in query S word = substring(query, r); Set l; if (r.start == 0) if (r.end == l(query)) l = msmGetAllAsSet(index.index, containingIC(index.words(), word)); else l = msmGetAllAsSet(index.index, endingWithIC(index.words(), word)); else if (r.end == l(query)) l = msmGetAllAsSet(index.index, prefixSubSet(index.words(), word)); else l = index.get(word); if (empty(l)) ret l; sets.add(l); } Set smallest = smallestCollection(sets), out = smallest; for (Set set : sets) { if (set == smallest) continue; new Set out2; for (A a : out) if (set.contains(a)) out2.add(a); out = out2; } ret out; }