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


C# Search.MatchAllDocsQuery类代码示例

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


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

示例1: MatchAllScorer

			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity) : base(similarity)
			{
				InitBlock(enclosingInstance);
				this.reader = reader;
				count = - 1;
				maxDoc = reader.MaxDoc();
			}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:7,代码来源:MatchAllDocsQuery.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.Value;
				this.norms = norms;
			}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:7,代码来源:MatchAllDocsQuery.cs

示例3: Query

		public string[] Query(string query, string[] sortFields, int start, int pageSize, out int totalResults)
		{
			IndexSearcher searcher;
			using (GetSearcher(out searcher))
			{
				Query q;
				if (string.IsNullOrEmpty(query))
				{
					q = new MatchAllDocsQuery();
				}
				else
				{
					var queryParser = new RavenQueryParser(analyzer, NumericIndexFields);
                    q = queryParser.Parse(query);
				}

				var topDocs = ExecuteQuery(searcher, sortFields, q, pageSize + start);

				var results = new List<string>();

				for (var i = start; i < pageSize + start && i < topDocs.TotalHits; i++)
				{
					var document = searcher.Doc(topDocs.ScoreDocs[i].Doc);
					results.Add(document.Get("__key"));
				}
				totalResults = topDocs.TotalHits;
				return results.ToArray();
			}
		}
开发者ID:felixmm,项目名称:ravendb,代码行数:29,代码来源:IndexStorage.cs

