Skip to content

Commit 8ca1322

Browse files
committed
Add LUCENENET-specific backport comment, fix test code style
1 parent 75f9974 commit 8ca1322

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ public virtual void TestFuzziness()
195195
reader.Dispose();
196196
directory.Dispose();
197197
}
198+
199+
// LUCENENET-specific: backported fix from Lucene 9.0.0 (lucene@45611d0, LUCENE-9365)
198200
[Test]
199201
public void TestPrefixLengthEqualStringLength()
200202
{
@@ -204,7 +206,7 @@ public void TestPrefixLengthEqualStringLength()
204206
AddDoc("b*ab", writer);
205207
AddDoc("b*abc", writer);
206208
AddDoc("b*abcd", writer);
207-
String multibyte = "아프리카코끼리속";
209+
const string multibyte = "아프리카코끼리속"; // LUCENENET-specific: made const
208210
AddDoc(multibyte, writer);
209211
IndexReader reader = writer.GetReader();
210212
IndexSearcher searcher = NewSearcher(reader);
@@ -226,17 +228,17 @@ public void TestPrefixLengthEqualStringLength()
226228
hits = searcher.Search(query, 1000).ScoreDocs;
227229
assertEquals(3, hits.Length);
228230

229-
maxEdits = 1;
230-
prefixLength = multibyte.Length - 1;
231-
query = new FuzzyQuery(new Term("field", multibyte.Substring(0, prefixLength)), maxEdits, prefixLength);
232-
hits = searcher.Search(query, 1000).ScoreDocs;
233-
assertEquals(1, hits.Length);
231+
maxEdits = 1;
232+
prefixLength = multibyte.Length - 1;
233+
query = new FuzzyQuery(new Term("field", multibyte.Substring(0, prefixLength)), maxEdits, prefixLength);
234+
hits = searcher.Search(query, 1000).ScoreDocs;
235+
assertEquals(1, hits.Length);
234236

235-
reader.DoClose();
236-
directory.Dispose();
237-
}
237+
reader.Dispose();
238+
directory.Dispose();
239+
}
238240

239-
[Test]
241+
[Test]
240242
public virtual void Test2()
241243
{
242244
Directory directory = NewDirectory();

src/Lucene.Net/Search/FuzzyQuery.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ public FuzzyQuery(Term term)
148148

149149
protected override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
150150
{
151-
if (maxEdits == 0 ) // can only match if it's exact
151+
// LUCENENET-specific: backported fix from Lucene 9.0.0 (lucene@45611d0, LUCENE-9365)
152+
if (maxEdits == 0) // can only match if it's exact
152153
{
153154
return new SingleTermsEnum(terms.GetEnumerator(), term.Bytes);
154155
}

0 commit comments

Comments
 (0)