blob: db1d4d0df519eca1a9492937d5b3bbb1f35ae9ca [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class MemoryIndex
| Apache Lucene.NET 4.8.0-beta00010 Documentation </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class MemoryIndex
| Apache Lucene.NET 4.8.0-beta00010 Documentation ">
<meta name="generator" content="docfx 2.56.0.0">
<link rel="shortcut icon" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/favicon.ico">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.css">
<meta property="docfx:navrel" content="toc.html">
<meta property="docfx:tocrel" content="memory/toc.html">
<meta property="docfx:rel" content="https://lucenenet.apache.org/docs/4.8.0-beta00009/">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img id="logo" class="svg" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/lucene-net-color.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search">
<ul class="level0 breadcrumb">
<li>
<a href="https://lucenenet.apache.org/docs/4.8.0-beta00009/">API</a>
<span id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</span>
</li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items">
<p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
</div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Lucene.Net.Index.Memory.MemoryIndex">
<h1 id="Lucene_Net_Index_Memory_MemoryIndex" data-uid="Lucene.Net.Index.Memory.MemoryIndex" class="text-break">Class MemoryIndex
</h1>
<div class="markdown level0 summary"><p>High-performance single-document main memory Apache Lucene fulltext search index. </p>
<h4>Overview</h4>
<p>This class is a replacement/substitute for a large subset of
<a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Store.RAMDirectory.html">RAMDirectory</a> functionality. It is designed to
enable maximum efficiency for on-the-fly matchmaking combining structured and
fuzzy fulltext search in realtime streaming applications such as Nux XQuery based XML
message queues, publish-subscribe systems for Blogs/newsfeeds, text chat, data acquisition and
distribution systems, application level routers, firewalls, classifiers, etc.
Rather than targeting fulltext search of infrequent queries over huge persistent
data archives (historic search), this class targets fulltext search of huge
numbers of queries over comparatively small transient realtime data (prospective
search).
For example as in </p>
<pre><code>float score = Search(string text, Query query)</code></pre>
<p>
Each instance can hold at most one Lucene &quot;document&quot;, with a document containing
zero or more &quot;fields&quot;, each field having a name and a fulltext value. The
fulltext value is tokenized (split and transformed) into zero or more index terms
(aka words) on <pre><code>AddField()</code></pre>, according to the policy implemented by an
Analyzer. For example, Lucene analyzers can split on whitespace, normalize to lower case
for case insensitivity, ignore common terms with little discriminatory value such as &quot;he&quot;, &quot;in&quot;, &quot;and&quot; (stop
words), reduce the terms to their natural linguistic root form such as &quot;fishing&quot;
being reduced to &quot;fish&quot; (stemming), resolve synonyms/inflexions/thesauri
(upon indexing and/or querying), etc. For details, see
<a target="_blank" href="http://today.java.net/pub/a/today/2003/07/30/LuceneIntro.html">Lucene Analyzer Intro</a>.
</p>
<p>
Arbitrary Lucene queries can be run against this class - see <a target="_blank" href="{@docRoot}/../queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description">
Lucene Query Syntax</a>
as well as <a target="_blank" href="http://today.java.net/pub/a/today/2003/11/07/QueryParserRules.html">Query Parser Rules</a>.
Note that a Lucene query selects on the field names and associated (indexed)
tokenized terms, not on the original fulltext(s) - the latter are not stored
but rather thrown away immediately after tokenization.
</p>
<p>
For some interesting background information on search technology, see Bob Wyman&apos;s
<a target="_blank" href="http://bobwyman.pubsub.com/main/2005/05/mary_hodder_poi.html">Prospective Search</a>,
Jim Gray&apos;s
<a target="_blank" href="http://www.acmqueue.org/modules.php?name=Content&amp;pa=showpage&amp;pid=293&amp;page=4">
A Call to Arms - Custom subscriptions</a>, and Tim Bray&apos;s
<a target="_blank" href="http://www.tbray.org/ongoing/When/200x/2003/07/30/OnSearchTOC">On Search, the Series</a>.
<h4>Example Usage</h4>
<pre><code>Analyzer analyzer = new SimpleAnalyzer(version);
MemoryIndex index = new MemoryIndex();
index.AddField(&quot;content&quot;, &quot;Readings about Salmons and other select Alaska fishing Manuals&quot;, analyzer);
index.AddField(&quot;author&quot;, &quot;Tales of James&quot;, analyzer);
QueryParser parser = new QueryParser(version, &quot;content&quot;, analyzer);
float score = index.Search(parser.Parse(&quot;+author:james +salmon~ +fish* manual~&quot;));
if (score > 0.0f) {
Console.WriteLine(&quot;it&apos;s a match&quot;);
} else {
Console.WriteLine(&quot;no match found&quot;);
}
Console.WriteLine(&quot;indexData=&quot; + index.toString());</code></pre>
<h4>Example XQuery Usage</h4>
<pre><code>(: An XQuery that finds all books authored by James that have something to do with &quot;salmon fishing manuals&quot;, sorted by relevance :)
declare namespace lucene = &quot;java:nux.xom.pool.FullTextUtil&quot;;
declare variable $query := &quot;+salmon~ +fish* manual~&quot;; (: any arbitrary Lucene query can go here :)
for $book in /books/book[author=&quot;James&quot; and lucene:match(abstract, $query) > 0.0]
let $score := lucene:match($book/abstract, $query)
order by $score descending
return $book</code></pre>
<h4>No thread safety guarantees</h4>
An instance can be queried multiple times with the same or different queries,
but an instance is not thread-safe. If desired use idioms such as:
<pre><code>MemoryIndex index = ...
lock (index) {
// read and/or write index (i.e. add fields and/or query)
} </code></pre>
<h4>Performance Notes</h4>
Internally there&apos;s a new data structure geared towards efficient indexing
and searching, plus the necessary support code to seamlessly plug into the Lucene
framework.
</p>
<p>
This class performs very well for very small texts (e.g. 10 chars)
as well as for large texts (e.g. 10 MB) and everything in between.
Typically, it is about 10-100 times faster than <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Store.RAMDirectory.html">RAMDirectory</a>.
Note that <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Store.RAMDirectory.html">RAMDirectory</a> has particularly
large efficiency overheads for small to medium sized texts, both in time and space.
Indexing a field with N tokens takes O(N) in the best case, and O(N logN) in the worst
case. Memory consumption is probably larger than for <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Store.RAMDirectory.html">RAMDirectory</a>.
</p>
<p>
Example throughput of many simple term queries over a single MemoryIndex:
~500000 queries/sec on a MacBook Pro, jdk 1.5.0_06, server VM.
As always, your mileage may vary.
</p>
<p>
If you&apos;re curious about
the whereabouts of bottlenecks, run java 1.5 with the non-perturbing &apos;-server
-agentlib:hprof=cpu=samples,depth=10&apos; flags, then study the trace log and
correlate its hotspot trailer with its call stack headers (see <a target="_blank" href="http://java.sun.com/developer/technicalArticles/Programming/HPROF.html">
hprof tracing </a>).
</p>
</div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><span class="xref">MemoryIndex</span></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.Equals(System.Object)</span>
</div>
<div>
<span class="xref">System.Object.Equals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.GetHashCode()</span>
</div>
<div>
<span class="xref">System.Object.GetType()</span>
</div>
<div>
<span class="xref">System.Object.MemberwiseClone()</span>
</div>
<div>
<span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
</div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="Lucene.Net.Index.Memory.html">Lucene.Net.Index.Memory</a></h6>
<h6><strong>Assembly</strong>: Lucene.Net.Memory.dll</h6>
<h5 id="Lucene_Net_Index_Memory_MemoryIndex_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">[Serializable]
public class MemoryIndex</code></pre>
</div>
<h3 id="constructors">Constructors
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex__ctor.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.%23ctor%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L188">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex__ctor_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.#ctor*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex__ctor" data-uid="Lucene.Net.Index.Memory.MemoryIndex.#ctor">MemoryIndex()</h4>
<div class="markdown level1 summary"><p>Constructs an empty instance.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public MemoryIndex()</code></pre>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex__ctor_System_Boolean_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.%23ctor(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L203">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex__ctor_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.#ctor*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex__ctor_System_Boolean_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.#ctor(System.Boolean)">MemoryIndex(Boolean)</h4>
<div class="markdown level1 summary"><p>Constructs an empty instance that can optionally store the start and end
character offset of each token term in the text. This can be useful for
highlighting of hit locations with the Lucene highlighter package.
Protected until the highlighter package matures, so that this can actually
be meaningfully integrated.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public MemoryIndex(bool storeOffsets)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><span class="parametername">storeOffsets</span></td>
<td><p>whether or not to store the start and end character offset of
each token term in the text </p>
</td>
</tr>
</tbody>
</table>
<h3 id="methods">Methods
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String%2CLucene.Net.Analysis.TokenStream)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L330">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_AddField_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String,Lucene.Net.Analysis.TokenStream)">AddField(String, TokenStream)</h4>
<div class="markdown level1 summary"><p>Equivalent to <code>AddField(fieldName, stream, 1.0f)</code>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddField(string fieldName, TokenStream stream)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">fieldName</span></td>
<td><p>a name to be associated with the text </p>
</td>
</tr>
<tr>
<td><span class="xref">Lucene.Net.Analysis.TokenStream</span></td>
<td><span class="parametername">stream</span></td>
<td><p>the token stream to retrieve tokens from </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String%2CLucene.Net.Analysis.TokenStream%2CSystem.Single)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L346">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_AddField_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String,Lucene.Net.Analysis.TokenStream,System.Single)">AddField(String, TokenStream, Single)</h4>
<div class="markdown level1 summary"><p>Iterates over the given token stream and adds the resulting terms to the index;
Equivalent to adding a tokenized, indexed, termVectorStored, unstored,
Lucene <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html">Field</a>.
Finally closes the token stream. Note that untokenized keywords can be added with this method via
<span class="xref">KeywordTokenStream{T}(ICollection{T}</span>)&quot;/&gt;, the Lucene <code>KeywordTokenizer</code> or similar utilities.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddField(string fieldName, TokenStream stream, float boost)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">fieldName</span></td>
<td><p>a name to be associated with the text </p>
</td>
</tr>
<tr>
<td><span class="xref">Lucene.Net.Analysis.TokenStream</span></td>
<td><span class="parametername">stream</span></td>
<td><p>the token stream to retrieve tokens from. </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">boost</span></td>
<td><p>the boost factor for hits for this field </p>
</td>
</tr>
</tbody>
</table>
<h5 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single__seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html#Lucene_Net_Documents_Field_Boost">Boost</a></div>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String%2CLucene.Net.Analysis.TokenStream%2CSystem.Single%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L366">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_AddField_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String,Lucene.Net.Analysis.TokenStream,System.Single,System.Int32)">AddField(String, TokenStream, Single, Int32)</h4>
<div class="markdown level1 summary"><p>Iterates over the given token stream and adds the resulting terms to the index;
Equivalent to adding a tokenized, indexed, termVectorStored, unstored,
Lucene <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html">Field</a>.
Finally closes the token stream. Note that untokenized keywords can be added with this method via
<span class="xref">KeywordTokenStream{T}(ICollection{T}</span>)&quot;/&gt;, the Lucene <code>KeywordTokenizer</code> or similar utilities.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddField(string fieldName, TokenStream stream, float boost, int positionIncrementGap)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">fieldName</span></td>
<td><p>a name to be associated with the text </p>
</td>
</tr>
<tr>
<td><span class="xref">Lucene.Net.Analysis.TokenStream</span></td>
<td><span class="parametername">stream</span></td>
<td><p>the token stream to retrieve tokens from. </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">boost</span></td>
<td><p>the boost factor for hits for this field </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">positionIncrementGap</span></td>
<td><p>the position increment gap if fields with the same name are added more than once</p>
</td>
</tr>
</tbody>
</table>
<h5 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32__seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html#Lucene_Net_Documents_Field_Boost">Boost</a></div>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32_System_Int32_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String%2CLucene.Net.Analysis.TokenStream%2CSystem.Single%2CSystem.Int32%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L385">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_AddField_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32_System_Int32_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String,Lucene.Net.Analysis.TokenStream,System.Single,System.Int32,System.Int32)">AddField(String, TokenStream, Single, Int32, Int32)</h4>
<div class="markdown level1 summary"><p>Iterates over the given token stream and adds the resulting terms to the index;
Equivalent to adding a tokenized, indexed, termVectorStored, unstored,
Lucene <a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html">Field</a>.
Finally closes the token stream. Note that untokenized keywords can be added with this method via
<span class="xref">KeywordTokenStream{T}(ICollection{T}</span>)&quot;/&gt;, the Lucene <code>KeywordTokenizer</code> or similar utilities.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddField(string fieldName, TokenStream stream, float boost, int positionIncrementGap, int offsetGap)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">fieldName</span></td>
<td><p>a name to be associated with the text </p>
</td>
</tr>
<tr>
<td><span class="xref">Lucene.Net.Analysis.TokenStream</span></td>
<td><span class="parametername">stream</span></td>
<td><p>the token stream to retrieve tokens from. </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">boost</span></td>
<td><p>the boost factor for hits for this field </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">positionIncrementGap</span></td>
<td><p>the position increment gap if fields with the same name are added more than once </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">offsetGap</span></td>
<td><p>the offset gap if fields with the same name are added more than once </p>
</td>
</tr>
</tbody>
</table>
<h5 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_System_Single_System_Int32_System_Int32__seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html#Lucene_Net_Documents_Field_Boost">Boost</a></div>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_System_String_Lucene_Net_Analysis_Analyzer_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String%2CSystem.String%2CLucene.Net.Analysis.Analyzer)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L234">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_AddField_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_System_String_Lucene_Net_Analysis_Analyzer_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.AddField(System.String,System.String,Lucene.Net.Analysis.Analyzer)">AddField(String, String, Analyzer)</h4>
<div class="markdown level1 summary"><p>Convenience method; Tokenizes the given field text and adds the resulting
terms to the index; Equivalent to adding an indexed non-keyword Lucene
<a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Documents.Field.html">Field</a> that is tokenized, not stored,
termVectorStored with positions (or termVectorStored with positions and offsets),</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddField(string fieldName, string text, Analyzer analyzer)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">fieldName</span></td>
<td><p>a name to be associated with the text </p>
</td>
</tr>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">text</span></td>
<td><p>the text to tokenize and index. </p>
</td>
</tr>
<tr>
<td><span class="xref">Lucene.Net.Analysis.Analyzer</span></td>
<td><span class="parametername">analyzer</span></td>
<td><p>the analyzer to use for tokenization </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_CreateSearcher.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.CreateSearcher%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L514">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_CreateSearcher_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.CreateSearcher*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_CreateSearcher" data-uid="Lucene.Net.Index.Memory.MemoryIndex.CreateSearcher">CreateSearcher()</h4>
<div class="markdown level1 summary"><p>Creates and returns a searcher that can be used to execute arbitrary
Lucene queries and to collect the resulting query results as hits.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual IndexSearcher CreateSearcher()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">Lucene.Net.Search.IndexSearcher</span></td>
<td><p>a searcher </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_GetMemorySize.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.GetMemorySize%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L604">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_GetMemorySize_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.GetMemorySize*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_GetMemorySize" data-uid="Lucene.Net.Index.Memory.MemoryIndex.GetMemorySize">GetMemorySize()</h4>
<div class="markdown level1 summary"><p>Returns a reasonable approximation of the main memory [bytes] consumed by
this instance. Useful for smart memory sensititive caches/pools. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual long GetMemorySize()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int64</span></td>
<td><p>the main memory consumption </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_KeywordTokenStream__1_System_Collections_Generic_ICollection___0__.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.KeywordTokenStream%60%601(System.Collections.Generic.ICollection%7B%60%600%7D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L271">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_KeywordTokenStream_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.KeywordTokenStream*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_KeywordTokenStream__1_System_Collections_Generic_ICollection___0__" data-uid="Lucene.Net.Index.Memory.MemoryIndex.KeywordTokenStream``1(System.Collections.Generic.ICollection{``0})">KeywordTokenStream&lt;T&gt;(ICollection&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Convenience method; Creates and returns a token stream that generates a
token for each keyword in the given collection, &quot;as is&quot;, without any
transforming text analysis. The resulting token stream can be fed into
<a class="xref" href="Lucene.Net.Index.Memory.MemoryIndex.html#Lucene_Net_Index_Memory_MemoryIndex_AddField_System_String_Lucene_Net_Analysis_TokenStream_">AddField(String, TokenStream)</a>, perhaps wrapped into another
<a class="xref" href="http://localhost:8080/api/core/Lucene.Net.Analysis.TokenFilter.html">TokenFilter</a>, as desired.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual TokenStream KeywordTokenStream&lt;T&gt;(ICollection&lt;T&gt; keywords)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Collections.Generic.ICollection</span>&lt;T&gt;</td>
<td><span class="parametername">keywords</span></td>
<td><p>the keywords to generate tokens for </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">Lucene.Net.Analysis.TokenStream</span></td>
<td><p>the corresponding token stream </p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_Reset.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.Reset%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L716">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_Reset_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.Reset*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_Reset" data-uid="Lucene.Net.Index.Memory.MemoryIndex.Reset">Reset()</h4>
<div class="markdown level1 summary"><p>Resets the <a class="xref" href="Lucene.Net.Index.Memory.MemoryIndex.html">MemoryIndex</a> to its initial state and recycles all internal buffers.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void Reset()</code></pre>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_Search_Lucene_Net_Search_Query_.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.Search(Lucene.Net.Search.Query)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L531">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_Search_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.Search*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_Search_Lucene_Net_Search_Query_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.Search(Lucene.Net.Search.Query)">Search(Query)</h4>
<div class="markdown level1 summary"><p>Convenience method that efficiently returns the relevance score by
matching this index against the given Lucene query expression.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual float Search(Query query)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">Lucene.Net.Search.Query</span></td>
<td><span class="parametername">query</span></td>
<td><p>an arbitrary Lucene query to run against this index </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>the relevance score of the matchmaking; A number in the range
[0.0 .. 1.0], with 0.0 indicating no match. The higher the number
the better the match.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex_ToString.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex.ToString%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.cs/#L648">View Source</a>
</span>
<a id="Lucene_Net_Index_Memory_MemoryIndex_ToString_" data-uid="Lucene.Net.Index.Memory.MemoryIndex.ToString*"></a>
<h4 id="Lucene_Net_Index_Memory_MemoryIndex_ToString" data-uid="Lucene.Net.Index.Memory.MemoryIndex.ToString">ToString()</h4>
<div class="markdown level1 summary"><p>Returns a String representation of the index data for debugging purposes.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public override string ToString()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><p>the string representation </p>
</td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><span class="xref">System.Object.ToString()</span></div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Index_Memory_MemoryIndex.md&amp;value=---%0Auid%3A%20Lucene.Net.Index.Memory.MemoryIndex%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/apache/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net.Memory/MemoryIndex.TermComparer.cs/#L27" class="contribution-link">View Source</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
Copyright © 2020 Licensed to the Apache Software Foundation (ASF)
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.js"></script>
</body>
</html>