• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Index.IndexReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.Lucene.Net.Index.IndexReader的典型用法代码示例。如果您正苦于以下问题:C# Mono.Lucene.Net.Index.IndexReader类的具体用法?C# Mono.Lucene.Net.Index.IndexReader怎么用?C# Mono.Lucene.Net.Index.IndexReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mono.Lucene.Net.Index.IndexReader类属于命名空间,在下文中一共展示了Mono.Lucene.Net.Index.IndexReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TermRangeTermEnum

		/// <summary> Enumerates all terms greater/equal than <code>lowerTerm</code>
		/// but less/equal than <code>upperTerm</code>. 
		/// 
		/// If an endpoint is null, it is said to be "open". Either or both 
		/// endpoints may be open.  Open endpoints may not be exclusive 
		/// (you can't select all but the first or last term without 
		/// explicitly specifying the term to exclude.)
		/// 
		/// </summary>
		/// <param name="reader">
		/// </param>
		/// <param name="field">An interned field that holds both lower and upper terms.
		/// </param>
		/// <param name="lowerTermText">The term text at the lower end of the range
		/// </param>
		/// <param name="upperTermText">The term text at the upper end of the range
		/// </param>
		/// <param name="includeLower">If true, the <code>lowerTerm</code> is included in the range.
		/// </param>
		/// <param name="includeUpper">If true, the <code>upperTerm</code> is included in the range.
		/// </param>
		/// <param name="collator">The collator to use to collate index Terms, to determine their
		/// membership in the range bounded by <code>lowerTerm</code> and
		/// <code>upperTerm</code>.
		/// 
		/// </param>
		/// <throws>  IOException </throws>
		public TermRangeTermEnum(IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
		{
			this.collator = collator;
			this.upperTermText = upperTermText;
			this.lowerTermText = lowerTermText;
			this.includeLower = includeLower;
			this.includeUpper = includeUpper;
			this.field = StringHelper.Intern(field);
			
			// do a little bit of normalization...
			// open ended range queries should always be inclusive.
			if (this.lowerTermText == null)
			{
				this.lowerTermText = "";
				this.includeLower = true;
			}
			
			if (this.upperTermText == null)
			{
				this.includeUpper = true;
			}
			
			System.String startTermText = collator == null?this.lowerTermText:"";
			SetEnum(reader.Terms(new Term(this.field, startTermText)));
		}
开发者ID:carrie901,项目名称:mono,代码行数:52,代码来源:TermRangeTermEnum.cs


示例2: 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;
			}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:MatchAllDocsQuery.cs


示例3: Purge

 public void Purge(IndexReader r)
 {
     foreach (Cache c in caches.Values)
     {
         c.Purge(r);
     }
 }
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:FieldCacheImpl.cs


示例4: Rewrite

		public override Query Rewrite(IndexReader reader)
		{
			if (!termContainsWildcard)
				return new TermQuery(GetTerm());
			else
				return base.Rewrite(reader);
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:WildcardQuery.cs


示例5: Explain

		public override Explanation Explain(IndexReader reader, int doc)
		{
			
			ComplexExplanation result = new ComplexExplanation();
			result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
			System.String field = ((SpanQuery) GetQuery()).GetField();
			
			Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + idfExp.Explain() + ")");
			
			// explain query weight
			Explanation queryExpl = new Explanation();
			queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
			
			Explanation boostExpl = new Explanation(GetQuery().GetBoost(), "boost");
			if (GetQuery().GetBoost() != 1.0f)
				queryExpl.AddDetail(boostExpl);
			queryExpl.AddDetail(idfExpl);
			
			Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
			queryExpl.AddDetail(queryNormExpl);
			
			queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
			
			result.AddDetail(queryExpl);
			
			// explain field weight
			ComplexExplanation fieldExpl = new ComplexExplanation();
			fieldExpl.SetDescription("fieldWeight(" + field + ":" + query.ToString(field) + " in " + doc + "), product of:");
			
			Explanation tfExpl = Scorer(reader, true, false).Explain(doc);
			fieldExpl.AddDetail(tfExpl);
			fieldExpl.AddDetail(idfExpl);
			
			Explanation fieldNormExpl = new Explanation();
			byte[] fieldNorms = reader.Norms(field);
			float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
			fieldNormExpl.SetValue(fieldNorm);
			fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
			fieldExpl.AddDetail(fieldNormExpl);
			
			fieldExpl.SetMatch(tfExpl.IsMatch());
			fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
			
			result.AddDetail(fieldExpl);
			System.Boolean? tempAux = fieldExpl.GetMatch();
			result.SetMatch(tempAux);
			
			// combine them
			result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
			
			if (queryExpl.GetValue() == 1.0f)
				return fieldExpl;
			
			return result;
		}
