当前位置: 首页>>代码示例>>C#>>正文


C# Index.IndexReader类代码示例

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


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

示例1: LuceneSearchResults

 /// <summary>
 ///     Initializes a new instance of the <see cref="SearchResults" /> class.
 /// </summary>
 /// <param name="searcher">The searcher.</param>
 /// <param name="reader">The reader.</param>
 /// <param name="docs">The hits.</param>
 /// <param name="criteria">The criteria.</param>
 /// <param name="query">The query.</param>
 public LuceneSearchResults(Searcher searcher, IndexReader reader, TopDocs docs, ISearchCriteria criteria, Query query)
 {
     Results = new SearchResults(criteria, null);
     CreateDocuments(searcher, docs);
     CreateFacets(reader, query);
     CreateSuggestions(reader, criteria);
 }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:15,代码来源:LuceneSearchResults.cs

示例2: SegmentMergeInfo

		internal SegmentMergeInfo(int b, TermEnum te, IndexReader r)
		{
			base_Renamed = b;
			reader = r;
			termEnum = te;
			term = te.Term;
		}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:7,代码来源:SegmentMergeInfo.cs

示例3: Rewrite

        public override Query Rewrite(IndexReader reader)
        {
            CustomScoreQuery clone = null;

            Query sq = subQuery.Rewrite(reader);
            if (sq != subQuery)
            {
                clone = (CustomScoreQuery)Clone();
                clone.subQuery = sq;
            }

            for (int i = 0; i < scoringQueries.Length; i++)
            {
                Query v = scoringQueries[i].Rewrite(reader);
                if (v != scoringQueries[i])
                {
                    if (clone == null)
                    {
                        clone = (CustomScoreQuery)Clone();
                    }
                    clone.scoringQueries[i] = v;
                }
            }

            return clone ?? this;
        }
开发者ID:eladmarg,项目名称:lucene.net,代码行数:26,代码来源:CustomScoreQuery.cs

示例4: MatchAllScorer

			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.termDocs = reader.TermDocs(null);
				score = w.Value;
				this.norms = norms;
			}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:7,代码来源:MatchAllDocsQuery.cs