示例4: TestEquals

		public virtual void  TestEquals()
		{
			Query q1 = new MatchAllDocsQuery();
			Query q2 = new MatchAllDocsQuery();
			Assert.IsTrue(q1.Equals(q2));
			q1.SetBoost(1.5f);
			Assert.IsFalse(q1.Equals(q2));
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:8,代码来源:TestMatchAllDocsQuery.cs

示例5: MatchAllScorer

			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.reader = reader;
				id = - 1;
				maxId = reader.MaxDoc() - 1;
				score = w.GetValue();
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:8,代码来源:MatchAllDocsQuery.cs

示例6: MatchAllScorer

 internal MatchAllScorer(MatchAllDocsQuery outerInstance, IndexReader reader, Bits liveDocs, Weight w, float score)
     : base(w)
 {
     this.OuterInstance = outerInstance;
     this.LiveDocs = liveDocs;
     this.Score_Renamed = score;
     MaxDoc = reader.MaxDoc;
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:8,代码来源:MatchAllDocsQuery.cs

示例7: TestBasic

        public virtual void TestBasic()
        {
            Query q = new MatchAllDocsQuery();
            TopDocs docs = @is.Search(q, 10);
            assertEquals(1, docs.TotalHits);
            float score = docs.ScoreDocs[0].Score;

            Query boostedQ = new BoostedQuery(q, new ConstValueSource(2.0f));
            AssertHits(boostedQ, new float[] { score * 2 });
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:10,代码来源:TestBoostedQuery.cs

示例8: AssertFilterEquals

 private void AssertFilterEquals(Filter f1, Filter f2)
 {
     Query query = new MatchAllDocsQuery();
     TopDocs hits1 = @is.Search(query, f1, Ir.MaxDoc());
     TopDocs hits2 = @is.Search(query, f2, Ir.MaxDoc());
     Assert.AreEqual(hits1.TotalHits, hits2.TotalHits);
     CheckHits.CheckEqual(query, hits1.ScoreDocs, hits2.ScoreDocs);
     // now do it again to confirm caching works
     TopDocs hits3 = @is.Search(query, f1, Ir.MaxDoc());
     TopDocs hits4 = @is.Search(query, f2, Ir.MaxDoc());
     Assert.AreEqual(hits3.TotalHits, hits4.TotalHits);
     CheckHits.CheckEqual(query, hits3.ScoreDocs, hits4.ScoreDocs);
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:13,代码来源:TestCachingWrapperFilter.cs

示例9: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            CreateLuceneIndexFolder();
            string rebuildEvery = ConfigurationManager.AppSettings["RebuildLuceneIndexEveryXDays"];

            int rebuildEveryXDays = Convert.ToInt32(rebuildEvery);

            string path = HttpContext.Current.Server.MapPath("~/App_Data/LuceneIndex");
            try
            {
                FSDirectory fsd = FSDirectory.Open(new DirectoryInfo(path));
                var indexSearcher = new IndexSearcher(fsd, true);

                var termQuery = new MatchAllDocsQuery();
                var sort = new Sort(new SortField(LuceneIndexFieldMap.LastModifiedField, SortField.STRING));
                TopDocs topDocs = indexSearcher.Search(termQuery, null, 1, sort);
                DateTime lastUpdateDate = DateTime.MinValue;
                foreach (ScoreDoc match in topDocs.ScoreDocs)
                {
                    Document doc = indexSearcher.Doc(match.doc);
                    string lastUpdate = doc.Get(LuceneIndexFieldMap.LastModifiedField);

                    if (lastUpdate != null)
                    {
                        lastUpdateDate = DateTools.StringToDate(lastUpdate);
                        Debug.WriteLine(lastUpdate);
                    }
                }

                TimeSpan ts = DateTime.Now - lastUpdateDate;

                if (ts.TotalDays > rebuildEveryXDays)
                {
                    var generator = new DataGenerator(path);
                    generator.WriteIndex();
                }
            }
            catch (FileNotFoundException exception)
            {
                CreateLuceneIndexFolder();
                var generator = new DataGenerator(path);
                generator.WriteIndex();

            }
        }
开发者ID:davidpellerin,项目名称:LuceneExample,代码行数:49,代码来源:Global.asax.cs

示例10: GetTopics

 public virtual IEnumerable<Topic> GetTopics(TopicFilter topicFilter)
 {
     Query query;
     if (topicFilter.Tags != null && topicFilter.Tags.Any())
     {
         var booleanQuery = new BooleanQuery();
         foreach (var tag in topicFilter.Tags)
         {
             booleanQuery.Add(new TermQuery(new Term("Tags", tag)), Occur.MUST);
         }
         query = booleanQuery;
     }
     else
     {
         query = new MatchAllDocsQuery();
     }
     return _dbProvider.GetRecords<Topic>(query, n : 25);
 }
开发者ID:pranavkm,项目名称:topical,代码行数:18,代码来源:TopicService.cs

示例11: TestMissingTerms

		public virtual void  TestMissingTerms()
		{
			System.String fieldName = "field1";
			MockRAMDirectory rd = new MockRAMDirectory();
			IndexWriter w = new IndexWriter(rd, new KeywordAnalyzer(), MaxFieldLength.UNLIMITED);
			for (int i = 0; i < 100; i++)
			{
				Document doc = new Document();
				int term = i * 10; //terms are units of 10;
				doc.Add(new Field(fieldName, "" + term, Field.Store.YES, Field.Index.NOT_ANALYZED));
				w.AddDocument(doc);
			}
			w.Close();

            IndexReader reader = IndexReader.Open(rd, true);
			IndexSearcher searcher = new IndexSearcher(reader);
			int numDocs = reader.NumDocs();
			ScoreDoc[] results;
			MatchAllDocsQuery q = new MatchAllDocsQuery();
			
			System.Collections.ArrayList terms = new System.Collections.ArrayList();
			terms.Add("5");
			results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, (System.String[]) terms.ToArray(typeof(System.String))), numDocs).ScoreDocs;
			Assert.AreEqual(0, results.Length, "Must match nothing");
			
			terms = new System.Collections.ArrayList();
			terms.Add("10");
            results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, (System.String[])terms.ToArray(typeof(System.String))), numDocs).ScoreDocs;
			Assert.AreEqual(1, results.Length, "Must match 1");
			
			terms = new System.Collections.ArrayList();
			terms.Add("10");
			terms.Add("20");
			results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, (System.String[]) terms.ToArray(typeof(System.String))), numDocs).ScoreDocs;
			Assert.AreEqual(2, results.Length, "Must match 2");
			
			reader.Close();
			rd.Close();
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:39,代码来源:TestFieldCacheTermsFilter.cs

