re-executes docs converter
diff --git a/src/Lucene.Net.Expressions/JS/package.md b/src/Lucene.Net.Expressions/JS/package.md
index d410dda..3ce22e2 100644
--- a/src/Lucene.Net.Expressions/JS/package.md
+++ b/src/Lucene.Net.Expressions/JS/package.md
@@ -32,7 +32,7 @@
* Boolean operators (including the ternary operator): `&& || ! ?:`
-* Comparison operators: `< <= == >= >`
+* Comparison operators: `< <= == >= >`
* Common mathematic functions: `abs ceil exp floor ln log2 log10 logn max min sqrt pow`
diff --git a/src/Lucene.Net/Codecs/package.md b/src/Lucene.Net/Codecs/package.md
new file mode 100644
index 0000000..eea6fd4
--- /dev/null
+++ b/src/Lucene.Net/Codecs/package.md
@@ -0,0 +1,34 @@
+---
+uid: Lucene.Net.Codecs
+summary: *content
+---
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+Codecs API: API for customization of the encoding and structure of the index.
+
+ The Codec API allows you to customise the way the following pieces of index information are stored: * Postings lists - see <xref:Lucene.Net.Codecs.PostingsFormat> * DocValues - see <xref:Lucene.Net.Codecs.DocValuesFormat> * Stored fields - see <xref:Lucene.Net.Codecs.StoredFieldsFormat> * Term vectors - see <xref:Lucene.Net.Codecs.TermVectorsFormat> * FieldInfos - see <xref:Lucene.Net.Codecs.FieldInfosFormat> * SegmentInfo - see <xref:Lucene.Net.Codecs.SegmentInfoFormat> * Norms - see <xref:Lucene.Net.Codecs.NormsFormat> * Live documents - see <xref:Lucene.Net.Codecs.LiveDocsFormat>
+
+ For some concrete implementations beyond Lucene's official index format, see
+ the [Codecs module]({@docRoot}/../codecs/overview-summary.html).
+
+ Codecs are identified by name through the Java Service Provider Interface. To create your own codec, extend <xref:Lucene.Net.Codecs.Codec> and pass the new codec's name to the super() constructor: public class MyCodec extends Codec { public MyCodec() { super("MyCodecName"); } ... } You will need to register the Codec class so that the {@link java.util.ServiceLoader ServiceLoader} can find it, by including a META-INF/services/org.apache.lucene.codecs.Codec file on your classpath that contains the package-qualified name of your codec.
+
+ If you just want to customise the <xref:Lucene.Net.Codecs.PostingsFormat>, or use different postings formats for different fields, then you can register your custom postings format in the same way (in META-INF/services/org.apache.lucene.codecs.PostingsFormat), and then extend the default <xref:Lucene.Net.Codecs.Lucene46.Lucene46Codec> and override [#getPostingsFormatForField(String)](xref:Lucene.Net.Codecs.Lucene46.Lucene46Codec) to return your custom postings format.
+
+ Similarly, if you just want to customise the <xref:Lucene.Net.Codecs.DocValuesFormat> per-field, have a look at [#getDocValuesFormatForField(String)](xref:Lucene.Net.Codecs.Lucene46.Lucene46Codec).
\ No newline at end of file
diff --git a/src/Lucene.Net/overview.md b/src/Lucene.Net/overview.md
index dc5432d..169769f 100644
--- a/src/Lucene.Net/overview.md
+++ b/src/Lucene.Net/overview.md
Binary files differ
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_AssociationsFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_AssociationsFacetsExample.md
index 98e4f25..bd69a03 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_AssociationsFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_AssociationsFacetsExample.md
@@ -51,87 +51,78 @@
{
IndexWriterConfig iwc = new IndexWriterConfig(EXAMPLE_VERSION,
new WhitespaceAnalyzer(EXAMPLE_VERSION));
- using (IndexWriter indexWriter = new IndexWriter(indexDir, iwc))
+ using IndexWriter indexWriter = new IndexWriter(indexDir, iwc);
// Writes facet ords to a separate directory from the main index
- using (DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir))
- {
+ using DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
+ Document doc = new Document();
+ // 3 occurrences for tag 'lucene'
- Document doc = new Document();
- // 3 occurrences for tag 'lucene'
+ doc.AddInt32AssociationFacetField(3, "tags", "lucene");
+ // 87% confidence level of genre 'computing'
+ doc.AddSingleAssociationFacetField(0.87f, "genre", "computing");
+ indexWriter.AddDocument(config.Build(taxoWriter, doc));
- doc.AddInt32AssociationFacetField(3, "tags", "lucene");
- // 87% confidence level of genre 'computing'
- doc.AddSingleAssociationFacetField(0.87f, "genre", "computing");
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- doc = new Document();
- // 1 occurrence for tag 'lucene'
- doc.AddInt32AssociationFacetField(1, "tags", "lucene");
- // 2 occurrence for tag 'solr'
- doc.AddInt32AssociationFacetField(2, "tags", "solr");
- // 75% confidence level of genre 'computing'
- doc.AddSingleAssociationFacetField(0.75f, "genre", "computing");
- // 34% confidence level of genre 'software'
- doc.AddSingleAssociationFacetField(0.34f, "genre", "software");
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- } // Disposes indexWriter and taxoWriter
+ doc = new Document();
+ // 1 occurrence for tag 'lucene'
+ doc.AddInt32AssociationFacetField(1, "tags", "lucene");
+ // 2 occurrence for tag 'solr'
+ doc.AddInt32AssociationFacetField(2, "tags", "solr");
+ // 75% confidence level of genre 'computing'
+ doc.AddSingleAssociationFacetField(0.75f, "genre", "computing");
+ // 34% confidence level of genre 'software'
+ doc.AddSingleAssociationFacetField(0.34f, "genre", "software");
+ indexWriter.AddDocument(config.Build(taxoWriter, doc));
}
/// <summary>User runs a query and aggregates facets by summing their association values.</summary>
private IList<FacetResult> SumAssociations()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+
+ FacetsCollector fc = new FacetsCollector();
+
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
+
+ Facets tags = new TaxonomyFacetSumInt32Associations("$tags", taxoReader, config, fc);
+ Facets genre = new TaxonomyFacetSumSingleAssociations("$genre", taxoReader, config, fc);
+
+ // Retrieve results
+ IList<FacetResult> results = new List<FacetResult>
{
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ tags.GetTopChildren(10, "tags"),
+ genre.GetTopChildren(10, "genre")
+ };
- FacetsCollector fc = new FacetsCollector();
-
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
-
- Facets tags = new TaxonomyFacetSumInt32Associations("$tags", taxoReader, config, fc);
- Facets genre = new TaxonomyFacetSumSingleAssociations("$genre", taxoReader, config, fc);
-
- // Retrieve results
- IList<FacetResult> results = new List<FacetResult>();
-
- results.Add(tags.GetTopChildren(10, "tags"));
- results.Add(genre.GetTopChildren(10, "genre"));
-
- return results;
-
- } // Disposes indexReader and taxoReader
+ return results;
}
/// <summary>User drills down on 'tags/solr'.</summary>
private FacetResult DrillDown()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Passing no baseQuery means we drill down on all
- // documents ("browse only"):
- DrillDownQuery q = new DrillDownQuery(config);
+ // Passing no baseQuery means we drill down on all
+ // documents ("browse only"):
+ DrillDownQuery q = new DrillDownQuery(config);
- // Now user drills down on Publish Date/2010:
- q.Add("tags", "solr");
- FacetsCollector fc = new FacetsCollector();
- FacetsCollector.Search(searcher, q, 10, fc);
+ // Now user drills down on Publish Date/2010:
+ q.Add("tags", "solr");
+ FacetsCollector fc = new FacetsCollector();
+ FacetsCollector.Search(searcher, q, 10, fc);
- // Retrieve results
- Facets facets = new TaxonomyFacetSumSingleAssociations("$genre", taxoReader, config, fc);
- FacetResult result = facets.GetTopChildren(10, "genre");
+ // Retrieve results
+ Facets facets = new TaxonomyFacetSumSingleAssociations("$genre", taxoReader, config, fc);
+ FacetResult result = facets.GetTopChildren(10, "genre");
- return result;
-
- } // Disposes indexReader and taxoReader
+ return result;
}
/// <summary>Runs summing association example.</summary>
@@ -148,7 +139,9 @@
return DrillDown();
}
+
/// <summary>Runs the sum int/float associations examples and prints the results.</summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Demo shows use of optional args argument")]
public static void Main(string[] args)
{
Console.WriteLine("Sum associations example:");
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_DistanceFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_DistanceFacetsExample.md
index 6f6a3e3..690da86 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_DistanceFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_DistanceFacetsExample.md
@@ -28,7 +28,7 @@
/// Shows simple usage of dynamic range faceting, using the
/// expressions module to calculate distance.
/// </summary>
- public class DistanceFacetsExample : IDisposable
+ public sealed class DistanceFacetsExample : IDisposable
{
/// <summary>
/// Using a constant for all functionality related to a specific index
@@ -66,34 +66,34 @@
/// <summary>Build the example index.</summary>
public void Index()
{
- using (IndexWriter writer = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
- {
- // TODO: we could index in radians instead ... saves all the conversions in GetBoundingBoxFilter
+ using IndexWriter writer = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
+ // TODO: we could index in radians instead ... saves all the conversions in GetBoundingBoxFilter
- // Add documents with latitude/longitude location:
- Document doc = new Document();
- doc.Add(new DoubleField("latitude", 40.759011, Field.Store.NO));
- doc.Add(new DoubleField("longitude", -73.9844722, Field.Store.NO));
- writer.AddDocument(doc);
+ // Add documents with latitude/longitude location:
+ writer.AddDocument(new Document
+ {
+ new DoubleField("latitude", 40.759011, Field.Store.NO),
+ new DoubleField("longitude", -73.9844722, Field.Store.NO)
+ });
- doc = new Document();
- doc.Add(new DoubleField("latitude", 40.718266, Field.Store.NO));
- doc.Add(new DoubleField("longitude", -74.007819, Field.Store.NO));
- writer.AddDocument(doc);
+ writer.AddDocument(new Document
+ {
+ new DoubleField("latitude", 40.718266, Field.Store.NO),
+ new DoubleField("longitude", -74.007819, Field.Store.NO)
+ });
- doc = new Document();
- doc.Add(new DoubleField("latitude", 40.7051157, Field.Store.NO));
- doc.Add(new DoubleField("longitude", -74.0088305, Field.Store.NO));
- writer.AddDocument(doc);
+ writer.AddDocument(new Document
+ {
+ new DoubleField("latitude", 40.7051157, Field.Store.NO),
+ new DoubleField("longitude", -74.0088305, Field.Store.NO)
+ });
- // Open near-real-time searcher
- searcher = new IndexSearcher(DirectoryReader.Open(writer, true));
-
- } // Disposes writer
+ // Open near-real-time searcher
+ searcher = new IndexSearcher(DirectoryReader.Open(writer, true));
}
- private ValueSource GetDistanceValueSource()
+ private static ValueSource GetDistanceValueSource()
{
Expression distance = JavascriptCompiler.Compile(
string.Format(CultureInfo.InvariantCulture, "haversin({0:R},{1:R},latitude,longitude)", ORIGIN_LATITUDE, ORIGIN_LONGITUDE));
@@ -156,22 +156,31 @@
maxLng = 180.ToRadians();
}
- BooleanFilter f = new BooleanFilter();
-
- // Add latitude range filter:
- f.Add(NumericRangeFilter.NewDoubleRange("latitude", minLat.ToDegrees(), maxLat.ToDegrees(), true, true),
- Occur.MUST);
+ BooleanFilter f = new BooleanFilter
+ {
+ // Add latitude range filter:
+ {
+ NumericRangeFilter.NewDoubleRange("latitude", minLat.ToDegrees(), maxLat.ToDegrees(), true, true),
+ Occur.MUST
+ }
+ };
// Add longitude range filter:
if (minLng > maxLng)
{
// The bounding box crosses the international date
// line:
- BooleanFilter lonF = new BooleanFilter();
- lonF.Add(NumericRangeFilter.NewDoubleRange("longitude", minLng.ToDegrees(), null, true, true),
- Occur.SHOULD);
- lonF.Add(NumericRangeFilter.NewDoubleRange("longitude", null, maxLng.ToDegrees(), true, true),
- Occur.SHOULD);
+ BooleanFilter lonF = new BooleanFilter
+ {
+ {
+ NumericRangeFilter.NewDoubleRange("longitude", minLng.ToDegrees(), null, true, true),
+ Occur.SHOULD
+ },
+ {
+ NumericRangeFilter.NewDoubleRange("longitude", null, maxLng.ToDegrees(), true, true),
+ Occur.SHOULD
+ }
+ };
f.Add(lonF, Occur.MUST);
}
else
@@ -238,21 +247,18 @@
/// <summary>Runs the search and drill-down examples and prints the results.</summary>
public static void Main(string[] args)
{
- using (DistanceFacetsExample example = new DistanceFacetsExample())
- {
- example.Index();
+ using DistanceFacetsExample example = new DistanceFacetsExample();
+ example.Index();
- Console.WriteLine("Distance facet counting example:");
- Console.WriteLine("-----------------------");
- Console.WriteLine(example.Search());
+ Console.WriteLine("Distance facet counting example:");
+ Console.WriteLine("-----------------------");
+ Console.WriteLine(example.Search());
- Console.WriteLine("\n");
- Console.WriteLine("Distance facet drill-down example (field/< 2 km):");
- Console.WriteLine("---------------------------------------------");
- TopDocs hits = example.DrillDown(TWO_KM);
- Console.WriteLine(hits.TotalHits + " totalHits");
-
- } // Disposes example
+ Console.WriteLine("\n");
+ Console.WriteLine("Distance facet drill-down example (field/< 2 km):");
+ Console.WriteLine("---------------------------------------------");
+ TopDocs hits = example.DrillDown(TWO_KM);
+ Console.WriteLine(hits.TotalHits + " totalHits");
}
}
}
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_ExpressionAggregationFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_ExpressionAggregationFacetsExample.md
index 23f91d0..d63ec48 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_ExpressionAggregationFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_ExpressionAggregationFacetsExample.md
@@ -40,57 +40,53 @@
/// <summary>Build the example index.</summary>
private void Index()
{
- using (IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
+ using IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
// Writes facet ords to a separate directory from the main index
- using (DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir))
- {
+ using DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
- Document doc = new Document();
- doc.Add(new TextField("c", "foo bar", Field.Store.NO));
- doc.Add(new NumericDocValuesField("popularity", 5L));
- doc.Add(new FacetField("A", "B"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new TextField("c", "foo bar", Field.Store.NO),
+ new NumericDocValuesField("popularity", 5L),
+ new FacetField("A", "B")
+ }));
- doc = new Document();
- doc.Add(new TextField("c", "foo foo bar", Field.Store.NO));
- doc.Add(new NumericDocValuesField("popularity", 3L));
- doc.Add(new FacetField("A", "C"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- } // Disposes indexWriter and taxoWriter
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new TextField("c", "foo foo bar", Field.Store.NO),
+ new NumericDocValuesField("popularity", 3L),
+ new FacetField("A", "C")
+ }));
}
/// <summary>User runs a query and aggregates facets.</summary>
private FacetResult Search()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Aggregate categories by an expression that combines the document's score
- // and its popularity field
- Expression expr = JavascriptCompiler.Compile("_score * sqrt(popularity)");
- SimpleBindings bindings = new SimpleBindings();
- bindings.Add(new SortField("_score", SortFieldType.SCORE)); // the score of the document
- bindings.Add(new SortField("popularity", SortFieldType.INT64)); // the value of the 'popularity' field
+ // Aggregate categories by an expression that combines the document's score
+ // and its popularity field
+ Expression expr = JavascriptCompiler.Compile("_score * sqrt(popularity)");
+ SimpleBindings bindings = new SimpleBindings();
+ bindings.Add(new SortField("_score", SortFieldType.SCORE)); // the score of the document
+ bindings.Add(new SortField("popularity", SortFieldType.INT64)); // the value of the 'popularity' field
- // Aggregates the facet values
- FacetsCollector fc = new FacetsCollector(true);
+ // Aggregates the facet values
+ FacetsCollector fc = new FacetsCollector(true);
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
- // Retrieve results
- Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, expr.GetValueSource(bindings));
- FacetResult result = facets.GetTopChildren(10, "A");
+ // Retrieve results
+ Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, expr.GetValueSource(bindings));
+ FacetResult result = facets.GetTopChildren(10, "A");
- return result;
-
- } // Disposes indexReader and taxoReader
+ return result;
}
/// <summary>Runs the search example.</summary>
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_MultiCategoryListsFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_MultiCategoryListsFacetsExample.md
index 3588f4f..5caf21b 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_MultiCategoryListsFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_MultiCategoryListsFacetsExample.md
@@ -47,38 +47,40 @@
/// <summary>Build the example index.</summary>
private void Index()
{
- using (IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
+ using IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
// Writes facet ords to a separate directory from the main index
- using (DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir))
+ using DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
+
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
{
- Document doc = new Document();
-
- doc.Add(new FacetField("Author", "Bob"));
- doc.Add(new FacetField("Publish Date", "2010", "10", "15"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ new FacetField("Author", "Bob"),
+ new FacetField("Publish Date", "2010", "10", "15")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2010", "10", "20"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2010", "10", "20")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2012", "1", "1"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2012", "1", "1")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Susan"));
- doc.Add(new FacetField("Publish Date", "2012", "1", "7"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Susan"),
+ new FacetField("Publish Date", "2012", "1", "7")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Frank"));
- doc.Add(new FacetField("Publish Date", "1999", "5", "5"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- } // Disposes indexWriter and taxoWriter
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Frank"),
+ new FacetField("Publish Date", "1999", "5", "5")
+ }));
}
/// <summary>User runs a query and counts facets.</summary>
@@ -86,27 +88,25 @@
{
IList<FacetResult> results = new List<FacetResult>();
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
- FacetsCollector fc = new FacetsCollector();
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+ FacetsCollector fc = new FacetsCollector();
- // Retrieve results
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
- // Count both "Publish Date" and "Author" dimensions
- Facets author = new FastTaxonomyFacetCounts("author", taxoReader, config, fc);
- results.Add(author.GetTopChildren(10, "Author"));
+ // Retrieve results
- Facets pubDate = new FastTaxonomyFacetCounts("pubdate", taxoReader, config, fc);
- results.Add(pubDate.GetTopChildren(10, "Publish Date"));
+ // Count both "Publish Date" and "Author" dimensions
+ Facets author = new FastTaxonomyFacetCounts("author", taxoReader, config, fc);
+ results.Add(author.GetTopChildren(10, "Author"));
- } // Disposes indexReader and taxoReader
+ Facets pubDate = new FastTaxonomyFacetCounts("pubdate", taxoReader, config, fc);
+ results.Add(pubDate.GetTopChildren(10, "Publish Date"));
return results;
}
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_RangeFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_RangeFacetsExample.md
index 870a0c6..5e44345 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_RangeFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_RangeFacetsExample.md
@@ -19,7 +19,7 @@
/// <summary>
/// Shows simple usage of dynamic range faceting.
/// </summary>
- public class RangeFacetsExample : IDisposable
+ public sealed class RangeFacetsExample : IDisposable
{
/// <summary>
/// Using a constant for all functionality related to a specific index
@@ -49,29 +49,26 @@
/// <summary>Build the example index.</summary>
public void Index()
{
- using (IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
+ using IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
+ // Add documents with a fake timestamp, 1000 sec before
+ // "now", 2000 sec before "now", ...:
+ for (int i = 0; i < 100; i++)
{
- // Add documents with a fake timestamp, 1000 sec before
- // "now", 2000 sec before "now", ...:
- for (int i = 0; i < 100; i++)
- {
- Document doc = new Document();
- long then = nowSec - i * 1000;
- // Add as doc values field, so we can compute range facets:
- doc.Add(new NumericDocValuesField("timestamp", then));
- // Add as numeric field so we can drill-down:
- doc.Add(new Int64Field("timestamp", then, Field.Store.NO));
- indexWriter.AddDocument(doc);
- }
+ Document doc = new Document();
+ long then = nowSec - i * 1000;
+ // Add as doc values field, so we can compute range facets:
+ doc.Add(new NumericDocValuesField("timestamp", then));
+ // Add as numeric field so we can drill-down:
+ doc.Add(new Int64Field("timestamp", then, Field.Store.NO));
+ indexWriter.AddDocument(doc);
+ }
- // Open near-real-time searcher
- searcher = new IndexSearcher(DirectoryReader.Open(indexWriter, true));
-
- } // Disposes indexWriter
+ // Open near-real-time searcher
+ searcher = new IndexSearcher(DirectoryReader.Open(indexWriter, true));
}
- private FacetsConfig GetConfig()
+ private static FacetsConfig GetConfig()
{
return new FacetsConfig();
}
@@ -115,21 +112,18 @@
/// <summary>Runs the search and drill-down examples and prints the results.</summary>
public static void Main(string[] args)
{
- using (RangeFacetsExample example = new RangeFacetsExample())
- {
- example.Index();
+ using RangeFacetsExample example = new RangeFacetsExample();
+ example.Index();
- Console.WriteLine("Facet counting example:");
- Console.WriteLine("-----------------------");
- Console.WriteLine(example.Search());
+ Console.WriteLine("Facet counting example:");
+ Console.WriteLine("-----------------------");
+ Console.WriteLine(example.Search());
- Console.WriteLine("\n");
- Console.WriteLine("Facet drill-down example (timestamp/Past six hours):");
- Console.WriteLine("---------------------------------------------");
- TopDocs hits = example.DrillDown(example.PAST_SIX_HOURS);
- Console.WriteLine(hits.TotalHits + " TotalHits");
-
- } // Disposes example
+ Console.WriteLine("\n");
+ Console.WriteLine("Facet drill-down example (timestamp/Past six hours):");
+ Console.WriteLine("---------------------------------------------");
+ TopDocs hits = example.DrillDown(example.PAST_SIX_HOURS);
+ Console.WriteLine(hits.TotalHits + " TotalHits");
}
}
}
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleFacetsExample.md
index acac442..b87ee09 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleFacetsExample.md
@@ -45,96 +45,95 @@
/// <summary>Build the example index.</summary>
private void Index()
{
- using (IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
+ using IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(EXAMPLE_VERSION,
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
// Writes facet ords to a separate directory from the main index
- using (DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir))
+ using DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
+
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
{
+ new FacetField("Author", "Bob"),
+ new FacetField("Publish Date", "2010", "10", "15")
+ }));
- Document doc = new Document();
- doc.Add(new FacetField("Author", "Bob"));
- doc.Add(new FacetField("Publish Date", "2010", "10", "15"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2010", "10", "20")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2010", "10", "20"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2012", "1", "1")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2012", "1", "1"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Susan"),
+ new FacetField("Publish Date", "2012", "1", "7")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Susan"));
- doc.Add(new FacetField("Publish Date", "2012", "1", "7"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- doc = new Document();
- doc.Add(new FacetField("Author", "Frank"));
- doc.Add(new FacetField("Publish Date", "1999", "5", "5"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- } // Disposes indexWriter and taxoWriter
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Frank"),
+ new FacetField("Publish Date", "1999", "5", "5")
+ }));
}
/// <summary>User runs a query and counts facets.</summary>
private IList<FacetResult> FacetsWithSearch()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+
+ FacetsCollector fc = new FacetsCollector();
+
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
+
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
+
+ // Retrieve results
+ IList<FacetResult> results = new List<FacetResult>
{
- IndexSearcher searcher = new IndexSearcher(indexReader);
-
- FacetsCollector fc = new FacetsCollector();
-
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
-
- // Retrieve results
- IList<FacetResult> results = new List<FacetResult>();
-
// Count both "Publish Date" and "Author" dimensions
- Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
- results.Add(facets.GetTopChildren(10, "Author"));
- results.Add(facets.GetTopChildren(10, "Publish Date"));
+ facets.GetTopChildren(10, "Author"),
+ facets.GetTopChildren(10, "Publish Date")
+ };
- return results;
-
- } // Disposes indexReader and taxoReader
+ return results;
}
/// <summary>User runs a query and counts facets only without collecting the matching documents.</summary>
private IList<FacetResult> FacetsOnly()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+
+ FacetsCollector fc = new FacetsCollector();
+
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ searcher.Search(new MatchAllDocsQuery(), null /*Filter */, fc);
+
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
+
+ // Retrieve results
+ IList<FacetResult> results = new List<FacetResult>
{
- IndexSearcher searcher = new IndexSearcher(indexReader);
-
- FacetsCollector fc = new FacetsCollector();
-
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- searcher.Search(new MatchAllDocsQuery(), null /*Filter */, fc);
-
- // Retrieve results
- IList<FacetResult> results = new List<FacetResult>();
-
// Count both "Publish Date" and "Author" dimensions
- Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
+ facets.GetTopChildren(10, "Author"),
+ facets.GetTopChildren(10, "Publish Date")
+ };
- results.Add(facets.GetTopChildren(10, "Author"));
- results.Add(facets.GetTopChildren(10, "Publish Date"));
-
- return results;
-
- } // Disposes indexReader and taxoReader
+ return results;
}
/// <summary>
@@ -143,27 +142,24 @@
/// </summary>
private FacetResult DrillDown()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Passing no baseQuery means we drill down on all
- // documents ("browse only"):
- DrillDownQuery q = new DrillDownQuery(config);
+ // Passing no baseQuery means we drill down on all
+ // documents ("browse only"):
+ DrillDownQuery q = new DrillDownQuery(config);
- // Now user drills down on Publish Date/2010:
- q.Add("Publish Date", "2010");
- FacetsCollector fc = new FacetsCollector();
- FacetsCollector.Search(searcher, q, 10, fc);
+ // Now user drills down on Publish Date/2010:
+ q.Add("Publish Date", "2010");
+ FacetsCollector fc = new FacetsCollector();
+ FacetsCollector.Search(searcher, q, 10, fc);
- // Retrieve results
- Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
- FacetResult result = facets.GetTopChildren(10, "Author");
+ // Retrieve results
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
+ FacetResult result = facets.GetTopChildren(10, "Author");
- return result;
-
- } // Disposes indexReader and taxoReader
+ return result;
}
/// <summary>
@@ -173,27 +169,24 @@
/// </summary>
private IList<FacetResult> DrillSideways()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- using (TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Passing no baseQuery means we drill down on all
- // documents ("browse only"):
- DrillDownQuery q = new DrillDownQuery(config);
+ // Passing no baseQuery means we drill down on all
+ // documents ("browse only"):
+ DrillDownQuery q = new DrillDownQuery(config);
- // Now user drills down on Publish Date/2010:
- q.Add("Publish Date", "2010");
+ // Now user drills down on Publish Date/2010:
+ q.Add("Publish Date", "2010");
- DrillSideways ds = new DrillSideways(searcher, config, taxoReader);
- DrillSidewaysResult result = ds.Search(q, 10);
+ DrillSideways ds = new DrillSideways(searcher, config, taxoReader);
+ DrillSidewaysResult result = ds.Search(q, 10);
- // Retrieve results
- IList<FacetResult> facets = result.Facets.GetAllDims(10);
+ // Retrieve results
+ IList<FacetResult> facets = result.Facets.GetAllDims(10);
- return facets;
-
- } // Disposes indexReader and taxoReader
+ return facets;
}
/// <summary>Runs the search example.</summary>
diff --git a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleSortedSetFacetsExample.md b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleSortedSetFacetsExample.md
index 8e5da5a..dcbdef1 100644
--- a/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleSortedSetFacetsExample.md
+++ b/websites/apidocs/apiSpec/Lucene_Net_Demo_Facet_SimpleSortedSetFacetsExample.md
@@ -39,87 +39,86 @@
/// <summary>Build the example index.</summary>
private void Index()
{
- using (IndexWriter indexWriter = new IndexWriter(indexDir,
+ using IndexWriter indexWriter = new IndexWriter(indexDir,
new IndexWriterConfig(EXAMPLE_VERSION,
- new WhitespaceAnalyzer(EXAMPLE_VERSION))))
+ new WhitespaceAnalyzer(EXAMPLE_VERSION)));
+
+ indexWriter.AddDocument(config.Build(new Document
{
- Document doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Bob"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year", "2010"));
- indexWriter.AddDocument(config.Build(doc));
+ new SortedSetDocValuesFacetField("Author", "Bob"),
+ new SortedSetDocValuesFacetField("Publish Year", "2010")
+ }));
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Lisa"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year", "2010"));
- indexWriter.AddDocument(config.Build(doc));
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Lisa"),
+ new SortedSetDocValuesFacetField("Publish Year", "2010")
+ }));
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Lisa"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year", "2012"));
- indexWriter.AddDocument(config.Build(doc));
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Lisa"),
+ new SortedSetDocValuesFacetField("Publish Year", "2012")
+ }));
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Susan"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year", "2012"));
- indexWriter.AddDocument(config.Build(doc));
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Susan"),
+ new SortedSetDocValuesFacetField("Publish Year", "2012")
+ }));
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Frank"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year", "1999"));
- indexWriter.AddDocument(config.Build(doc));
-
- } // Disposes indexWriter
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Frank"),
+ new SortedSetDocValuesFacetField("Publish Year", "1999")
+ }));
}
/// <summary>User runs a query and counts facets.</summary>
private IList<FacetResult> Search()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+ SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
+
+ // Aggregatses the facet counts
+ FacetsCollector fc = new FacetsCollector();
+
+ // MatchAllDocsQuery is for "browsing" (counts facets
+ // for all non-deleted docs in the index); normally
+ // you'd use a "normal" query:
+ FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
+
+ // Retrieve results
+ Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
+
+ IList<FacetResult> results = new List<FacetResult>
{
- IndexSearcher searcher = new IndexSearcher(indexReader);
- SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
+ facets.GetTopChildren(10, "Author"),
+ facets.GetTopChildren(10, "Publish Year")
+ };
- // Aggregatses the facet counts
- FacetsCollector fc = new FacetsCollector();
-
- // MatchAllDocsQuery is for "browsing" (counts facets
- // for all non-deleted docs in the index); normally
- // you'd use a "normal" query:
- FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, fc);
-
- // Retrieve results
- Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
-
- IList<FacetResult> results = new List<FacetResult>();
- results.Add(facets.GetTopChildren(10, "Author"));
- results.Add(facets.GetTopChildren(10, "Publish Year"));
-
- return results;
-
- } // Disposes indexWriter
+ return results;
}
/// <summary>User drills down on 'Publish Year/2010'.</summary>
private FacetResult DrillDown()
{
- using (DirectoryReader indexReader = DirectoryReader.Open(indexDir))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
- SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+ SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
- // Now user drills down on Publish Year/2010:
- DrillDownQuery q = new DrillDownQuery(config);
- q.Add("Publish Year", "2010");
- FacetsCollector fc = new FacetsCollector();
- FacetsCollector.Search(searcher, q, 10, fc);
+ // Now user drills down on Publish Year/2010:
+ DrillDownQuery q = new DrillDownQuery(config);
+ q.Add("Publish Year", "2010");
+ FacetsCollector fc = new FacetsCollector();
+ FacetsCollector.Search(searcher, q, 10, fc);
- // Retrieve results
- Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
- FacetResult result = facets.GetTopChildren(10, "Author");
+ // Retrieve results
+ Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
+ FacetResult result = facets.GetTopChildren(10, "Author");
- return result;
-
- } // Disposes indexReader
+ return result;
}
/// <summary>Runs the search example.</summary>