示例5: VerifyCount

 private void VerifyCount(IndexReader ir)
 {
     Fields fields = MultiFields.GetFields(ir);
     if (fields == null)
     {
         return;
     }
     foreach (string field in fields)
     {
         Terms terms = fields.Terms(field);
         if (terms == null)
         {
             continue;
         }
         int docCount = terms.DocCount;
         FixedBitSet visited = new FixedBitSet(ir.MaxDoc);
         TermsEnum te = terms.Iterator(null);
         while (te.Next() != null)
         {
             DocsEnum de = TestUtil.Docs(Random(), te, null, null, DocsEnum.FLAG_NONE);
             while (de.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
             {
                 visited.Set(de.DocID());
             }
         }
         Assert.AreEqual(visited.Cardinality(), docCount);
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:28,代码来源:TestDocCount.cs

示例6: Query

		public SuggestionQueryResult Query(SuggestionQuery suggestionQuery, IndexReader indexReader)
		{
			if (suggestionQuery.Accuracy.HasValue == false)
				throw new InvalidOperationException("SuggestionQuery.Accuracy must be specified.");

			if (suggestionQuery.Distance.HasValue == false)
				throw new InvalidOperationException("SuggestionQuery.Distance must be specified.");

			spellChecker.setStringDistance(SuggestionQueryRunner.GetStringDistance(suggestionQuery.Distance.Value));
			spellChecker.SetAccuracy(suggestionQuery.Accuracy.Value);

			if (suggestionQuery.Term.StartsWith("<<") && suggestionQuery.Term.EndsWith(">>"))
			{
				return QueryOverMultipleWords(suggestionQuery, indexReader,
					suggestionQuery.Term.Substring(2, suggestionQuery.Term.Length - 4));
			}
			if (suggestionQuery.Term.StartsWith("(") && suggestionQuery.Term.EndsWith(")"))
			{
				return QueryOverMultipleWords(suggestionQuery, indexReader,
					suggestionQuery.Term.Substring(1, suggestionQuery.Term.Length - 2));
			}
			string[] suggestions = spellChecker.SuggestSimilar(suggestionQuery.Term,
															   suggestionQuery.MaxSuggestions,
															   indexReader,
															   suggestionQuery.Field,
															   true);

			return new SuggestionQueryResult
			{
				Suggestions = suggestions
			};
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:32,代码来源:SuggestionQueryIndexExtension.cs

示例7: GetSearchFields

				/// <summary>
				/// Returns a list of fields to search on
				/// </summary>
				/// <returns></returns>
				protected static string[] GetSearchFields(IndexReader reader)
				{
						//exclude the special index fields
						return reader.GetFieldNames(IndexReader.FieldOption.ALL)
								.Where(x => !x.StartsWith(LuceneIndexer.SpecialFieldPrefix))
								.ToArray();
				}
开发者ID:uniquelau,项目名称:vdb.UmbracoExtensions,代码行数:11,代码来源:LuceneSearcher.cs

示例8: GetValues

        public override DocValues GetValues(IndexReader reader)
        {
            var @base = 0; //reader.DocBase;
            var vals = source.GetValues(reader);
            return new CachingDoubleDocValue(@base, vals, cache);

        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:7,代码来源:CachingDoubleValueSource.cs

示例9: CreateScorer

     public virtual Scorer CreateScorer(Scorer innerScorer, IndexReader reader, bool scoreDocsInOrder, bool topScorer)
     {
         if(!(reader is BoboIndexReader)) 
             throw new ArgumentException("IndexReader is not BoboIndexReader");
 
         return new FacetBasedBoostingScorer(this, (BoboIndexReader)reader, innerScorer.Similarity, innerScorer);
     }
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:7,代码来源:FacetBasedBoostScorerBuilder.cs

示例10: Explain

        public virtual Explanation Explain(IndexReader indexReader, int docid, Explanation innerExplaination)
        {
            if (!(indexReader is BoboIndexReader)) throw new ArgumentException("IndexReader is not BoboIndexReader");
            BoboIndexReader reader = (BoboIndexReader)indexReader;

            Explanation exp = new Explanation();
            exp.Description = "FacetBasedBoost";

            float boost = 1.0f;
            foreach (var boostEntry in _boostMaps)
            {
                string facetName = boostEntry.Key;
                IFacetHandler handler = reader.GetFacetHandler(facetName);
                if (!(handler is IFacetScoreable))
                    throw new ArgumentException(facetName + " does not implement IFacetScoreable");

                IFacetScoreable facetScoreable = (IFacetScoreable)handler;
                BoboDocScorer scorer = facetScoreable.GetDocScorer(reader, _scoringFunctionFactory, boostEntry.Value);
                float facetBoost = scorer.Score(docid);

                Explanation facetExp = new Explanation();
                facetExp.Description = facetName;
                facetExp.Value = facetBoost;
                facetExp.AddDetail(scorer.Explain(docid));
                boost *= facetBoost;
                exp.AddDetail(facetExp);
            }
            exp.Value = boost;
            exp.AddDetail(innerExplaination);
            return exp;
        }
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:31,代码来源:FacetBasedBoostScorerBuilder.cs

示例11: ReadCommitUserData

        internal static CommitUserData ReadCommitUserData(IndexReader reader)
        {
            int lastActivityId = 0;
            var gap = new List<int>();

            var cud = reader.GetCommitUserData();
            if (cud != null)
            {
                if (cud.ContainsKey(IndexManager.LastActivityIdKey))
                {
                    var lastID = cud[IndexManager.LastActivityIdKey];
                    if (!string.IsNullOrEmpty(lastID))
                        int.TryParse(lastID, out lastActivityId);
                }
                if (cud.ContainsKey(IndexManager.MissingActivitiesKey))
                {
                    var gapstring = cud[IndexManager.MissingActivitiesKey];
                    int g;
                    if (!string.IsNullOrEmpty(gapstring))
                        foreach (var s in gapstring.Split(','))
                            if (Int32.TryParse(s, out g))
                                gap.Add(g);
                }
            }
            return new CommitUserData { LastActivityId = lastActivityId, Gap = gap };
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:26,代码来源:IndexManager.cs

示例12: CreateBitSet

 public static OpenBitSet CreateBitSet(IndexReader reader, Filter filter)
 {
     IndexSearcher searcher = new IndexSearcher(reader);
     OpenBitSet result = new OpenBitSet();
     searcher.Search(new MatchAllDocsQuery(), filter, new BitSetCollector(result));
     return result;
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:BitSetCollector.cs

示例13: Process

        public void Process(IndexReader indexReader,
            string readerName,
            int perSegmentDocumentNumber,
            int perIndexDocumentNumber,
            Document document,
            string id,
            NuGetVersion version)
        {
            // main index docid
            if (id == null || version == null)
            {
                return;
            }

            List<RegistrationEntry> versions;
            if (!_registrations.TryGetValue(id, out versions))
            {
                versions = new List<RegistrationEntry>();
                _registrations.Add(id, versions);
            }

            var entry = new RegistrationEntry(perIndexDocumentNumber, version, GetListed(document));

            versions.Add(entry);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:25,代码来源:VersionsHandler.cs

示例14: Add

		/// <summary>Add an IndexReader whose stored fields will not be returned.  This can
		/// accellerate search when stored fields are only needed from a subset of
		/// the IndexReaders.
		/// 
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes contain the same number  </throws>
		/// <summary>     of documents
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes have the same value  </throws>
		/// <summary>     of {@link IndexReader#MaxDoc()}
		/// </summary>
		public virtual void  Add(IndexReader reader, bool ignoreStoredFields)
		{
			
			if (readers.Count == 0)
			{
				this.maxDoc = reader.MaxDoc();
				this.numDocs = reader.NumDocs();
				this.hasDeletions = reader.HasDeletions();
			}
			
			if (reader.MaxDoc() != maxDoc)
			// check compatibility
				throw new System.ArgumentException("All readers must have same maxDoc: " + maxDoc + "!=" + reader.MaxDoc());
			if (reader.NumDocs() != numDocs)
				throw new System.ArgumentException("All readers must have same numDocs: " + numDocs + "!=" + reader.NumDocs());
			
			System.Collections.IEnumerator i = reader.GetFieldNames(IndexReader.FieldOption.ALL).GetEnumerator();
			while (i.MoveNext())
			{
                System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) i.Current;

				// update fieldToReader map
				System.String field = fi.Key.ToString();
				if (fieldToReader[field] == null)
					fieldToReader[field] = reader;
			}
			
			if (!ignoreStoredFields)
				storedFieldReaders.Add(reader); // add to storedFieldReaders
			readers.Add(reader);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:42,代码来源:ParallelReader.cs

示例15: Bits

        public override BitArray Bits(IndexReader reader)
        {
            if (chainedFilters.Count == 0)
            {
                throw new AssertionFailure("ChainedFilter has no filters to chain for");
            }

            // We need to copy the first BitArray because BitArray is assigned to by And
            Filter filter = chainedFilters[0];
            BitArray result = (BitArray)filter.Bits(reader).Clone();
            int size = result.Count;
            for (int index = 1; index < chainedFilters.Count; index++ )
            {
                BitArray b2 = chainedFilters[index].Bits(reader);
                int s2 = b2.Count;
                if (s2 != size)
                {
                    // Align the lengths, any extra elements are set to false, ok as as we are Anding
                    b2.Length = size;
                }

                // Stared at this for hours - C# compiler doesn't warn when you discard a function result!
                result = result.And(b2);
            }

            return result;
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:27,代码来源:ChainedFilter.cs


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