开发者ID:carrie901,项目名称:mono,代码行数:55,代码来源:SpanWeight.cs


示例6: SubReader

		/// <summary> Returns sub IndexReader that contains the given document id.
		/// 
		/// </summary>
		/// <param name="doc">id of document
		/// </param>
		/// <param name="reader">parent reader
		/// </param>
		/// <returns> sub reader of parent which contains the specified doc id
		/// </returns>
		public static IndexReader SubReader(int doc, IndexReader reader)
		{
			System.Collections.ArrayList subReadersList = new System.Collections.ArrayList();
			ReaderUtil.GatherSubReaders(subReadersList, reader);
			IndexReader[] subReaders = (IndexReader[]) subReadersList.ToArray(typeof(IndexReader));
			int[] docStarts = new int[subReaders.Length];
			int maxDoc = 0;
			for (int i = 0; i < subReaders.Length; i++)
			{
				docStarts[i] = maxDoc;
				maxDoc += subReaders[i].MaxDoc();
			}
			return subReaders[ReaderUtil.SubIndex(doc, docStarts)];
		}
开发者ID:carrie901,项目名称:mono,代码行数:23,代码来源:ReaderUtil.cs


示例7: GetValues

		public override DocValues GetValues(IndexReader reader)
		{
			
			IndexReader[] subReaders = reader.GetSequentialSubReaders();
			if (subReaders != null)
			{
				// This is a composite reader
				return new MultiDocValues(this, subReaders);
			}
			else
			{
				// Already an atomic reader -- just delegate
				return other.GetValues(reader);
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:15,代码来源:MultiValueSource.cs


示例8: GatherSubReaders

		/// <summary> Gathers sub-readers from reader into a List.
		/// 
		/// </summary>
		/// <param name="allSubReaders">
		/// </param>
		/// <param name="reader">
		/// </param>
		public static void  GatherSubReaders(System.Collections.IList allSubReaders, IndexReader reader)
		{
			IndexReader[] subReaders = reader.GetSequentialSubReaders();
			if (subReaders == null)
			{
				// Add the reader itself, and do not recurse
				allSubReaders.Add(reader);
			}
			else
			{
				for (int i = 0; i < subReaders.Length; i++)
				{
					GatherSubReaders(allSubReaders, subReaders[i]);
				}
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:23,代码来源:ReaderUtil.cs


示例9: BitSpans

		public override SpanFilterResult BitSpans(IndexReader reader)
		{
			
			OpenBitSet bits = new OpenBitSet(reader.MaxDoc());
			Mono.Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader);
			System.Collections.IList tmp = new System.Collections.ArrayList(20);
			int currentDoc = - 1;
			SpanFilterResult.PositionInfo currentInfo = null;
			while (spans.Next())
			{
				int doc = spans.Doc();
				bits.Set(doc);
				if (currentDoc != doc)
				{
					currentInfo = new SpanFilterResult.PositionInfo(doc);
					tmp.Add(currentInfo);
					currentDoc = doc;
				}
				currentInfo.AddPosition(spans.Start(), spans.End());
			}
			return new SpanFilterResult(bits, tmp);
		}
开发者ID:carrie901,项目名称:mono,代码行数:22,代码来源:SpanQueryFilter.cs


示例10: WildcardTermEnum

		/// <summary> Creates a new <code>WildcardTermEnum</code>.
		/// <p/>
		/// After calling the constructor the enumeration is already pointing to the first 
		/// valid term if such a term exists.
		/// </summary>
		public WildcardTermEnum(IndexReader reader, Term term):base()
		{
			searchTerm = term;
			field = searchTerm.Field();
			System.String searchTermText = searchTerm.Text();
			
			int sidx = searchTermText.IndexOf((System.Char) WILDCARD_STRING);
			int cidx = searchTermText.IndexOf((System.Char) WILDCARD_CHAR);
			int idx = sidx;
			if (idx == - 1)
			{
				idx = cidx;
			}
			else if (cidx >= 0)
			{
				idx = System.Math.Min(idx, cidx);
			}
			pre = idx != - 1?searchTerm.Text().Substring(0, (idx) - (0)):"";
			
			preLen = pre.Length;
			text = searchTermText.Substring(preLen);
			SetEnum(reader.Terms(new Term(searchTerm.Field(), pre)));
		}
开发者ID:carrie901,项目名称:mono,代码行数:28,代码来源:WildcardTermEnum.cs


示例11: comparatorDouble

		/// <summary> Returns a comparator for sorting hits according to a field containing doubles.</summary>
		/// <param name="reader"> Index to use.
		/// </param>
		/// <param name="fieldname"> Fieldable containing float values.
		/// </param>
		/// <returns>  Comparator for sorting hits.
		/// </returns>
		/// <throws>  IOException If an error occurs reading the index. </throws>
		internal static ScoreDocComparator comparatorDouble(IndexReader reader, System.String fieldname, Mono.Lucene.Net.Search.DoubleParser parser)
		{
			System.String field = String.Intern(fieldname);
			double[] fieldOrder = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetDoubles(reader, field, parser);
			return new AnonymousClassScoreDocComparator5(fieldOrder);
		}
开发者ID:carrie901,项目名称:mono,代码行数:14,代码来源:FieldSortedHitQueue.cs


示例12: comparatorFloat

		/// <summary> Returns a comparator for sorting hits according to a field containing floats.</summary>
		/// <param name="reader"> Index to use.
		/// </param>
		/// <param name="fieldname"> Fieldable containing float values.
		/// </param>
		/// <returns>  Comparator for sorting hits.
		/// </returns>
		/// <throws>  IOException If an error occurs reading the index. </throws>
		internal static ScoreDocComparator comparatorFloat(IndexReader reader, System.String fieldname, Mono.Lucene.Net.Search.FloatParser parser)
		{
			System.String field = String.Intern(fieldname);
			float[] fieldOrder = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetFloats(reader, field, parser);
			return new AnonymousClassScoreDocComparator4(fieldOrder);
		}
开发者ID:carrie901,项目名称:mono,代码行数:14,代码来源:FieldSortedHitQueue.cs


示例13: GetSpans

		public override Spans GetSpans(IndexReader reader)
		{
			return new AnonymousClassSpans(reader, this);
		}
开发者ID:carrie901,项目名称:mono,代码行数:4,代码来源:SpanFirstQuery.cs


示例14: Rewrite

		public override Query Rewrite(IndexReader reader)
		{
			if (!termLongEnough)
			{
				// can only match if it's exact
				return new TermQuery(term);
			}
			
			FilteredTermEnum enumerator = GetEnum(reader);
			int maxClauseCount = BooleanQuery.GetMaxClauseCount();
			ScoreTermQueue stQueue = new ScoreTermQueue(maxClauseCount);
			ScoreTerm reusableST = null;
			
			try
			{
				do 
				{
					float score = 0.0f;
					Term t = enumerator.Term();
					if (t != null)
					{
						score = enumerator.Difference();
						if (reusableST == null)
						{
							reusableST = new ScoreTerm(t, score);
						}
						else if (score >= reusableST.score)
						{
							// reusableST holds the last "rejected" entry, so, if
							// this new score is not better than that, there's no
							// need to try inserting it
							reusableST.score = score;
							reusableST.term = t;
						}
						else
						{
							continue;
						}
						
						reusableST = (ScoreTerm) stQueue.InsertWithOverflow(reusableST);
					}
				}
				while (enumerator.Next());
			}
			finally
			{
				enumerator.Close();
			}
			
			BooleanQuery query = new BooleanQuery(true);
			int size = stQueue.Size();
			for (int i = 0; i < size; i++)
			{
				ScoreTerm st = (ScoreTerm) stQueue.Pop();
				TermQuery tq = new TermQuery(st.term); // found a match
				tq.SetBoost(GetBoost() * st.score); // set the boost
				query.Add(tq, BooleanClause.Occur.SHOULD); // add to query
			}
			
			return query;
		}
开发者ID:carrie901,项目名称:mono,代码行数:61,代码来源:FuzzyQuery.cs


示例15: Rewrite

		/// <summary>Optimize our representation and our subqueries representations</summary>
		/// <param name="reader">the IndexReader we query
		/// </param>
		/// <returns> an optimized copy of us (which may not be a copy if there is nothing to optimize) 
		/// </returns>
		public override Query Rewrite(IndexReader reader)
		{
			int numDisjunctions = disjuncts.Count;
			if (numDisjunctions == 1)
			{
				Query singleton = (Query) disjuncts[0];
				Query result = singleton.Rewrite(reader);
				if (GetBoost() != 1.0f)
				{
					if (result == singleton)
						result = (Query) result.Clone();
					result.SetBoost(GetBoost() * result.GetBoost());
				}
				return result;
			}
			DisjunctionMaxQuery clone = null;
			for (int i = 0; i < numDisjunctions; i++)
			{
				Query clause = (Query) disjuncts[i];
				Query rewrite = clause.Rewrite(reader);
				if (rewrite != clause)
				{
					if (clone == null)
						clone = (DisjunctionMaxQuery) this.Clone();
					clone.disjuncts[i] = rewrite;
				}
			}
			if (clone != null)
				return clone;
			else
				return this;
		}
开发者ID:carrie901,项目名称:mono,代码行数:37,代码来源:DisjunctionMaxQuery.cs


示例16: Scorer

			/* Create the scorer used to score our associated DisjunctionMaxQuery */
			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
			{
				Scorer[] scorers = new Scorer[weights.Count];
				int idx = 0;
				for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
				{
					Weight w = (Weight) iter.Current;
					Scorer subScorer = w.Scorer(reader, true, false);
					if (subScorer != null && subScorer.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
					{
						scorers[idx++] = subScorer;
					}
				}
				if (idx == 0)
					return null; // all scorers did not have documents
				DisjunctionMaxScorer result = new DisjunctionMaxScorer(Enclosing_Instance.tieBreakerMultiplier, similarity, scorers, idx);
				return result;
			}
开发者ID:carrie901,项目名称:mono,代码行数:19,代码来源:DisjunctionMaxQuery.cs


示例17: ComparatorAuto

		/// <summary> Returns a comparator for sorting hits according to values in the given field.
		/// The terms in the field are looked at to determine whether they contain integers,
		/// floats or strings.  Once the type is determined, one of the other static methods
		/// in this class is called to get the comparator.
		/// </summary>
		/// <param name="reader"> Index to use.
		/// </param>
		/// <param name="fieldname"> Fieldable containing values.
		/// </param>
		/// <returns>  Comparator for sorting hits.
		/// </returns>
		/// <throws>  IOException If an error occurs reading the index. </throws>
		internal static ScoreDocComparator ComparatorAuto(IndexReader reader, System.String fieldname)
		{
			System.String field = String.Intern(fieldname);
			System.Object lookupArray = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetAuto(reader, field);
			if (lookupArray is Mono.Lucene.Net.Search.StringIndex)
			{
				return comparatorString(reader, field);
			}
			else if (lookupArray is int[])
			{
				return comparatorInt(reader, field, null);
			}
			else if (lookupArray is long[])
			{
				return comparatorLong(reader, field, null);
			}
			else if (lookupArray is float[])
			{
				return comparatorFloat(reader, field, null);
			}
			else if (lookupArray is System.String[])
			{
				return comparatorString(reader, field);
			}
			else
			{
				throw new System.SystemException("unknown data type in field '" + field + "'");
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:41,代码来源:FieldSortedHitQueue.cs


示例18: comparatorString

		/// <summary> Returns a comparator for sorting hits according to a field containing strings.</summary>
		/// <param name="reader"> Index to use.
		/// </param>
		/// <param name="fieldname"> Fieldable containing string values.
		/// </param>
		/// <returns>  Comparator for sorting hits.
		/// </returns>
		/// <throws>  IOException If an error occurs reading the index. </throws>
		internal static ScoreDocComparator comparatorString(IndexReader reader, System.String fieldname)
		{
			System.String field = String.Intern(fieldname);
			Mono.Lucene.Net.Search.StringIndex index = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field);
			return new AnonymousClassScoreDocComparator6(index);
		}
开发者ID:carrie901,项目名称:mono,代码行数:14,代码来源:FieldSortedHitQueue.cs


示例19: comparatorStringLocale

		/// <summary> Returns a comparator for sorting hits according to a field containing strings.</summary>
		/// <param name="reader"> Index to use.
		/// </param>
		/// <param name="fieldname"> Fieldable containing string values.
		/// </param>
		/// <returns>  Comparator for sorting hits.
		/// </returns>
		/// <throws>  IOException If an error occurs reading the index. </throws>
		internal static ScoreDocComparator comparatorStringLocale(IndexReader reader, System.String fieldname, System.Globalization.CultureInfo locale)
		{
			System.Globalization.CompareInfo collator = locale.CompareInfo;
			System.String field = String.Intern(fieldname);
			System.String[] index = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStrings(reader, field);
			return new AnonymousClassScoreDocComparator7(index, collator);
		}
开发者ID:carrie901,项目名称:mono,代码行数:15,代码来源:FieldSortedHitQueue.cs


示例20: GetSpans

		public override Spans GetSpans(IndexReader reader)
		{
			if (clauses.Count == 1)
			// optimize 1-clause case
				return ((SpanQuery) clauses[0]).GetSpans(reader);
			
			return new AnonymousClassSpans(reader, this);
		}
开发者ID:carrie901,项目名称:mono,代码行数:8,代码来源:SpanOrQuery.cs



注:本文中的Mono.Lucene.Net.Index.IndexReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextEditor.TextEditorData类代码示例发布时间:2022-05-24
下一篇:
C# Mono类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap