diff --git a/.gitignore b/.gitignore index 1bc915c..7e61028 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.suo *.user *.sln.docstates +.vs # Build results @@ -96,8 +97,7 @@ publish/ *.Publish.xml # NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ +packages/ # Windows Azure Build Output csx diff --git a/MultiFacetLuceneNet.Tests/DocumentExtensions.cs b/MultiFacetLucene.Tests/DocumentExtensions.cs similarity index 92% rename from MultiFacetLuceneNet.Tests/DocumentExtensions.cs rename to MultiFacetLucene.Tests/DocumentExtensions.cs index 3c82ccf..1d195fc 100644 --- a/MultiFacetLuceneNet.Tests/DocumentExtensions.cs +++ b/MultiFacetLucene.Tests/DocumentExtensions.cs @@ -1,7 +1,7 @@ using System; using Lucene.Net.Documents; -namespace MultiFacetLuceneNet.Tests +namespace MultiFacetLucene.Tests { public static class DocumentExtensions { diff --git a/MultiFacetLuceneNet.Tests/FacetSearcherTest.cs b/MultiFacetLucene.Tests/FacetSearcherTest.cs similarity index 92% rename from MultiFacetLuceneNet.Tests/FacetSearcherTest.cs rename to MultiFacetLucene.Tests/FacetSearcherTest.cs index 4ac46fe..e475284 100644 --- a/MultiFacetLuceneNet.Tests/FacetSearcherTest.cs +++ b/MultiFacetLucene.Tests/FacetSearcherTest.cs @@ -1,31 +1,29 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using Lucene.Net.Analysis; -using Lucene.Net.Analysis.Standard; using Lucene.Net.Documents; using Lucene.Net.Index; -using Lucene.Net.QueryParsers; using Lucene.Net.Search; using Lucene.Net.Store; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using MultiFacetLucene; using Lucene.Net.Util; +using NUnit.Framework; +using Lucene.Net.Analysis.Standard; +using Lucene.Net.Analysis.Core; +using Lucene.Net.QueryParsers.Classic; -namespace MultiFacetLuceneNet.Tests +namespace MultiFacetLucene.Tests { - [TestClass] + [TestFixture] public class FacetSearcherTest { private FacetSearcher _target; - [TestInitialize] + [SetUp] public void TestInitialize() { _target = new FacetSearcher(SetupIndex()); } - [TestMethod] + [Test] public void MatchAllQueryShouldReturnCorrectFacetsAndDocuments() { var facetFieldInfos = new List @@ -55,7 +53,7 @@ public void MatchAllQueryShouldReturnCorrectFacetsAndDocuments() Assert.AreEqual(2, typeFacets.Single(x => x.Value == "fruit").Count); } - [TestMethod] + [Test] public void DrilldownSingleFacetSingleValueShouldReturnCorrectFacetsAndDocuments() { var facetFieldInfos = new List @@ -83,7 +81,7 @@ public void DrilldownSingleFacetSingleValueShouldReturnCorrectFacetsAndDocuments Assert.AreEqual(2, typeFacets.Single(x => x.Value == "fruit").Count); } - [TestMethod] + [Test] public void DrilldownSingleFacetMultiValueShouldReturnCorrectFacetsAndDocuments() { var facetFieldInfos = new List @@ -112,7 +110,7 @@ public void DrilldownSingleFacetMultiValueShouldReturnCorrectFacetsAndDocuments( Assert.AreEqual(1, typeFacets.Single(x => x.Value == "drink").Count); } - [TestMethod] + [Test] public void MaxFacetRestrictionShouldReturnCorrectFacetsAndDocuments() { var facetFieldInfos = new List @@ -129,7 +127,7 @@ public void MaxFacetRestrictionShouldReturnCorrectFacetsAndDocuments() Assert.AreEqual(3, colorFacets.Single(x => x.Value == "yellow").Count); } - [TestMethod] + [Test] public void MaxFacetRestrictionShouldStillReturnSelectedFacet() { var facetFieldInfos = new List @@ -146,7 +144,7 @@ public void MaxFacetRestrictionShouldStillReturnSelectedFacet() Assert.AreEqual(1, colorFacets.Single(x => x.Value == "none").Count); } - + [Test] public void MaxFacetRestrictionShouldReturnSelectedFacetAsWell() { var facetFieldInfos = new List @@ -174,10 +172,10 @@ public void MaxFacetRestrictionShouldReturnSelectedFacetAsWell() } - [TestMethod] + [Test] public void MatchSpecifiedQueryShouldReturnCorrectFacetsAndDocuments() { - var query = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, string.Empty, new KeywordAnalyzer()).Parse("keywords:apa"); + var query = new QueryParser(LuceneVersion.LUCENE_48, string.Empty, new KeywordAnalyzer()).Parse("keywords:apa"); var facetFieldInfos = new List { @@ -190,8 +188,8 @@ public void MatchSpecifiedQueryShouldReturnCorrectFacetsAndDocuments() var typeFacets = actual.Facets.Where(x => x.FacetFieldName == "type").ToList(); Assert.AreEqual(2, actual.Hits.TotalHits); - Assert.AreEqual("Banana", _target.Doc(actual.Hits.ScoreDocs[0].Doc).GetField("title").StringValue); - Assert.AreEqual("Water", _target.Doc(actual.Hits.ScoreDocs[1].Doc).GetField("title").StringValue); + Assert.AreEqual("Banana", _target.Doc(actual.Hits.ScoreDocs[0].Doc).GetField("title").GetStringValue()); + Assert.AreEqual("Water", _target.Doc(actual.Hits.ScoreDocs[1].Doc).GetField("title").GetStringValue()); Assert.AreEqual(2, colorFacets.Count); Assert.AreEqual(3, typeFacets.Count); @@ -204,7 +202,7 @@ public void MatchSpecifiedQueryShouldReturnCorrectFacetsAndDocuments() Assert.AreEqual(1, typeFacets.Single(x => x.Value == "fruit").Count); } - [TestMethod] + [Test] public void DrilldownMultiFacetsShouldReturnCorrectFacetsAndDocuments() { var facetFieldInfos = new List @@ -230,7 +228,7 @@ public void DrilldownMultiFacetsShouldReturnCorrectFacetsAndDocuments() Assert.AreEqual(3, typeFacets.Single(x => x.Value == "food").Count);//only yellow } - [TestMethod] + [Test] public void IncludeEmptyFacetsShouldIncludeEmptyFacets() { var facetFieldInfos = new List @@ -246,7 +244,7 @@ public void IncludeEmptyFacetsShouldIncludeEmptyFacets() Assert.AreEqual(1, colorFacets.Count(x => x.Count == 0)); } - [TestMethod] + [Test] public void DoNotIncludeEmptyFacetsShouldNotIncludeEmptyFacets() { var facetFieldInfos = new List @@ -262,16 +260,16 @@ public void DoNotIncludeEmptyFacetsShouldNotIncludeEmptyFacets() Assert.AreEqual(0, colorFacets.Count(x => x.Count == 0)); } - [TestMethod] + [Test] public void RangeFacetsShouldReturnCorrectFacetsAndDocument() { var facetFieldInfos = new List { - new FacetFieldInfo{ FieldName = "price", IsRange = true, Ranges = new List + new FacetFieldInfo{ FieldName = "price", IsRange = true, Ranges = new List { - new Range { Id = "A", From = "0", To = "10"}, - new Range { Id = "B", From = "0", To = "20"}, - new Range { Id = "C", From = "0", To = "30"} + new MultiFacetLucene.Range { Id = "A", From = "0", To = "10"}, + new MultiFacetLucene.Range { Id = "B", From = "0", To = "20"}, + new MultiFacetLucene.Range { Id = "C", From = "0", To = "30"} }, Selections = new List { @@ -309,8 +307,7 @@ public void RangeFacetsShouldReturnCorrectFacetsAndDocument() protected static IndexReader SetupIndex() { var directory = new RAMDirectory(); - var writer = new IndexWriter(directory, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), true, - IndexWriter.MaxFieldLength.LIMITED); + var writer = new IndexWriter(directory, new IndexWriterConfig(LuceneVersion.LUCENE_48, new StandardAnalyzer(LuceneVersion.LUCENE_48))); writer.AddDocument(new Document() .AddField("title", "Banana", Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("color", "yellow", Field.Store.YES, Field.Index.NOT_ANALYZED) @@ -341,10 +338,9 @@ protected static IndexReader SetupIndex() .AddField("type", "drink", Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("keywords", "apa hello cars", Field.Store.YES, Field.Index.ANALYZED) .AddField("price", "0", Field.Store.YES, Field.Index.NOT_ANALYZED)); - writer.Flush(true, true, true); - writer.Optimize(); + writer.Flush(true, true); writer.Commit(); - return IndexReader.Open(directory, true); + return DirectoryReader.Open(directory); } } diff --git a/MultiFacetLucene.Tests/MultiFacetLucene.Tests.csproj b/MultiFacetLucene.Tests/MultiFacetLucene.Tests.csproj new file mode 100644 index 0000000..2fffdbf --- /dev/null +++ b/MultiFacetLucene.Tests/MultiFacetLucene.Tests.csproj @@ -0,0 +1,21 @@ + + + + net5.0 + enable + + + + + + + + + + + + + + + + diff --git a/MultiFacetLuceneNet.Tests/PerformanceTest.cs b/MultiFacetLucene.Tests/PerformanceTest.cs similarity index 82% rename from MultiFacetLuceneNet.Tests/PerformanceTest.cs rename to MultiFacetLucene.Tests/PerformanceTest.cs index 75878f3..54d5fbc 100644 --- a/MultiFacetLuceneNet.Tests/PerformanceTest.cs +++ b/MultiFacetLucene.Tests/PerformanceTest.cs @@ -1,20 +1,17 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Lucene.Net.Analysis.Standard; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Store; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using MultiFacetLucene; -using Version = Lucene.Net.Util.Version; +using NUnit.Framework; -namespace MultiFacetLuceneNet.Tests +namespace MultiFacetLucene.Tests { - [Ignore] - [TestClass] + //[Ignore] + [TestFixture] public class PerformanceTest { private static FacetSearcher _target; @@ -31,14 +28,14 @@ public void Warmup() _target.SearchWithFacets(new TermQuery(new Term("Price", "5")), 100, facetFieldInfos); } - [TestInitialize] + [SetUp] public void TestInitialize() { _target = new FacetSearcher(SetupIndex()); Warmup(); } - [TestMethod] + [Test] public void MatchAllDocsAndCalculateFacetsPerformanceTest() { Warmup(); @@ -47,8 +44,8 @@ public void MatchAllDocsAndCalculateFacetsPerformanceTest() var facetFieldInfos = new List { - new FacetFieldInfo{ FieldName = "color"}, - new FacetFieldInfo{ FieldName = "type"}, + new() { FieldName = "color"}, + new() { FieldName = "type"}, }; var actual = _target.SearchWithFacets(new MatchAllDocsQuery(), 100, facetFieldInfos); @@ -58,7 +55,7 @@ public void MatchAllDocsAndCalculateFacetsPerformanceTest() Trace.WriteLine("Took " + vs + " ms"); } - [TestMethod] + [Test] public void MatchAllDocsPerformanceTest() { var stopwatch = new Stopwatch(); @@ -76,8 +73,7 @@ public void MatchAllDocsPerformanceTest() protected static IndexReader SetupIndex() { var directory = new RAMDirectory(); - var writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_29), true, - IndexWriter.MaxFieldLength.LIMITED); + var writer = new IndexWriter(directory, new IndexWriterConfig(Lucene.Net.Util.LuceneVersion.LUCENE_48, new StandardAnalyzer(Lucene.Net.Util.LuceneVersion.LUCENE_48))); for (var i = 0; i < 50000; i++) writer.AddDocument(new Document() .AddField("title", Guid.NewGuid().ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED) @@ -85,10 +81,9 @@ protected static IndexReader SetupIndex() .AddField("type", GenerateFood(), Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("type", GenerateFruit(), Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("price", "10", Field.Store.YES, Field.Index.NOT_ANALYZED)); - writer.Flush(true, true, true); - writer.Optimize(); + writer.Flush(true, true); writer.Commit(); - return IndexReader.Open(directory, true); + return DirectoryReader.Open(directory); } diff --git a/MultiFacetLuceneNet.sln b/MultiFacetLucene.sln similarity index 57% rename from MultiFacetLuceneNet.sln rename to MultiFacetLucene.sln index f177bfb..9a5982d 100644 --- a/MultiFacetLuceneNet.sln +++ b/MultiFacetLucene.sln @@ -1,12 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiFacetLucene", "MultiFacetLucene\MultiFacetLucene.csproj", "{086093FD-D444-48BE-B897-7FAC14133C23}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiFacetLuceneNet.Tests", "MultiFacetLuceneNet.Tests\MultiFacetLuceneNet.Tests.csproj", "{F29DAEA8-7267-4230-B2F6-70062D2E890B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerformanceTest", "PerformanceTest\PerformanceTest.csproj", "{0065E899-596D-4B16-9CF5-E917DD957DAB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B13A814A-4ECA-4A5F-A340-FF4C6DCE5145}" @@ -16,26 +12,33 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B13A81 .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiFacetLucene", "MultiFacetLucene\MultiFacetLucene.csproj", "{87059512-913A-4B3D-BD07-C13419852B81}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiFacetLucene.Tests", "MultiFacetLucene.Tests\MultiFacetLucene.Tests.csproj", "{B2573CD0-8A9E-43EA-BFB3-6056FB41C2D2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {086093FD-D444-48BE-B897-7FAC14133C23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {086093FD-D444-48BE-B897-7FAC14133C23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {086093FD-D444-48BE-B897-7FAC14133C23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {086093FD-D444-48BE-B897-7FAC14133C23}.Release|Any CPU.Build.0 = Release|Any CPU - {F29DAEA8-7267-4230-B2F6-70062D2E890B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F29DAEA8-7267-4230-B2F6-70062D2E890B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F29DAEA8-7267-4230-B2F6-70062D2E890B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F29DAEA8-7267-4230-B2F6-70062D2E890B}.Release|Any CPU.Build.0 = Release|Any CPU {0065E899-596D-4B16-9CF5-E917DD957DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0065E899-596D-4B16-9CF5-E917DD957DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU {0065E899-596D-4B16-9CF5-E917DD957DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU {0065E899-596D-4B16-9CF5-E917DD957DAB}.Release|Any CPU.Build.0 = Release|Any CPU + {87059512-913A-4B3D-BD07-C13419852B81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87059512-913A-4B3D-BD07-C13419852B81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87059512-913A-4B3D-BD07-C13419852B81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87059512-913A-4B3D-BD07-C13419852B81}.Release|Any CPU.Build.0 = Release|Any CPU + {B2573CD0-8A9E-43EA-BFB3-6056FB41C2D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2573CD0-8A9E-43EA-BFB3-6056FB41C2D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2573CD0-8A9E-43EA-BFB3-6056FB41C2D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2573CD0-8A9E-43EA-BFB3-6056FB41C2D2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D0C27F1D-550D-403C-9243-107D171EE003} + EndGlobalSection EndGlobal diff --git a/MultiFacetLucene/FacetBitSetCalculatorProvider.cs b/MultiFacetLucene/FacetBitSetCalculatorProvider.cs index 03eb244..d33100a 100644 --- a/MultiFacetLucene/FacetBitSetCalculatorProvider.cs +++ b/MultiFacetLucene/FacetBitSetCalculatorProvider.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MultiFacetLucene.Configuration; +using MultiFacetLucene.Configuration; namespace MultiFacetLucene { diff --git a/MultiFacetLucene/FacetSearcher.cs b/MultiFacetLucene/FacetSearcher.cs index 6cc202f..4b0bbd6 100644 --- a/MultiFacetLucene/FacetSearcher.cs +++ b/MultiFacetLucene/FacetSearcher.cs @@ -2,10 +2,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using Lucene.Net.Analysis; +using System.Threading.Tasks; using Lucene.Net.Index; +using Lucene.Net.Queries; using Lucene.Net.Search; -using Lucene.Net.Store; using Lucene.Net.Util; using MultiFacetLucene.Configuration; @@ -15,24 +15,30 @@ public class FacetSearcher : IndexSearcher { private readonly ConcurrentDictionary _facetBitSetDictionary = new ConcurrentDictionary(); - public FacetSearcher(Directory path, FacetSearcherConfiguration facetSearcherConfiguration = null) - : base(path) + public FacetSearcher(IndexReader reader, FacetSearcherConfiguration facetSearcherConfiguration = null) + : base(reader) { Initialize(facetSearcherConfiguration); } - public FacetSearcher(Directory path, bool readOnly, FacetSearcherConfiguration facetSearcherConfiguration = null) - : base(path, readOnly) + public FacetSearcher(IndexReader reader, TaskScheduler scheduler, FacetSearcherConfiguration facetSearcherConfiguration = null) + : base(reader, scheduler) { Initialize(facetSearcherConfiguration); } - public FacetSearcher(IndexReader r, FacetSearcherConfiguration facetSearcherConfiguration = null) - : base(r) + public FacetSearcher(IndexReaderContext context, FacetSearcherConfiguration facetSearcherConfiguration = null) + : base(context) { Initialize(facetSearcherConfiguration); } - + + public FacetSearcher(IndexReaderContext context, TaskScheduler scheduler, FacetSearcherConfiguration facetSearcherConfiguration = null) + : base(context, scheduler) + { + Initialize(facetSearcherConfiguration); + } + public FacetSearcherConfiguration FacetSearcherConfiguration { get; protected set; } private void Initialize(FacetSearcherConfiguration facetSearcherConfiguration) @@ -92,10 +98,24 @@ private IEnumerable FindMatchesInQuery(Query baseQueryWithoutFacetDr { var calculations = 0; var queryFilter = new CachingWrapperFilter(CombineQueryWithFilter(CreateFacetedQuery(baseQueryWithoutFacetDrilldown, allFacetFieldInfos, facetFieldInfoToCalculateFor.FieldName), filter)); - var bitsQueryWithoutFacetDrilldown = new OpenBitSetDISI(queryFilter.GetDocIdSet(IndexReader).Iterator(), IndexReader.MaxDoc); + + var bitsQueryWithoutFacetDrilldown = new OpenBitSetDISI(IndexReader.MaxDoc); + foreach (var leaf in IndexReader.Leaves) + { + var docSet = queryFilter.GetDocIdSet(leaf.AtomicReader.AtomicContext, leaf.AtomicReader.LiveDocs); + if (docSet == null) + { + continue; + } + var iterator = docSet.GetIterator(); + if (iterator == null) + { + continue; + } + bitsQueryWithoutFacetDrilldown.InPlaceOr(iterator); + } var baseQueryWithoutFacetDrilldownCopy = new OpenBitSetDISI(bitsQueryWithoutFacetDrilldown.Bits.Length); - baseQueryWithoutFacetDrilldownCopy.Bits = new long[bitsQueryWithoutFacetDrilldown.Bits.Length]; - + var docIdMappingArray = GetDocIdMappingArray(docIdMappingTable); var calculatedFacetCounts = new ResultCollection(facetFieldInfoToCalculateFor); @@ -109,9 +129,8 @@ private IEnumerable FindMatchesInQuery(Query baseQueryWithoutFacetDr break; } - bitsQueryWithoutFacetDrilldown.Bits.CopyTo(baseQueryWithoutFacetDrilldownCopy.Bits, 0); - baseQueryWithoutFacetDrilldownCopy.NumWords = bitsQueryWithoutFacetDrilldown.NumWords; - + baseQueryWithoutFacetDrilldownCopy.Union(bitsQueryWithoutFacetDrilldown); + var bitset = facetValueBitSet.Bitset ?? GetFacetBitSetCalculator(facetFieldInfoToCalculateFor).GetFacetBitSet(IndexReader, facetFieldInfoToCalculateFor, facetValueBitSet.Value); baseQueryWithoutFacetDrilldownCopy.And(bitset); @@ -119,7 +138,7 @@ private IEnumerable FindMatchesInQuery(Query baseQueryWithoutFacetDr { CascadeVariantValuesToParent(baseQueryWithoutFacetDrilldownCopy, docIdMappingArray); } - var count = baseQueryWithoutFacetDrilldownCopy.Cardinality(); + var count = baseQueryWithoutFacetDrilldownCopy.Cardinality; var match = new FacetMatch { @@ -155,8 +174,8 @@ private int[] GetDocIdMappingArray(Dictionary docIdMappingTable) private void CascadeVariantValuesToParent(OpenBitSetDISI bitset, int[] docIdMappingTable) { - var capacity = Math.Min(bitset.Capacity(), docIdMappingTable.Length); - if (bitset.IsEmpty()) + var capacity = Math.Min(bitset.Capacity, docIdMappingTable.Length); + if (bitset.IsEmpty) return; for (int i = 0; i < capacity; i++) { @@ -182,7 +201,7 @@ private Filter CombineQueryWithFilter(Query query, Filter filter) new QueryWrapperFilter(query), filter }, - ChainedFilter.Logic.AND + ChainedFilter.AND ); } @@ -201,14 +220,14 @@ protected Query CreateFacetedQuery(Query baseQueryWithoutFacetDrilldown, IList - ///*

