Skip to content

Commit d43c48c

Browse files
committed
feat!: upgrade to Lucene.Net 4.8.0-beta00016
1 parent a128975 commit d43c48c

File tree

92 files changed

+513
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+513
-537
lines changed
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
using System;
21
using System.IO;
32
using Lucene.Net.Analysis;
43
using Lucene.Net.Analysis.Standard;
5-
using Lucene.Net.Analysis.Tokenattributes;
4+
using Lucene.Net.Analysis.TokenAttributes;
5+
using Lucene.Net.Util;
66

77
namespace NHibernate.Search.Tests.Analyzer
88
{
99
public abstract class AbstractTestAnalyzer : Lucene.Net.Analysis.Analyzer
1010
{
1111
protected abstract string[] Tokens { get; }
1212

13-
public override TokenStream TokenStream(string fieldName, TextReader reader)
13+
protected override TokenStreamComponents CreateComponents(string fieldName, TextReader reader)
1414
{
15-
return new InternalTokenStream(Tokens);
15+
return new TokenStreamComponents(
16+
new StandardTokenizer(LuceneVersion.LUCENE_48, reader),
17+
new InternalTokenStream(Tokens));
1618
}
1719

18-
#region Nested type: InternalTokenStream
19-
20-
private class InternalTokenStream : TokenStream
20+
private sealed class InternalTokenStream : TokenStream
2121
{
2222
private readonly string[] tokens;
2323
private int position;
24-
private readonly ITermAttribute termAttribute;
24+
private readonly IPayloadAttribute attribute;
2525

2626
public InternalTokenStream(string[] tokens)
2727
{
2828
this.tokens = tokens;
29-
termAttribute = AddAttribute<ITermAttribute>();
29+
attribute = AddAttribute<IPayloadAttribute>();
3030
}
3131

3232
public override bool IncrementToken()
3333
{
3434
ClearAttributes();
3535
if (position < tokens.Length)
3636
{
37-
termAttribute.SetTermBuffer(tokens[position++]);
37+
attribute.Payload = new BytesRef(tokens[position++]);
3838
}
3939

4040
return false;
@@ -44,7 +44,5 @@ protected override void Dispose(bool disposing)
4444
{
4545
}
4646
}
47-
48-
#endregion
4947
}
5048
}

src/NHibernate.Search.Tests/Analyzer/AnalyzerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using Lucene.Net.Analysis.Standard;
4-
using Lucene.Net.QueryParsers;
4+
using Lucene.Net.QueryParsers.Classic;
55
using Lucene.Net.Util;
66
using NUnit.Framework;
77

@@ -33,7 +33,7 @@ public void TestScopedAnalyzers()
3333

3434
tx = s.BeginTransaction();
3535

36-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
36+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
3737
Lucene.Net.Search.Query luceneQuery = parser.Parse("entity:alarm");
3838
IFullTextQuery query = s.CreateFullTextQuery(luceneQuery, typeof(MyEntity));
3939
Assert.AreEqual(1, query.ResultSize, "Entity query");

src/NHibernate.Search.Tests/Async/Analyzer/AnalyzerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Collections;
1212
using System.Collections.Generic;
1313
using Lucene.Net.Analysis.Standard;
14-
using Lucene.Net.QueryParsers;
14+
using Lucene.Net.QueryParsers.Classic;
1515
using Lucene.Net.Util;
1616
using NUnit.Framework;
1717

@@ -44,7 +44,7 @@ public async Task TestScopedAnalyzersAsync()
4444

4545
tx = s.BeginTransaction();
4646

47-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
47+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
4848
Lucene.Net.Search.Query luceneQuery = parser.Parse("entity:alarm");
4949
IFullTextQuery query = s.CreateFullTextQuery(luceneQuery, typeof(MyEntity));
5050
Assert.AreEqual(1, query.ResultSize, "Entity query");

src/NHibernate.Search.Tests/Async/Bridge/BridgeTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
using System;
1212
using System.Collections;
1313
using System.Collections.Generic;
14-
using Lucene.Net.Analysis;
14+
using Lucene.Net.Analysis.Core;
1515
using Lucene.Net.Analysis.Standard;
16-
using Lucene.Net.QueryParsers;
16+
using Lucene.Net.QueryParsers.Classic;
17+
using Lucene.Net.Util;
1718
using NHibernate.Cfg;
1819
using NUnit.Framework;
19-
using Version = Lucene.Net.Util.Version;
2020

2121
namespace NHibernate.Search.Tests.Bridge
2222
{
@@ -49,7 +49,7 @@ public async Task CustomBridgesAsync()
4949

5050
tx = s.BeginTransaction();
5151
IFullTextSession session = Search.CreateFullTextSession(s);
52-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new SimpleAnalyzer());
52+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
5353

5454
Lucene.Net.Search.Query query = parser.Parse("CustomFieldBridge:This AND CustomStringBridge:This");
5555
IList result = await (session.CreateFullTextQuery(query).ListAsync());
@@ -86,7 +86,7 @@ public async Task DateTimeBridgeAsync()
8686

8787
tx = s.BeginTransaction();
8888
IFullTextSession session = Search.CreateFullTextSession(s);
89-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
89+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
9090

9191
Lucene.Net.Search.Query query = parser.Parse("DateTime:[19900101 TO 20060101]"
9292
+ " AND DateTimeDay:[20001214 TO 2000121501]"
@@ -129,7 +129,7 @@ public async Task DefaultAndNullBridgesAsync()
129129

130130
tx = s.BeginTransaction();
131131
IFullTextSession session = Search.CreateFullTextSession(s);
132-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
132+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
133133

134134
Lucene.Net.Search.Query query = parser.Parse("Double2:[2 TO 2.1] AND Float2:[2 TO 2.1] " +
135135
"AND Int2:[2 TO 2.1] AND Long2:[2 TO 2.1] AND Type:\"Dog\" AND Storm:false");

src/NHibernate.Search.Tests/Async/Bridge/ClassBridgeTest.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace NHibernate.Search.Tests.Bridge
1515
{
1616
using System.Collections;
1717

18-
using Lucene.Net.Analysis;
18+
using Lucene.Net.Analysis.Core;
1919
using Lucene.Net.Documents;
20-
using Lucene.Net.QueryParsers;
20+
using Lucene.Net.QueryParsers.Classic;
2121
using Lucene.Net.Search;
2222

2323
using NHibernate.Cfg;
@@ -63,7 +63,7 @@ public async Task ClassBridgeAsync()
6363
// the branch field and the network field of the Department
6464
// class. This is in the Lucene document but not in the
6565
// Department entity itself.
66-
QueryParser parser = new QueryParser(Version.LUCENE_30, "branchnetwork", new SimpleAnalyzer());
66+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "branchnetwork", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
6767

6868
Query query = parser.Parse("branchnetwork:layton 2B");
6969
IFullTextQuery hibQuery = session.CreateFullTextQuery(query, typeof(Department));
@@ -90,7 +90,7 @@ public async Task ClassBridgeAsync()
9090
Assert.IsTrue(result.Count == 0, "problem with field cross-ups");
9191

9292
// Non-ClassBridge field.
93-
parser = new QueryParser(Version.LUCENE_30, "BranchHead", new SimpleAnalyzer());
93+
parser = new QueryParser(LuceneVersion.LUCENE_48, "BranchHead", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
9494
query = parser.Parse("BranchHead:Kent Lewin");
9595
hibQuery = session.CreateFullTextQuery(query, typeof(Department));
9696
result = await (hibQuery.ListAsync());
@@ -131,7 +131,7 @@ public async Task ClassBridgesAsync()
131131
// Departments entity after being massaged by passing it
132132
// through the EquipmentType class. This field is in
133133
// the Lucene document but not in the Department entity itself.
134-
QueryParser parser = new QueryParser(Version.LUCENE_30, "equipment", new SimpleAnalyzer());
134+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "equipment", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
135135

136136
// Check the second ClassBridge annotation
137137
Query query = parser.Parse("equiptype:Cisco");
@@ -152,7 +152,7 @@ public async Task ClassBridgesAsync()
152152
Assert.IsTrue(result.Count == 0, "problem with field cross-ups");
153153

154154
// Non-ClassBridge field.
155-
parser = new QueryParser(Version.LUCENE_30, "BranchHead", new SimpleAnalyzer());
155+
parser = new QueryParser(LuceneVersion.LUCENE_48, "BranchHead", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
156156
query = parser.Parse("BranchHead:Kent Lewin");
157157
hibQuery = session.CreateFullTextQuery(query, typeof(Departments));
158158
result = await (hibQuery.ListAsync());
@@ -161,7 +161,7 @@ public async Task ClassBridgesAsync()
161161
Assert.AreEqual("Kent Lewin", ((Departments)result[0]).BranchHead, "incorrect entity returned");
162162

163163
// Check other ClassBridge annotation.
164-
parser = new QueryParser(Version.LUCENE_30, "branchnetwork", new SimpleAnalyzer());
164+
parser = new QueryParser(LuceneVersion.LUCENE_48, "branchnetwork", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
165165
query = parser.Parse("branchnetwork:st. george 1D");
166166
hibQuery = session.CreateFullTextQuery(query, typeof(Departments));
167167
result = await (hibQuery.ListAsync());
@@ -203,7 +203,7 @@ public async Task ClassBridgesWithProjectionAsync()
203203
// Departments entity after being massaged by passing it
204204
// through the EquipmentType class. This field is in
205205
// the Lucene document but not in the Department entity itself.
206-
QueryParser parser = new QueryParser(Version.LUCENE_30, "equipment", new SimpleAnalyzer());
206+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "equipment", new SimpleAnalyzer(LuceneVersion.LUCENE_48));
207207

208208
// Check the second ClassBridge annotation
209209
Query query = parser.Parse("equiptype:Cisco");
@@ -221,14 +221,14 @@ public async Task ClassBridgesWithProjectionAsync()
221221
// Note: This assertion fails when run with other tests because the id is assigned by the database, and previous tests have already used this value
222222
//Assert.AreEqual(1, ((Departments)projection[0]).Id, "id incorrect");
223223
Assert.IsTrue(projection[1] is Document, "DOCUMENT incorrect");
224-
Assert.AreEqual(8, ((Document)projection[1]).GetFields().Count, "DOCUMENT size incorrect");
224+
Assert.AreEqual(8, ((Document)projection[1]).Fields.Count, "DOCUMENT size incorrect");
225225
Assert.IsNotNull(((Document)projection[1]).GetField("equiptype"), "equiptype is null");
226226
Assert.AreEqual(
227-
"Cisco", ((Document)projection[1]).GetField("equiptype").StringValue, "equiptype incorrect");
227+
"Cisco", ((Document)projection[1]).GetField("equiptype").GetStringValue(), "equiptype incorrect");
228228
Assert.IsNotNull(((Document)projection[1]).GetField("branchnetwork"), "branchnetwork is null");
229229
Assert.AreEqual(
230230
"Salt Lake City 1A",
231-
((Document)projection[1]).GetField("branchnetwork").StringValue,
231+
((Document)projection[1]).GetField("branchnetwork").GetStringValue(),
232232
"branchnetwork incorrect");
233233

234234
projections.MoveNext();
@@ -238,14 +238,14 @@ public async Task ClassBridgesWithProjectionAsync()
238238
// NB This assertion causes the test to break when run with other tests - some leakage?
239239
//Assert.AreEqual(4, ((Departments)projection[0]).Id, "id incorrect");
240240
Assert.IsTrue(projection[1] is Document, "DOCUMENT incorrect");
241-
Assert.AreEqual(8, ((Document)projection[1]).GetFields().Count, "DOCUMENT size incorrect");
241+
Assert.AreEqual(8, ((Document)projection[1]).Fields.Count, "DOCUMENT size incorrect");
242242
Assert.IsNotNull(((Document)projection[1]).GetField("equiptype"), "equiptype is null");
243243
Assert.AreEqual(
244-
"Cisco", ((Document)projection[1]).GetField("equiptype").StringValue, "equiptype incorrect");
244+
"Cisco", ((Document)projection[1]).GetField("equiptype").GetStringValue(), "equiptype incorrect");
245245
Assert.IsNotNull(((Document)projection[1]).GetField("branchnetwork"), "branchnetwork is null");
246246
Assert.AreEqual(
247247
"St. George 1D",
248-
((Document)projection[1]).GetField("branchnetwork").StringValue,
248+
((Document)projection[1]).GetField("branchnetwork").GetStringValue(),
249249
"branchnetwork incorrect");
250250

251251
Assert.AreEqual(false, projections.MoveNext(), "incorrect result count returned");

src/NHibernate.Search.Tests/Async/DirectoryProvider/FSSlaveAndMasterDPTest.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
using System.Collections.Generic;
1414
using System.IO;
1515
using System.Threading;
16-
using Lucene.Net.Analysis;
17-
using Lucene.Net.QueryParsers;
16+
using Lucene.Net.Analysis.Core;
17+
using Lucene.Net.QueryParsers.Classic;
1818
using NHibernate.Cfg;
1919
using NHibernate.Search.Store;
2020
using NUnit.Framework;
@@ -44,7 +44,7 @@ public async Task ProperCopyAsync()
4444
// Assert that the slave index is empty
4545
IFullTextSession fullTextSession = Search.CreateFullTextSession(GetSlaveSession());
4646
ITransaction tx = fullTextSession.BeginTransaction();
47-
QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "id", new StopAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
47+
QueryParser parser = new QueryParser(Lucene.Net.Util.LuceneVersion.LUCENE_48, "id", new StopAnalyzer(Lucene.Net.Util.LuceneVersion.LUCENE_48));
4848
IList result = await (fullTextSession.CreateFullTextQuery(parser.Parse("Location:texas")).ListAsync());
4949
Assert.AreEqual(0, result.Count, "No copy yet, fresh index expected");
5050
await (tx.CommitAsync());
@@ -131,6 +131,11 @@ public override void FixtureSetUp()
131131
[TearDown]
132132
public void TearDown()
133133
{
134+
foreach (var factory in SessionFactories)
135+
{
136+
factory.Close();
137+
}
138+
134139
ZapLuceneStore();
135140
}
136141

src/NHibernate.Search.Tests/Async/Embedded/EmbeddedTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Collections;
1212
using System.Collections.Generic;
1313
using Lucene.Net.Analysis.Standard;
14-
using Lucene.Net.QueryParsers;
14+
using Lucene.Net.QueryParsers.Classic;
1515
using Lucene.Net.Util;
1616
using NUnit.Framework;
1717

@@ -81,7 +81,7 @@ public async Task EmbeddedIndexingAsync()
8181
await (tx.CommitAsync());
8282

8383
IFullTextSession session = Search.CreateFullTextSession(s);
84-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
84+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
8585

8686
Lucene.Net.Search.Query query = parser.Parse("address.street:place");
8787
IList result = await (session.CreateFullTextQuery(query).ListAsync());
@@ -161,7 +161,7 @@ public async Task ContainedInAsync()
161161
s.Clear();
162162

163163
IFullTextSession session = Search.CreateFullTextSession(s);
164-
QueryParser parser = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
164+
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
165165

166166
Lucene.Net.Search.Query query = parser.Parse("address.street:peachtree");
167167
IList result = await (session.CreateFullTextQuery(query).ListAsync());

src/NHibernate.Search.Tests/Async/Embedded/IndexedEmbeddedAndCollections.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace NHibernate.Search.Tests.Embedded
1616
using System.Collections;
1717
using Lucene.Net.Analysis.Standard;
1818
using Lucene.Net.Index;
19-
using Lucene.Net.QueryParsers;
19+
using Lucene.Net.QueryParsers.Classic;
2020
using Lucene.Net.Search;
2121
using NUnit.Framework;
2222
using System.Threading.Tasks;
@@ -115,7 +115,7 @@ public async Task CanLookupEntityByValueOfEmbeddedSetValuesAsync()
115115
{
116116
IFullTextSession session = Search.CreateFullTextSession(s);
117117

118-
QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_30, new string[] { "name", "authors.name" }, new StandardAnalyzer(Version.LUCENE_30));
118+
QueryParser parser = new MultiFieldQueryParser(LuceneVersion.LUCENE_48, new string[] { "name", "authors.name" }, new StandardAnalyzer(LuceneVersion.LUCENE_48));
119119

120120
Lucene.Net.Search.Query query = parser.Parse("Hugo");
121121
IList result = await (session.CreateFullTextQuery(query).ListAsync());
@@ -149,7 +149,7 @@ public async Task CanLookupEntityByUpdatedValueInSetAsync()
149149
tx = s.BeginTransaction();
150150

151151
IFullTextSession session = Search.CreateFullTextSession(s);
152-
QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_30, new string[] { "name", "authors.name" }, new StandardAnalyzer(Version.LUCENE_30));
152+
QueryParser parser = new MultiFieldQueryParser(LuceneVersion.LUCENE_48, new string[] { "name", "authors.name" }, new StandardAnalyzer(LuceneVersion.LUCENE_48));
153153
Query query = parser.Parse("Proust");
154154
IList result = await (session.CreateFullTextQuery(query, typeof(Product)).ListAsync());
155155

src/NHibernate.Search.Tests/Async/FieldAccess/FieldAccessTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Collections;
1212
using System.Collections.Generic;
1313
using Lucene.Net.Analysis.Standard;
14-
using Lucene.Net.QueryParsers;
14+
using Lucene.Net.QueryParsers.Classic;
1515
using Lucene.Net.Util;
1616
using NUnit.Framework;
1717

@@ -44,7 +44,7 @@ public async Task FieldBoostAsync()
4444

4545
IFullTextSession session = Search.CreateFullTextSession(s);
4646
tx = session.BeginTransaction();
47-
QueryParser p = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
47+
QueryParser p = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
4848
IList result = await (session.CreateFullTextQuery(p.Parse("title:Action OR Abstract:Action")).ListAsync());
4949
Assert.AreEqual(2, result.Count, "Query by field");
5050
Assert.AreEqual("Hibernate in Action", ((Document)result[0]).Title, "@Boost fails");
@@ -68,7 +68,7 @@ public async Task FieldsAsync()
6868

6969
IFullTextSession session = Search.CreateFullTextSession(s);
7070
tx = session.BeginTransaction();
71-
QueryParser p = new QueryParser(Version.LUCENE_30, "id", new StandardAnalyzer(Version.LUCENE_30));
71+
QueryParser p = new QueryParser(LuceneVersion.LUCENE_48, "id", new StandardAnalyzer(LuceneVersion.LUCENE_48));
7272
IList result = await (session.CreateFullTextQuery(p.Parse("Abstract:Hibernate")).ListAsync());
7373
Assert.AreEqual(1, result.Count, "Query by field");
7474
await (s.DeleteAsync(result[0]));

src/NHibernate.Search.Tests/Async/FileHelperTestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public async Task SynchronizeAsync()
7575
os.Close();
7676
FileInfo test = new FileInfo(Path.Combine(src.FullName, "c"));
7777
FileInfo destTest = new FileInfo(Path.Combine(dest.FullName, "c"));
78-
Assert.AreNotSame(test.LastWriteTime, destTest.LastWriteTime);
78+
Assert.AreNotEqual(test.LastWriteTime, destTest.LastWriteTime);
7979
FileHelper.Synchronize(src, dest, true);
8080
destTest.Refresh();
8181
Assert.AreEqual(test.LastWriteTime, destTest.LastWriteTime);

0 commit comments

Comments
 (0)