本文整理汇总了C#中Lucene.Net.Index.IndexReader类的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.IndexReader类的具体用法?C# Lucene.Net.Index.IndexReader怎么用?C# Lucene.Net.Index.IndexReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lucene.Net.Index.IndexReader类属于命名空间,在下文中一共展示了Lucene.Net.Index.IndexReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public override void SetUp()
{
base.SetUp();
RAMDirectory directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
long theLong = System.Int64.MaxValue;
double theDouble = System.Double.MaxValue;
sbyte theByte = (sbyte) System.SByte.MaxValue;
short theShort = System.Int16.MaxValue;
int theInt = System.Int32.MaxValue;
float theFloat = System.Single.MaxValue;
for (int i = 0; i < NUM_DOCS; i++)
{
Document doc = new Document();
doc.Add(new Field("theLong", System.Convert.ToString(theLong--), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.Add(new Field("theDouble", (theDouble--).ToString("E16"), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.Add(new Field("theByte", System.Convert.ToString((sbyte) theByte--), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.Add(new Field("theShort", System.Convert.ToString(theShort--), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.Add(new Field("theInt", System.Convert.ToString(theInt--), Field.Store.NO, Field.Index.NOT_ANALYZED));
doc.Add(new Field("theFloat", (theFloat--).ToString("E8"), Field.Store.NO, Field.Index.NOT_ANALYZED));
writer.AddDocument(doc);
}
writer.Close();
reader = IndexReader.Open(directory);
}
示例2: Bits
public override System.Collections.BitArray Bits(IndexReader reader)
{
System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
bitset.Set(1, true);
bitset.Set(3, true);
return bitset;
}
示例3: GetDocIdSet
public override DocIdSet GetDocIdSet(IndexReader reader)
{
System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
bitset.Set(1, true);
bitset.Set(3, true);
return new DocIdBitSet(bitset);
}
示例4: GetDocIdSet
public override DocIdSet GetDocIdSet(IndexReader reader)
{
if (cache == null)
{
cache = new System.Collections.Hashtable();
}
lock (cache.SyncRoot)
{
// check cache
DocIdSet cached = (DocIdSet) cache[reader];
if (shouldHaveCache)
{
Assert.IsNotNull(cached, "Cache should have data ");
}
else
{
Assert.IsNotNull( cached, "Cache should be null " + cached);
}
if (cached != null)
{
return cached;
}
}
DocIdSet bits = filter.GetDocIdSet(reader);
lock (cache.SyncRoot)
{
// update cache
cache[reader] = bits;
}
return bits;
}
示例5: SubReader
/// <summary> Returns sub-reader subIndex from reader.
///
/// </summary>
/// <param name="reader">parent reader
/// </param>
/// <param name="subIndex">index of desired sub reader
/// </param>
/// <returns> the subreader at subINdex
/// </returns>
public static IndexReader SubReader(IndexReader reader, int subIndex)
{
var subReadersList = new System.Collections.Generic.List<IndexReader>();
ReaderUtil.GatherSubReaders(subReadersList, reader);
IndexReader[] subReaders = subReadersList.ToArray();
return subReaders[subIndex];
}
示例6: Rewrite
public override Query Rewrite(IndexReader reader)
{
Query orig = new RegexQuery(term).Rewrite(reader);
// RegexQuery (via MultiTermQuery).rewrite always returns a BooleanQuery
BooleanQuery bq = (BooleanQuery) orig;
BooleanClause[] clauses = bq.GetClauses();
SpanQuery[] sqs = new SpanQuery[clauses.Length];
for (int i = 0; i < clauses.Length; i++)
{
BooleanClause clause = clauses[i];
// Clauses from RegexQuery.rewrite are always TermQuery's
TermQuery tq = (TermQuery) clause.GetQuery();
sqs[i] = new SpanTermQuery(tq.GetTerm());
sqs[i].SetBoost(tq.GetBoost());
}
SpanOrQuery query = new SpanOrQuery(sqs);
query.SetBoost(orig.GetBoost());
return query;
}
示例7: Rewrite
public override Query Rewrite(IndexReader reader)
{
if (!termContainsWildcard)
return new TermQuery(GetTerm());
else
return base.Rewrite(reader);
}
示例8: Bits
public override System.Collections.BitArray Bits(IndexReader reader)
{
if (cache == null)
{
cache = new System.Collections.Hashtable();
}
lock (cache.SyncRoot)
{
// check cache
System.Collections.BitArray cached = (System.Collections.BitArray) cache[reader];
if (cached != null)
{
return cached;
}
}
System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
new IndexSearcher(reader).Search(query, new AnonymousClassHitCollector(bits, this));
lock (cache.SyncRoot)
{
// update cache
cache[reader] = bits;
}
return bits;
}
示例9: Rewrite
public override Query Rewrite(IndexReader reader)
{
BooleanQuery query = new BooleanQuery(true);
TermEnum enumerator = reader.Terms(prefix);
try
{
System.String prefixText = prefix.Text();
System.String prefixField = prefix.Field();
do
{
Term term = enumerator.Term();
if (term != null && term.Text().StartsWith(prefixText) && term.Field() == prefixField)
{
TermQuery tq = new TermQuery(term); // found a match
tq.SetBoost(GetBoost()); // set the boost
query.Add(tq, BooleanClause.Occur.SHOULD); // add to query
//System.out.println("added " + term);
}
else
{
break;
}
}
while (enumerator.Next());
}
finally
{
enumerator.Close();
}
return query;
}
示例10: Bits
public override System.Collections.BitArray Bits(IndexReader reader)
{
System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0 ? reader.MaxDoc() / 64 : reader.MaxDoc() / 64 + 1) * 64);
new IndexSearcher(reader).Search(query, new AnonymousClassHitCollector(bits, this));
return bits;
}
示例11: Purge
public void Purge(IndexReader r)
{
foreach (Cache c in caches.Values)
{
c.Purge(r);
}
}
示例12: NewComparator
// inherit javadocs
public virtual ScoreDocComparator NewComparator(IndexReader reader, System.String fieldname)
{
System.String field = String.Intern(fieldname);
System.IComparable[] cachedValues = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetCustom(reader, field, this);
return new AnonymousClassScoreDocComparator(cachedValues, this);
}
示例13: SetUp
public override void SetUp()
{
base.SetUp();
PayloadHelper helper = new PayloadHelper();
searcher = helper.SetUp(similarity, 1000);
indexReader = searcher.GetIndexReader();
}
示例14: CreateValue
protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
{
Entry entry = (Entry) entryKey;
System.String field = entry.field;
LongParser parser = (LongParser) entry.custom;
long[] retArray = new long[reader.MaxDoc()];
TermDocs termDocs = reader.TermDocs();
TermEnum termEnum = reader.Terms(new Term(field, ""));
try
{
do
{
Term term = termEnum.Term();
if (term == null || (System.Object) term.Field() != (System.Object) field)
break;
long termval = parser.ParseLong(term.Text());
termDocs.Seek(termEnum);
while (termDocs.Next())
{
retArray[termDocs.Doc()] = termval;
}
}
while (termEnum.Next());
}
finally
{
termDocs.Close();
termEnum.Close();
}
return retArray;
}
示例15: MatchAllScorer
internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
{
InitBlock(enclosingInstance);
this.termDocs = reader.TermDocs(null);
score = w.GetValue();
this.norms = norms;
}