示例12: TestMissingTerms

        public virtual void TestMissingTerms()
        {
            string fieldName = "field1";
            Directory rd = NewDirectory();
            RandomIndexWriter w = new RandomIndexWriter(Random(), rd);
            for (int i = 0; i < 100; i++)
            {
                Document doc = new Document();
                int term = i * 10; //terms are units of 10;
                doc.Add(NewStringField(fieldName, "" + term, Field.Store.YES));
                w.AddDocument(doc);
            }
            IndexReader reader = w.Reader;
            w.Dispose();

            IndexSearcher searcher = NewSearcher(reader);
            int numDocs = reader.NumDocs;
            ScoreDoc[] results;
            MatchAllDocsQuery q = new MatchAllDocsQuery();

            List<string> terms = new List<string>();
            terms.Add("5");
            results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, terms.ToArray()), numDocs).ScoreDocs;
            Assert.AreEqual(0, results.Length, "Must match nothing");

            terms = new List<string>();
            terms.Add("10");
            results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, terms.ToArray()), numDocs).ScoreDocs;
            Assert.AreEqual(1, results.Length, "Must match 1");

            terms = new List<string>();
            terms.Add("10");
            terms.Add("20");
            results = searcher.Search(q, new FieldCacheTermsFilter(fieldName, terms.ToArray()), numDocs).ScoreDocs;
            Assert.AreEqual(2, results.Length, "Must match 2");

            reader.Dispose();
            rd.Dispose();
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:39,代码来源:TestFieldCacheTermsFilter.cs

示例13: TestSortWithoutFillFields

        public virtual void TestSortWithoutFillFields()
        {
            // There was previously a bug in TopFieldCollector when fillFields was set
            // to false - the same doc and score was set in ScoreDoc[] array. this test
            // asserts that if fillFields is false, the documents are set properly. It
            // does not use Searcher's default search methods (with Sort) since all set
            // fillFields to true.
            Sort[] sort = new Sort[] { new Sort(SortField.FIELD_DOC), new Sort() };
            for (int i = 0; i < sort.Length; i++)
            {
                Query q = new MatchAllDocsQuery();
                TopDocsCollector<Entry> tdc = TopFieldCollector.Create(sort[i], 10, false, false, false, true);

                @is.Search(q, tdc);

                ScoreDoc[] sd = tdc.TopDocs().ScoreDocs;
                for (int j = 1; j < sd.Length; j++)
                {
                    Assert.IsTrue(sd[j].Doc != sd[j - 1].Doc);
                }
            }
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:22,代码来源:TestTopFieldCollector.cs

示例14: EmptyQueryMatchesAllDocuments

        public void EmptyQueryMatchesAllDocuments()
        {
            // arrange
            var queryText = string.Empty;
            var expected = new MatchAllDocsQuery();

            // act
            var actual = NuGetQuery.MakeQuery(queryText);

            // assert
            Assert.Equal(expected, actual);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:12,代码来源:NuGetQueryTests.cs

示例15: Query

        public string[] Query(string query, string[] sortFields, int start, int pageSize, out int totalResults)
        {
            IndexSearcher searcher;
            using (GetSearcher(out searcher))
            {
                Query fileQuery;
                if (string.IsNullOrEmpty(query))
                {
                    Log.Debug("Issuing query on index for all files");
                    fileQuery = new MatchAllDocsQuery();
                }
                else
                {
                    Log.Debug("Issuing query on index for: {0}", query);
                    var queryParser = new SimpleFilesQueryParser(analyzer);
                    fileQuery = queryParser.Parse(query);
                }

                var topDocs = ExecuteQuery(searcher, sortFields, fileQuery, pageSize + start);

                var results = new List<string>();

                for (var i = start; i < pageSize + start && i < topDocs.TotalHits; i++)
                {
                    var document = searcher.Doc(topDocs.ScoreDocs[i].Doc);
                    results.Add(document.Get("__key"));
                }
                totalResults = topDocs.TotalHits;
                return results.ToArray();
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:31,代码来源:IndexStorage.cs


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