Commit ec0fea8e authored by Rob Tomsick's avatar Rob Tomsick

Make drug search use the same fuzzy hashing approach as everything else

parent d61bbba1
......@@ -190,18 +190,30 @@ implements DictionaryService
/* fuzzy hash search */
final Iterator<List<String>> hi =
partitionByLength(hashFuzz(query, HASH_DISTANCE, MIN_FUZZY_HASH_LEN)).iterator();
final List<List<String>> hashes =
partitionByLength(hashFuzz(query, HASH_DISTANCE, MIN_FUZZY_HASH_LEN));
while (drugs.size() < limit && hi.hasNext())
final Field<String> hashField =
field(name("phonetic_hash"), String.class);
for (final List<String> hashGroup : hashes)
List<String> hashes =;
if (drugs.size() >= limit)
Condition cond = DSL.falseCondition();
for (String hash : hashGroup)
cond = cond.or(;
.where(field(name("phonetic_hash"), String.class).in(hashes))
.limit(limit - drugs.size())
.map(n -> new Drug(n.toUpperCase()))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment