This is an automated email from the ASF dual-hosted git repository.
shazwazza pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new ae13dc4 re-executes docs converter
ae13dc4 is described below
commit ae13dc4dfe0b8a2d305b9f8f860ac0849a16ac80
Author: Shannon <[email protected]>
AuthorDate: Tue Feb 2 10:35:52 2021 +1100
re-executes docs converter
---
src/Lucene.Net.Expressions/JS/package.md | 2 +-
src/Lucene.Net/Codecs/package.md | 34 +++
src/Lucene.Net/overview.md | 257 ++++++++++-----------
...ene_Net_Demo_Facet_AssociationsFacetsExample.md | 113 +++++----
.../Lucene_Net_Demo_Facet_DistanceFacetsExample.md | 102 ++++----
...emo_Facet_ExpressionAggregationFacetsExample.md | 86 ++++---
...t_Demo_Facet_MultiCategoryListsFacetsExample.md | 92 ++++----
.../Lucene_Net_Demo_Facet_RangeFacetsExample.md | 66 +++---
.../Lucene_Net_Demo_Facet_SimpleFacetsExample.md | 181 +++++++--------
..._Net_Demo_Facet_SimpleSortedSetFacetsExample.md | 121 +++++-----
10 files changed, 530 insertions(+), 524 deletions(-)
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 @@ A Javascript expression is a numeric expression specified
using an expression sy
* 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 < [...]
+
+ 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 con [...]
+
+ 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
@@ -1,134 +1,125 @@
----
-uid: Lucene.Net
-title: Lucene.Net
-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.
--->
-
-Apache Lucene is a high-performance, full-featured text search engine library.
Here's a simple example how to use Lucene for indexing and searching (using
JUnit to check if the results are what we expect):
-
-<!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard
[email protected] = -->
-
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
+---
+uid: Lucene.Net
+title: Lucene.Net
+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.
+-->
+
+Apache Lucene is a high-performance, full-featured text search engine library.
Here's a simple example how to use Lucene for indexing and searching (using
JUnit to check if the results are what we expect):
+
+<!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard
[email protected] = -->
+
+ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
- // Store the index in memory:
- Directory directory = new RAMDirectory();
- // To store an index on disk, use this instead:
- //Directory directory = FSDirectory.open("/tmp/testindex");
- IndexWriterConfig config = new
IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
- IndexWriter iwriter = new IndexWriter(directory, config);
- Document doc = new Document();
- String text = "This is the text to be indexed.";
- doc.add(new Field("fieldname", text, TextField.TYPE_STORED));
- iwriter.addDocument(doc);
- iwriter.close();
-
- // Now search the index:
- DirectoryReader ireader = DirectoryReader.open(directory);
- IndexSearcher isearcher = new IndexSearcher(ireader);
- // Parse a simple query that searches for "text":
- QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,
"fieldname", analyzer);
- Query query = parser.parse("text");
- ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs;
- assertEquals(1, hits.length);
- // Iterate through the results:
- for (int i = 0; i < hits.length;="" i++)="" {="" document=""
hitdoc="isearcher.doc(hits[i].doc);" assertequals("this="" is="" the="" text=""
to="" be="" indexed.",="" hitdoc.get("fieldname"));="" }="" ireader.close();="">
-
-The Lucene API is divided into several packages:
-
-* __<xref:Lucene.Net.Analysis>__
-defines an abstract [Analyzer](xref:Lucene.Net.Analysis.Analyzer)
-API for converting text from a {@link java.io.Reader}
-into a [TokenStream](xref:Lucene.Net.Analysis.TokenStream),
-an enumeration of token [Attribute](xref:Lucene.Net.Util.Attribute)s.
-A TokenStream can be composed by applying
[TokenFilter](xref:Lucene.Net.Analysis.TokenFilter)s
-to the output of a [Tokenizer](xref:Lucene.Net.Analysis.Tokenizer).
-Tokenizers and TokenFilters are strung together and applied with an
[Analyzer](xref:Lucene.Net.Analysis.Analyzer).
-[analyzers-common](../analyzers-common/overview-summary.html) provides a
number of Analyzer implementations, including
-[StopAnalyzer](../analyzers-common/org/apache/lucene/analysis/core/StopAnalyzer.html)
-and the grammar-based
[StandardAnalyzer](../analyzers-common/org/apache/lucene/analysis/standard/StandardAnalyzer.html).
-
-
-* __<xref:Lucene.Net.Codecs>__
-provides an abstraction over the encoding and decoding of the inverted index
structure,
-as well as different implementations that can be chosen depending upon
application needs.
-
-
-* __<xref:Lucene.Net.Documents>__
-provides a simple [Document](xref:Lucene.Net.Documents.Document)
-class. A Document is simply a set of named
[Field](xref:Lucene.Net.Documents.Field)s,
-whose values may be strings or instances of {@link java.io.Reader}.
-
-
-* __<xref:Lucene.Net.Index>__
-provides two primary classes: [IndexWriter](xref:Lucene.Net.Index.IndexWriter),
-which creates and adds documents to indices; and
<xref:Lucene.Net.Index.IndexReader>,
-which accesses the data in the index.
-
-
-* __<xref:Lucene.Net.Search>__
-provides data structures to represent queries (ie
[TermQuery](xref:Lucene.Net.Search.TermQuery)
-for individual words, [PhraseQuery](xref:Lucene.Net.Search.PhraseQuery)
-for phrases, and [BooleanQuery](xref:Lucene.Net.Search.BooleanQuery)
-for boolean combinations of queries) and the
[IndexSearcher](xref:Lucene.Net.Search.IndexSearcher)
-which turns queries into [TopDocs](xref:Lucene.Net.Search.TopDocs).
-A number of [QueryParser](../queryparser/overview-summary.html)s are provided
for producing
-query structures from strings or xml.
-
-
-* __<xref:Lucene.Net.Store>__
-defines an abstract class for storing persistent data, the
[Directory](xref:Lucene.Net.Store.Directory),
-which is a collection of named files written by an
[IndexOutput](xref:Lucene.Net.Store.IndexOutput)
-and read by an [IndexInput](xref:Lucene.Net.Store.IndexInput).
-Multiple implementations are provided, including
[FSDirectory](xref:Lucene.Net.Store.FSDirectory),
-which uses a file system directory to store files, and
[RAMDirectory](xref:Lucene.Net.Store.RAMDirectory)
-which implements files as memory-resident data structures.
-
-
-* __<xref:Lucene.Net.Util>__
-contains a few handy data structures and util classes, ie
[OpenBitSet](xref:Lucene.Net.Util.OpenBitSet)
-and [PriorityQueue](xref:Lucene.Net.Util.PriorityQueue).
-
-To use Lucene, an application should:
-
-1. Create [Document](xref:Lucene.Net.Documents.Document)s by
-adding
-[Field](xref:Lucene.Net.Documents.Field)s;
-
-
-2. Create an [IndexWriter](xref:Lucene.Net.Index.IndexWriter)
-and add documents to it with
[AddDocument](xref:Lucene.Net.Index.IndexWriter#methods);
-
-
-3. Call
[QueryParser.parse()](../queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#parse(java.lang.String))
-to build a query from a string; and
-
-
-4. Create an [IndexSearcher](xref:Lucene.Net.Search.IndexSearcher)
-and pass the query to its
[Search](xref:Lucene.Net.Search.IndexSearcher#methods)
-method.
-
-Some simple examples of code which does this are:
-
-*
[IndexFiles.java](../demo/src-html/org/apache/lucene/demo/IndexFiles.html)
creates an
-index for all the files contained in a directory.
-
-
-*
[SearchFiles.java](../demo/src-html/org/apache/lucene/demo/SearchFiles.html)
prompts for
-queries and searches an index.
+ // Store the index in memory:
+ Directory directory = new RAMDirectory();
+ // To store an index on disk, use this instead:
+ //Directory directory = FSDirectory.open("/tmp/testindex");
+ IndexWriterConfig config = new
IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
+ IndexWriter iwriter = new IndexWriter(directory, config);
+ Document doc = new Document();
+ String text = "This is the text to be indexed.";
+ doc.add(new Field("fieldname", text, TextField.TYPE_STORED));
+ iwriter.addDocument(doc);
+ iwriter.close();
+
+ // Now search the index:
+ DirectoryReader ireader = DirectoryReader.open(directory);
+ IndexSearcher isearcher = new IndexSearcher(ireader);
+ // Parse a simple query that searches for "text":
+ QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,
"fieldname", analyzer);
+ Query query = parser.parse("text");
+ ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs;
+ assertEquals(1, hits.length);
+ // Iterate through the results:
+ for (int i = 0; i < hits.length;="" i++)="" {="" document=""
hitdoc="isearcher.doc(hits[i].doc);" assertequals("this="" is="" the="" text=""
to="" be="" indexed.",="" hitdoc.get("fieldname"));="" }="" ireader.close();="">
+
+The Lucene API is divided into several packages:
+
+* __<xref:Lucene.Net.Analysis>__
+defines an abstract [Analyzer](xref:Lucene.Net.Analysis.Analyzer)
+API for converting text from a {@link java.io.Reader}
+into a [TokenStream](xref:Lucene.Net.Analysis.TokenStream),
+an enumeration of token [Attribute](xref:Lucene.Net.Util.Attribute)s.
+A TokenStream can be composed by applying
[TokenFilter](xref:Lucene.Net.Analysis.TokenFilter)s
+to the output of a [Tokenizer](xref:Lucene.Net.Analysis.Tokenizer).
+Tokenizers and TokenFilters are strung together and applied with an
[Analyzer](xref:Lucene.Net.Analysis.Analyzer).
+[analyzers-common](../analyzers-common/overview-summary.html) provides a
number of Analyzer implementations, including
+[StopAnalyzer](../analyzers-common/org/apache/lucene/analysis/core/StopAnalyzer.html)
+and the grammar-based
[StandardAnalyzer](../analyzers-common/org/apache/lucene/analysis/standard/StandardAnalyzer.html).
+
+* __<xref:Lucene.Net.Codecs>__
+provides an abstraction over the encoding and decoding of the inverted index
structure,
+as well as different implementations that can be chosen depending upon
application needs.
+
+* __<xref:Lucene.Net.Documents>__
+provides a simple [Document](xref:Lucene.Net.Documents.Document)
+class. A Document is simply a set of named
[Field](xref:Lucene.Net.Documents.Field)s,
+whose values may be strings or instances of {@link java.io.Reader}.
+
+* __<xref:Lucene.Net.Index>__
+provides two primary classes: [IndexWriter](xref:Lucene.Net.Index.IndexWriter),
+which creates and adds documents to indices; and
<xref:Lucene.Net.Index.IndexReader>,
+which accesses the data in the index.
+
+* __<xref:Lucene.Net.Search>__
+provides data structures to represent queries (ie
[TermQuery](xref:Lucene.Net.Search.TermQuery)
+for individual words, [PhraseQuery](xref:Lucene.Net.Search.PhraseQuery)
+for phrases, and [BooleanQuery](xref:Lucene.Net.Search.BooleanQuery)
+for boolean combinations of queries) and the
[IndexSearcher](xref:Lucene.Net.Search.IndexSearcher)
+which turns queries into [TopDocs](xref:Lucene.Net.Search.TopDocs).
+A number of [QueryParser](../queryparser/overview-summary.html)s are provided
for producing
+query structures from strings or xml.
+
+* __<xref:Lucene.Net.Store>__
+defines an abstract class for storing persistent data, the
[Directory](xref:Lucene.Net.Store.Directory),
+which is a collection of named files written by an
[IndexOutput](xref:Lucene.Net.Store.IndexOutput)
+and read by an [IndexInput](xref:Lucene.Net.Store.IndexInput).
+Multiple implementations are provided, including
[FSDirectory](xref:Lucene.Net.Store.FSDirectory),
+which uses a file system directory to store files, and
[RAMDirectory](xref:Lucene.Net.Store.RAMDirectory)
+which implements files as memory-resident data structures.
+
+* __<xref:Lucene.Net.Util>__
+contains a few handy data structures and util classes, ie
[OpenBitSet](xref:Lucene.Net.Util.OpenBitSet)
+and [PriorityQueue](xref:Lucene.Net.Util.PriorityQueue).
+
+To use Lucene, an application should:
+
+1. Create [Document](xref:Lucene.Net.Documents.Document)s by
+adding
+[Field](xref:Lucene.Net.Documents.Field)s;
+
+2. Create an [IndexWriter](xref:Lucene.Net.Index.IndexWriter)
+and add documents to it with
[AddDocument](xref:Lucene.Net.Index.IndexWriter#methods);
+
+3. Call
[QueryParser.parse()](../queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#parse(java.lang.String))
+to build a query from a string; and
+
+4. Create an [IndexSearcher](xref:Lucene.Net.Search.IndexSearcher)
+and pass the query to its
[Search](xref:Lucene.Net.Search.IndexSearcher#methods)
+method.
+
+Some simple examples of code which does this are:
+
+*
[IndexFiles.java](../demo/src-html/org/apache/lucene/demo/IndexFiles.html)
creates an
+index for all the files contained in a directory.
+
+*
[SearchFiles.java](../demo/src-html/org/apache/lucene/demo/SearchFiles.html)
prompts for
+queries and searches an index.
+
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 @@ namespace Lucene.Net.Demo.Facet
{
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))
- {
-
- 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 = 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
+ using DirectoryTaxonomyWriter taxoWriter = new
DirectoryTaxonomyWriter(taxoDir);
+ 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 = 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))
- {
- 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);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new
DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- Facets tags = new TaxonomyFacetSumInt32Associations("$tags",
taxoReader, config, fc);
- Facets genre = new
TaxonomyFacetSumSingleAssociations("$genre", taxoReader, config, fc);
+ FacetsCollector fc = new FacetsCollector();
- // Retrieve results
- IList<FacetResult> results = new List<FacetResult>();
+ // 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);
- results.Add(tags.GetTopChildren(10, "tags"));
- results.Add(genre.GetTopChildren(10, "genre"));
+ Facets tags = new TaxonomyFacetSumInt32Associations("$tags",
taxoReader, config, fc);
+ Facets genre = new TaxonomyFacetSumSingleAssociations("$genre",
taxoReader, config, fc);
- return results;
+ // Retrieve results
+ IList<FacetResult> results = new List<FacetResult>
+ {
+ tags.GetTopChildren(10, "tags"),
+ genre.GetTopChildren(10, "genre")
+ };
- } // 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 @@ namespace Lucene.Net.Demo.Facet
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 @@ namespace Lucene.Net.Demo.Facet
/// 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 @@ namespace Lucene.Net.Demo.Facet
/// <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
-
- // 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);
+ 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
- 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);
+ // 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.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.718266, Field.Store.NO),
+ new DoubleField("longitude", -74.007819, Field.Store.NO)
+ });
- // Open near-real-time searcher
- searcher = new IndexSearcher(DirectoryReader.Open(writer,
true));
+ writer.AddDocument(new Document
+ {
+ new DoubleField("latitude", 40.7051157, Field.Store.NO),
+ new DoubleField("longitude", -74.0088305, Field.Store.NO)
+ });
- } // 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 @@ namespace Lucene.Net.Demo.Facet
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 @@ namespace Lucene.Net.Demo.Facet
/// <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();
-
- 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
+ using DistanceFacetsExample example = new DistanceFacetsExample();
+ example.Index();
+
+ 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");
}
}
}
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 @@ namespace Lucene.Net.Demo.Facet
/// <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))
- {
-
- 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));
-
- 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
+ using DirectoryTaxonomyWriter taxoWriter = new
DirectoryTaxonomyWriter(taxoDir);
+
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new TextField("c", "foo bar", Field.Store.NO),
+ new NumericDocValuesField("popularity", 5L),
+ new FacetField("A", "B")
+ }));
+
+ 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);
-
- // 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);
-
- // 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");
-
- return result;
-
- } // Disposes indexReader and taxoReader
+ 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
+
+ // 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);
+
+ // Retrieve results
+ Facets facets = new TaxonomyFacetSumValueSource(taxoReader,
config, fc, expr.GetValueSource(bindings));
+ FacetResult result = facets.GetTopChildren(10, "A");
+
+ 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 @@ namespace Lucene.Net.Demo.Facet
/// <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")
+ }));
+
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2010", "10", "20")
+ }));
+
+ 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));
-
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2010", "10", "20"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- doc = new Document();
- doc.Add(new FacetField("Author", "Lisa"));
- doc.Add(new FacetField("Publish Date", "2012", "1", "1"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
-
- 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
+ new FacetField("Author", "Lisa"),
+ new FacetField("Publish Date", "2012", "1", "1")
+ }));
+
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Susan"),
+ new FacetField("Publish Date", "2012", "1", "7")
+ }));
+
+ 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 @@ namespace Lucene.Net.Demo.Facet
{
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 @@ namespace Lucene.Net.Demo.Facet
/// <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 @@ namespace Lucene.Net.Demo.Facet
/// <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);
- }
-
- // Open near-real-time searcher
- searcher = new IndexSearcher(DirectoryReader.Open(indexWriter,
true));
-
- } // Disposes indexWriter
+ 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));
}
- private FacetsConfig GetConfig()
+ private static FacetsConfig GetConfig()
{
return new FacetsConfig();
}
@@ -115,21 +112,18 @@ namespace Lucene.Net.Demo.Facet
/// <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();
-
- 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
+ using RangeFacetsExample example = new RangeFacetsExample();
+ example.Index();
+
+ 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");
}
}
}
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 @@ namespace Lucene.Net.Demo.Facet
/// <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))
- {
-
- 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));
+ using DirectoryTaxonomyWriter taxoWriter = new
DirectoryTaxonomyWriter(taxoDir);
- 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", "Bob"),
+ new FacetField("Publish Date", "2010", "10", "15")
+ }));
- 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", "2010", "10", "20")
+ }));
- 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", "Lisa"),
+ new FacetField("Publish Date", "2012", "1", "1")
+ }));
- doc = new Document();
- doc.Add(new FacetField("Author", "Frank"));
- doc.Add(new FacetField("Publish Date", "1999", "5", "5"));
- indexWriter.AddDocument(config.Build(taxoWriter, doc));
+ indexWriter.AddDocument(config.Build(taxoWriter, new Document
+ {
+ new FacetField("Author", "Susan"),
+ new FacetField("Publish Date", "2012", "1", "7")
+ }));
- } // 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))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new
DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- FacetsCollector fc = new FacetsCollector();
+ 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);
+ // 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>();
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config,
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))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new
DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- FacetsCollector fc = new FacetsCollector();
+ 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);
+ // 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>();
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config,
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"));
-
- return results;
+ facets.GetTopChildren(10, "Author"),
+ facets.GetTopChildren(10, "Publish Date")
+ };
- } // Disposes indexReader and taxoReader
+ return results;
}
/// <summary>
@@ -143,27 +142,24 @@ namespace Lucene.Net.Demo.Facet
/// </summary>
private FacetResult DrillDown()
{
- 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);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new
DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Now user drills down on Publish Date/2010:
- q.Add("Publish Date", "2010");
- FacetsCollector fc = new FacetsCollector();
- FacetsCollector.Search(searcher, q, 10, fc);
+ // Passing no baseQuery means we drill down on all
+ // documents ("browse only"):
+ DrillDownQuery q = new DrillDownQuery(config);
- // Retrieve results
- Facets facets = new FastTaxonomyFacetCounts(taxoReader,
config, fc);
- FacetResult result = facets.GetTopChildren(10, "Author");
+ // Now user drills down on Publish Date/2010:
+ q.Add("Publish Date", "2010");
+ FacetsCollector fc = new FacetsCollector();
+ FacetsCollector.Search(searcher, q, 10, fc);
- return result;
+ // Retrieve results
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config,
fc);
+ FacetResult result = facets.GetTopChildren(10, "Author");
- } // Disposes indexReader and taxoReader
+ return result;
}
/// <summary>
@@ -173,27 +169,24 @@ namespace Lucene.Net.Demo.Facet
/// </summary>
private IList<FacetResult> DrillSideways()
{
- 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);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ using TaxonomyReader taxoReader = new
DirectoryTaxonomyReader(taxoDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
- // Now user drills down on Publish Date/2010:
- q.Add("Publish Date", "2010");
+ // Passing no baseQuery means we drill down on all
+ // documents ("browse only"):
+ DrillDownQuery q = new DrillDownQuery(config);
- DrillSideways ds = new DrillSideways(searcher, config,
taxoReader);
- DrillSidewaysResult result = ds.Search(q, 10);
+ // Now user drills down on Publish Date/2010:
+ q.Add("Publish Date", "2010");
- // Retrieve results
- IList<FacetResult> facets = result.Facets.GetAllDims(10);
+ DrillSideways ds = new DrillSideways(searcher, config, taxoReader);
+ DrillSidewaysResult result = ds.Search(q, 10);
- return facets;
+ // Retrieve results
+ IList<FacetResult> facets = result.Facets.GetAllDims(10);
- } // 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 @@ namespace Lucene.Net.Demo.Facet
/// <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
+ {
+ new SortedSetDocValuesFacetField("Author", "Bob"),
+ new SortedSetDocValuesFacetField("Publish Year", "2010")
+ }));
+
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Lisa"),
+ new SortedSetDocValuesFacetField("Publish Year", "2010")
+ }));
+
+ indexWriter.AddDocument(config.Build(new Document
+ {
+ new SortedSetDocValuesFacetField("Author", "Lisa"),
+ new SortedSetDocValuesFacetField("Publish Year", "2012")
+ }));
+
+ 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));
-
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Lisa"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year",
"2010"));
- indexWriter.AddDocument(config.Build(doc));
-
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Lisa"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year",
"2012"));
- indexWriter.AddDocument(config.Build(doc));
-
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Susan"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year",
"2012"));
- indexWriter.AddDocument(config.Build(doc));
-
- doc = new Document();
- doc.Add(new SortedSetDocValuesFacetField("Author", "Frank"));
- doc.Add(new SortedSetDocValuesFacetField("Publish Year",
"1999"));
- indexWriter.AddDocument(config.Build(doc));
-
- } // Disposes indexWriter
+ new SortedSetDocValuesFacetField("Author", "Susan"),
+ new SortedSetDocValuesFacetField("Publish Year", "2012")
+ }));
+
+ 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))
- {
- IndexSearcher searcher = new IndexSearcher(indexReader);
- SortedSetDocValuesReaderState state = new
DefaultSortedSetDocValuesReaderState(indexReader);
-
- // Aggregatses the facet counts
- FacetsCollector fc = new FacetsCollector();
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+ SortedSetDocValuesReaderState state = new
DefaultSortedSetDocValuesReaderState(indexReader);
- // 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);
+ // Aggregatses the facet counts
+ FacetsCollector fc = new FacetsCollector();
- // Retrieve results
- Facets facets = new SortedSetDocValuesFacetCounts(state, 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);
- IList<FacetResult> results = new List<FacetResult>();
- results.Add(facets.GetTopChildren(10, "Author"));
- results.Add(facets.GetTopChildren(10, "Publish Year"));
+ // Retrieve results
+ Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
- return results;
+ IList<FacetResult> results = new List<FacetResult>
+ {
+ facets.GetTopChildren(10, "Author"),
+ facets.GetTopChildren(10, "Publish Year")
+ };
- } // 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);
-
- // 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);
+ using DirectoryReader indexReader = DirectoryReader.Open(indexDir);
+ IndexSearcher searcher = new IndexSearcher(indexReader);
+ SortedSetDocValuesReaderState state = new
DefaultSortedSetDocValuesReaderState(indexReader);
- // Retrieve results
- Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
- FacetResult result = facets.GetTopChildren(10, "Author");
+ // 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);
- return result;
+ // Retrieve results
+ Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
+ FacetResult result = facets.GetTopChildren(10, "Author");
- } // Disposes indexReader
+ return result;
}
/// <summary>Runs the search example.</summary>