- /// * Allows multiple {@link Filter}s to be chained. - /// * Logical operations such as NOT and XOR - /// * are applied between filters. One operation can be used - /// * for all filters, or a specific operation can be declared - /// * for each filter. - /// *

- /// *

- /// * Order in which filters are called depends on - /// * the position of the filter in the chain. It's probably - /// * more efficient to place the most restrictive filters - /// * /least computationally-intensive filters first. - /// *

- /// - public class ChainedFilter : Filter - { - public enum Logic - { - NONE = -1, - OR = 0, - AND = 1, - ANDNOT = 2, - XOR = 3 - }; - - ///Logical operation when none is declared. Defaults to OR - public const Logic DEFAULT = Logic.OR; - - /** The filter chain */ - private Filter[] chain = null; - - private Logic[] logicArray; - - private Logic logic = Logic.NONE; - - ///CtorThe chain of filters - public ChainedFilter(Filter[] chain) - { - this.chain = chain; - } - - ///ctor - ///The chain of filters - ///Logical operations to apply between filters - public ChainedFilter(Filter[] chain, Logic[] logicArray) - { - this.chain = chain; - this.logicArray = logicArray; - } - - ///ctor - ///The chain of filters - ///Logical operation to apply to ALL filters - public ChainedFilter(Filter[] chain, Logic logic) - { - this.chain = chain; - this.logic = logic; - } - - /// - public override DocIdSet GetDocIdSet(IndexReader reader) - { - int[] index = new int[1]; // use array as reference to modifiable int; - index[0] = 0; // an object attribute would not be thread safe. - if (logic != Logic.NONE) - return GetDocIdSet(reader, logic, index); - else if (logicArray != null) - return GetDocIdSet(reader, logicArray, index); - else - return GetDocIdSet(reader, DEFAULT, index); - } - - private DocIdSetIterator GetDISI(Filter filter, IndexReader reader) - { - DocIdSet docIdSet = filter.GetDocIdSet(reader); - if (docIdSet == null) - { - return DocIdSet.EMPTY_DOCIDSET.Iterator(); - } - else - { - DocIdSetIterator iter = docIdSet.Iterator(); - if (iter == null) - { - return DocIdSet.EMPTY_DOCIDSET.Iterator(); - } - else - { - return iter; - } - } - } - - private OpenBitSetDISI InitialResult(IndexReader reader, Logic logic, int[] index) - { - OpenBitSetDISI result; - /** - * First AND operation takes place against a completely false - * bitset and will always return zero results. - */ - if (logic == Logic.AND) - { - result = new OpenBitSetDISI(GetDISI(chain[index[0]], reader), reader.MaxDoc); - ++index[0]; - } - else if (logic == Logic.ANDNOT) - { - result = new OpenBitSetDISI(GetDISI(chain[index[0]], reader), reader.MaxDoc); - result.Flip(0, reader.MaxDoc); // NOTE: may set bits for deleted docs. - ++index[0]; - } - else - { - result = new OpenBitSetDISI(reader.MaxDoc); - } - return result; - } - - - /// - /// * Provide a SortedVIntList when it is definitely - /// * smaller than an OpenBitSet - /// * @deprecated Either use CachingWrapperFilter, or - /// * switch to a different DocIdSet implementation yourself. - /// * This method will be removed in Lucene 4.0 - /// - protected DocIdSet FinalResult(OpenBitSetDISI result, int maxDocs) - { - return result; - } - - - /** - * Delegates to each filter in the chain. - * @param reader IndexReader - * @param logic Logical operation - * @return DocIdSet - */ - private DocIdSet GetDocIdSet(IndexReader reader, Logic logic, int[] index) - { - OpenBitSetDISI result = InitialResult(reader, logic, index); - for (; index[0] < chain.Length; index[0]++) - { - DoChain(result, logic, chain[index[0]].GetDocIdSet(reader)); - } - return FinalResult(result, reader.MaxDoc); - } - - /** - * Delegates to each filter in the chain. - * @param reader IndexReader - * @param logic Logical operation - * @return DocIdSet - */ - private DocIdSet GetDocIdSet(IndexReader reader, Logic[] logic, int[] index) - { - if (logic.Length != chain.Length) - throw new ArgumentException("Invalid number of elements in logic array"); - - OpenBitSetDISI result = InitialResult(reader, logic[0], index); - for (; index[0] < chain.Length; index[0]++) - { - DoChain(result, logic[index[0]], chain[index[0]].GetDocIdSet(reader)); - } - return FinalResult(result, reader.MaxDoc); - } - - public override String ToString() - { - StringBuilder sb = new StringBuilder(); - sb.Append("ChainedFilter: ["); - for (int i = 0; i < chain.Length; i++) - { - sb.Append(chain[i]); - sb.Append(' '); - } - sb.Append(']'); - return sb.ToString(); - } - - private void DoChain(OpenBitSetDISI result, Logic logic, DocIdSet dis) - { - - if (dis is OpenBitSet) - { - // optimized case for OpenBitSets - switch (logic) - { - case Logic.OR: - result.Or((OpenBitSet)dis); - break; - case Logic.AND: - result.And((OpenBitSet)dis); - break; - case Logic.ANDNOT: - result.AndNot((OpenBitSet)dis); - break; - case Logic.XOR: - result.Xor((OpenBitSet)dis); - break; - default: - DoChain(result, DEFAULT, dis); - break; - } - } - else - { - DocIdSetIterator disi; - if (dis == null) - { - disi = DocIdSet.EMPTY_DOCIDSET.Iterator(); - } - else - { - disi = dis.Iterator(); - if (disi == null) - { - disi = DocIdSet.EMPTY_DOCIDSET.Iterator(); - } - } - - switch (logic) - { - case Logic.OR: - result.InPlaceOr(disi); - break; - case Logic.AND: - result.InPlaceAnd(disi); - break; - case Logic.ANDNOT: - result.InPlaceNot(disi); - break; - case Logic.XOR: - result.InPlaceXor(disi); - break; - default: - DoChain(result, DEFAULT, dis); - break; - } - } - } - - } - -} \ No newline at end of file diff --git a/MultiFacetLucene/MultiFacetLucene.csproj b/MultiFacetLucene/MultiFacetLucene.csproj index 8eeda7d..570d3a2 100644 --- a/MultiFacetLucene/MultiFacetLucene.csproj +++ b/MultiFacetLucene/MultiFacetLucene.csproj @@ -1,124 +1,12 @@ - - - + + - Debug - AnyCPU - {086093FD-D444-48BE-B897-7FAC14133C23} - Library - Properties - MultiFacetLucene - MultiFacetLucene - v4.5.1 - 512 - - - - - - - - - ..\..\GibeCommerce\GibeCommerce\ - true + net48 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - - ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Analyzers.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Core.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.FastVectorHighlighter.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Highlighter.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Memory.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Queries.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Regex.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SimpleFacetedSearch.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Snowball.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SpellChecker.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file + + diff --git a/MultiFacetLucene/Properties/AssemblyInfo.cs b/MultiFacetLucene/Properties/AssemblyInfo.cs deleted file mode 100644 index de7255d..0000000 --- a/MultiFacetLucene/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MultiFacetLucene")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Systementor AB")] -[assembly: AssemblyProduct("MultiFacetLucene")] -[assembly: AssemblyCopyright("Copyright © Stefan Holmberg 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f17322c5-71e1-446e-94c8-31f3cf50e8c4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyFileVersion("3.0.0.0")] diff --git a/MultiFacetLucene/RangeFacetBitSetCalculator.cs b/MultiFacetLucene/RangeFacetBitSetCalculator.cs index 43d5fc6..1151089 100644 --- a/MultiFacetLucene/RangeFacetBitSetCalculator.cs +++ b/MultiFacetLucene/RangeFacetBitSetCalculator.cs @@ -10,44 +10,49 @@ namespace MultiFacetLucene { - public class RangeFacetBitSetCalculator : IFacetBitSetCalculator - { - private FacetSearcherConfiguration _facetSearcherConfiguration; + public class RangeFacetBitSetCalculator : IFacetBitSetCalculator + { + private FacetSearcherConfiguration _facetSearcherConfiguration; - public RangeFacetBitSetCalculator(FacetSearcherConfiguration configuration) - { - _facetSearcherConfiguration = configuration; - } + public RangeFacetBitSetCalculator(FacetSearcherConfiguration configuration) + { + _facetSearcherConfiguration = configuration; + } - public IEnumerable GetFacetValueBitSets(IndexReader indexReader, FacetFieldInfo info) - { - foreach (var range in info.Ranges) - { - var bitset = CalculateOpenBitSetDisi(indexReader, info.FieldName, range.From, range.To); - var cnt = bitset.Cardinality(); - if (cnt >= _facetSearcherConfiguration.MinimumCountInTotalDatasetForFacet) - { - yield return - new FacetSearcher.FacetValues.FacetValueBitSet {Value = range.Id, Bitset = bitset, Count = cnt}; - } - else - { - bitset = null; - } - } - } + public IEnumerable GetFacetValueBitSets(IndexReader indexReader, FacetFieldInfo info) + { + foreach (var range in info.Ranges) + { + var bitset = CalculateOpenBitSetDisi(indexReader, info.FieldName, range.From, range.To); + var cnt = bitset.Cardinality; + if (cnt >= _facetSearcherConfiguration.MinimumCountInTotalDatasetForFacet) + { + yield return + new FacetSearcher.FacetValues.FacetValueBitSet { Value = range.Id, Bitset = bitset, Count = cnt }; + } + else + { + bitset = null; + } + } + } - public OpenBitSetDISI GetFacetBitSet(IndexReader indexReader, FacetFieldInfo info, string value) - { - var range = info.Ranges.FirstOrDefault(r => r.Id == value); - return CalculateOpenBitSetDisi(indexReader, info.FieldName, range.From, range.To); - } + public OpenBitSetDISI GetFacetBitSet(IndexReader indexReader, FacetFieldInfo info, string value) + { + var range = info.Ranges.FirstOrDefault(r => r.Id == value); + return CalculateOpenBitSetDisi(indexReader, info.FieldName, range.From, range.To); + } - protected OpenBitSetDISI CalculateOpenBitSetDisi(IndexReader indexReader, string facetAttributeFieldName, string from, string to) - { - var facetQuery = new TermRangeQuery(facetAttributeFieldName, from, to, true, true); - var facetQueryFilter = new QueryWrapperFilter(facetQuery); - return new OpenBitSetDISI(facetQueryFilter.GetDocIdSet(indexReader).Iterator(), indexReader.MaxDoc); - } - } + protected OpenBitSetDISI CalculateOpenBitSetDisi(IndexReader indexReader, string facetAttributeFieldName, string from, string to) + { + var facetQuery = new TermRangeQuery(facetAttributeFieldName, new BytesRef(from), new BytesRef(to), true, true); + var facetQueryFilter = new QueryWrapperFilter(facetQuery); + var disi = new OpenBitSetDISI(indexReader.MaxDoc); + foreach (var leaf in indexReader.Leaves) + { + disi.InPlaceOr(facetQueryFilter.GetDocIdSet(leaf.AtomicReader.AtomicContext, leaf.AtomicReader.LiveDocs).GetIterator()); + } + return disi; + } + } } diff --git a/MultiFacetLucene/TermFacetBitSetCalulcator.cs b/MultiFacetLucene/TermFacetBitSetCalulcator.cs index b560df3..cfcd18f 100644 --- a/MultiFacetLucene/TermFacetBitSetCalulcator.cs +++ b/MultiFacetLucene/TermFacetBitSetCalulcator.cs @@ -10,46 +10,59 @@ namespace MultiFacetLucene { - public class TermFacetBitSetCalulcator : IFacetBitSetCalculator - { - private readonly FacetSearcherConfiguration _facetSearcherConfiguration; - - public TermFacetBitSetCalulcator(FacetSearcherConfiguration configuration) - { - _facetSearcherConfiguration = configuration; - } - - public IEnumerable GetFacetValueBitSets(IndexReader indexReader, FacetFieldInfo info) - { - var termReader = indexReader.Terms(new Term(info.FieldName, String.Empty)); - do - { - if (termReader.Term.Field != info.FieldName) - yield break; - - var bitset = CalculateOpenBitSetDisi(indexReader, info.FieldName, termReader.Term.Text); - var cnt = bitset.Cardinality(); - if (cnt >= _facetSearcherConfiguration.MinimumCountInTotalDatasetForFacet) - yield return new FacetSearcher.FacetValues.FacetValueBitSet { Value = termReader.Term.Text, Bitset = bitset, Count = cnt }; - else - { - bitset = null; - } - } while (termReader.Next()); - termReader.Close(); - } - - public OpenBitSetDISI GetFacetBitSet(IndexReader indexReader, FacetFieldInfo info, string value) - { - return CalculateOpenBitSetDisi(indexReader, info.FieldName, value); - } - - - protected OpenBitSetDISI CalculateOpenBitSetDisi(IndexReader indexReader, string facetAttributeFieldName, string value) - { - var facetQuery = new TermQuery(new Term(facetAttributeFieldName, value)); - var facetQueryFilter = new QueryWrapperFilter(facetQuery); - return new OpenBitSetDISI(facetQueryFilter.GetDocIdSet(indexReader).Iterator(), indexReader.MaxDoc); - } - } + public class TermFacetBitSetCalulcator : IFacetBitSetCalculator + { + private readonly FacetSearcherConfiguration _facetSearcherConfiguration; + + public TermFacetBitSetCalulcator(FacetSearcherConfiguration configuration) + { + _facetSearcherConfiguration = configuration; + } + + public IEnumerable GetFacetValueBitSets(IndexReader indexReader, FacetFieldInfo info) + { + + foreach (var leaf in indexReader.Leaves) + { + + var termReader = leaf.AtomicReader.GetTerms(info.FieldName).GetEnumerator(); + do + { + var bitset = CalculateOpenBitSetDisi(indexReader, info.FieldName, termReader.Term.Utf8ToString()); + var cnt = bitset.Cardinality; + if (cnt >= _facetSearcherConfiguration.MinimumCountInTotalDatasetForFacet) + yield return new FacetSearcher.FacetValues.FacetValueBitSet + { Value = termReader.Term.Utf8ToString(), Bitset = bitset, Count = cnt }; + else + { + bitset = null; + } + } while (termReader.MoveNext()); + + } + } + + public OpenBitSetDISI GetFacetBitSet(IndexReader indexReader, FacetFieldInfo info, string value) + { + return CalculateOpenBitSetDisi(indexReader, info.FieldName, value); + } + + + protected OpenBitSetDISI CalculateOpenBitSetDisi(IndexReader indexReader, string facetAttributeFieldName, string value) + { + var facetQuery = new TermQuery(new Term(facetAttributeFieldName, value)); + var facetQueryFilter = new QueryWrapperFilter(facetQuery); + var disi = new OpenBitSetDISI(indexReader.MaxDoc); + foreach (var leaf in indexReader.Leaves) + { + var docSet = facetQueryFilter.GetDocIdSet(leaf.AtomicReader.AtomicContext, leaf.AtomicReader.LiveDocs); + var iterator = docSet.GetIterator(); + if (iterator != null) + { + disi.InPlaceOr(iterator); + } + } + return disi; + } + } } diff --git a/MultiFacetLucene/app.config b/MultiFacetLucene/app.config deleted file mode 100644 index fe339ee..0000000 --- a/MultiFacetLucene/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/MultiFacetLucene/packages.config b/MultiFacetLucene/packages.config deleted file mode 100644 index 591d3c9..0000000 --- a/MultiFacetLucene/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/MultiFacetLuceneNet.Tests/MultiFacetLuceneNet.Tests.csproj b/MultiFacetLuceneNet.Tests/MultiFacetLuceneNet.Tests.csproj deleted file mode 100644 index eb581ec..0000000 --- a/MultiFacetLuceneNet.Tests/MultiFacetLuceneNet.Tests.csproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - Debug - AnyCPU - {F29DAEA8-7267-4230-B2F6-70062D2E890B} - Library - Properties - MultiFacetLuceneNet.Tests - MultiFacetLuceneNet.Tests - v4.5.1 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - - - - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - - ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Analyzers.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Core.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.FastVectorHighlighter.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Highlighter.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Memory.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Queries.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Regex.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SimpleFacetedSearch.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Snowball.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SpellChecker.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - {086093FD-D444-48BE-B897-7FAC14133C23} - MultiFacetLucene - - - - - - - False - - - False - - - False - - - False - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/MultiFacetLuceneNet.Tests/Properties/AssemblyInfo.cs b/MultiFacetLuceneNet.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index f8108e5..0000000 --- a/MultiFacetLuceneNet.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MultiFacetLuceneNet.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("MultiFacetLuceneNet.Tests")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7e5ee159-a373-48a1-8062-1f2dc7ee9e8f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MultiFacetLuceneNet.Tests/app.config b/MultiFacetLuceneNet.Tests/app.config deleted file mode 100644 index 3ccce54..0000000 --- a/MultiFacetLuceneNet.Tests/app.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/MultiFacetLuceneNet.Tests/packages.config b/MultiFacetLuceneNet.Tests/packages.config deleted file mode 100644 index 591d3c9..0000000 --- a/MultiFacetLuceneNet.Tests/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/PerformanceTest/App.config b/PerformanceTest/App.config index 6fad07f..416fb85 100644 --- a/PerformanceTest/App.config +++ b/PerformanceTest/App.config @@ -1,14 +1,14 @@ - + - + - - + + - \ No newline at end of file + diff --git a/PerformanceTest/PerformanceTest.csproj b/PerformanceTest/PerformanceTest.csproj index 829b1fc..a15de8e 100644 --- a/PerformanceTest/PerformanceTest.csproj +++ b/PerformanceTest/PerformanceTest.csproj @@ -9,11 +9,12 @@ Properties PerformanceTest PerformanceTest - v4.5.1 + v4.8 512 true ..\ true + AnyCPU @@ -35,49 +36,171 @@ 4 - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + ..\packages\J2N.2.0.0-beta-0017\lib\net45\J2N.dll - - ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll + + ..\packages\Lucene.Net.4.8.0-beta00015\lib\net45\Lucene.Net.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Analyzers.dll + + ..\packages\Lucene.Net.Analysis.Common.4.8.0-beta00015\lib\net45\Lucene.Net.Analysis.Common.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Core.dll + + ..\packages\Lucene.Net.Queries.4.8.0-beta00015\lib\net45\Lucene.Net.Queries.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.FastVectorHighlighter.dll + + ..\packages\Lucene.Net.QueryParser.4.8.0-beta00015\lib\net45\Lucene.Net.QueryParser.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Highlighter.dll + + ..\packages\Lucene.Net.Sandbox.4.8.0-beta00015\lib\net45\Lucene.Net.Sandbox.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Memory.dll + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.1.1.2\lib\netstandard1.0\Microsoft.Extensions.Configuration.Abstractions.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Queries.dll + + ..\packages\Microsoft.Extensions.Primitives.1.1.1\lib\netstandard1.0\Microsoft.Extensions.Primitives.dll - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Regex.dll + + ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + True + True - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SimpleFacetedSearch.dll - - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.Snowball.dll + + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True - - ..\packages\Lucene.Net.Contrib.3.0.3\lib\net40\Lucene.Net.Contrib.SpellChecker.dll + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + True - + + ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + True + True + + + ..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + True + True + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + + ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + True + True + + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.3.0\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + True + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll + True + True + + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + True + @@ -90,10 +213,13 @@ - {086093FD-D444-48BE-B897-7FAC14133C23} + {87059512-913a-4b3d-bd07-c13419852b81} MultiFacetLucene + + + diff --git a/PerformanceTest/Program.cs b/PerformanceTest/Program.cs index e8d294e..af68854 100644 --- a/PerformanceTest/Program.cs +++ b/PerformanceTest/Program.cs @@ -6,13 +6,13 @@ using Lucene.Net.Analysis.Standard; using Lucene.Net.Documents; using Lucene.Net.Index; -using Lucene.Net.QueryParsers; +using Lucene.Net.QueryParsers.Classic; using Lucene.Net.Search; using Lucene.Net.Store; +using Lucene.Net.Util; using MultiFacetLucene; using MultiFacetLucene.Configuration; using MultiFacetLucene.Configuration.MemoryOptimizer; -using Version = Lucene.Net.Util.Version; namespace PerformanceTest { @@ -64,8 +64,7 @@ public static void Warmup() protected static IndexReader SetupIndex() { var directory = new RAMDirectory(); - var writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_29), true, - IndexWriter.MaxFieldLength.LIMITED); + var writer = new IndexWriter(directory, new IndexWriterConfig(LuceneVersion.LUCENE_48, new StandardAnalyzer(LuceneVersion.LUCENE_48))); for (var i = 0; i < 50000; i++) writer.AddDocument(new Document() .AddField("title", Guid.NewGuid().ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED) @@ -73,17 +72,16 @@ protected static IndexReader SetupIndex() .AddField("type", GenerateFood(), Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("type", GenerateFruit(), Field.Store.YES, Field.Index.NOT_ANALYZED) .AddField("price", "10", Field.Store.YES, Field.Index.NOT_ANALYZED)); - writer.Flush(true, true, true); - writer.Optimize(); + writer.Flush(true, true); writer.Commit(); - return IndexReader.Open(directory, true); + return DirectoryReader.Open(directory); } protected static IndexReader SetupIndexPhysicalTest() { - var directory = new DirectoryInfo(@"D:\Code\sites\SearchSite\SearchSiteWeb\App_Data\Index\Wordpress"); + var directory = new DirectoryInfo(@"c:\temp\lucene\multifacetlucene"); var index = FSDirectory.Open(directory); - return IndexReader.Open(index, true); + return DirectoryReader.Open(index); } private static void Main(string[] args) @@ -94,9 +92,9 @@ private static void Main(string[] args) var stopwatchAll = new Stopwatch(); stopwatchAll.Start(); - var queryParser = new MultiFieldQueryParser(Version.LUCENE_29, + var queryParser = new MultiFieldQueryParser(LuceneVersion.LUCENE_48, new[] {"title", "bodies"}, - new StandardAnalyzer(Version.LUCENE_29) + new StandardAnalyzer(LuceneVersion.LUCENE_48) ); var facetFieldInfos = new List diff --git a/PerformanceTest/packages.config b/PerformanceTest/packages.config index 591d3c9..a9789e6 100644 --- a/PerformanceTest/packages.config +++ b/PerformanceTest/packages.config @@ -1,6 +1,58 @@  - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VERSION.txt b/VERSION.txt index 56fea8a..0c89fc9 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.0.0 \ No newline at end of file +4.0.0 \ No newline at end of file