Skip to content

Commit bc28e8f

Browse files
committed
Clear de-dupe HashSet when starting a new build
1 parent bf782e1 commit bc28e8f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/ifactory/press/db/solr/spelling/suggest/SafariInfixSuggester.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class SafariInfixSuggester extends AnalyzingInfixSuggester {
2020

2121
private final boolean highlight;
22-
private final Set<BytesRef> suggestionSet;
22+
private Set<BytesRef> suggestionSet;
2323
private static final Logger LOG = LoggerFactory.getLogger(SafariInfixSuggester.class);
2424

2525
public enum Context {
@@ -40,7 +40,7 @@ public SafariInfixSuggester(
4040

4141
showContext = Collections.singleton(new BytesRef(new byte[] { (byte) Context.SHOW.ordinal() }));
4242
hideContext = Collections.singleton(new BytesRef(new byte[] { (byte) Context.HIDE.ordinal() }));
43-
suggestionSet = new HashSet<BytesRef>();
43+
suggestionSet = new HashSet<>();
4444

4545
if (!DirectoryReader.indexExists(dir)) {
4646
// no index in place -- build an empty one so we are prepared for updates
@@ -57,6 +57,14 @@ public void update(BytesRef bytes, long weight) throws IOException {
5757
super.update(bytes, weight <= 0 ? hideContext : showContext, weight, null);
5858
}
5959

60+
@Override
61+
public void build(InputIterator iter) throws IOException {
62+
// Reset suggestion HashSet on build
63+
LOG.info("\n\nStarting suggestion build.");
64+
suggestionSet = new HashSet<>();
65+
super.build(iter);
66+
}
67+
6068
/**
6169
* Like build(), but without flushing the old entries, and *ignores duplicate entries*
6270
*

0 commit comments

Comments
 (0)