本文整理汇总了C#中Lucene.Net.Search.MatchAllDocsQuery类的典型用法代码示例。如果您正苦于以下问题:C# MatchAllDocsQuery类的具体用法?C# MatchAllDocsQuery怎么用?C# MatchAllDocsQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatchAllDocsQuery类属于Lucene.Net.Search命名空间,在下文中一共展示了MatchAllDocsQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Test6
public void Test6()
{
Query query = new MatchAllDocsQuery();
SimpleFacetedSearch sfs = new SimpleFacetedSearch(_Reader, "nosuchfield");
SimpleFacetedSearch.Hits hits = sfs.Search(query);
Assert.AreEqual(0, hits.TotalHitCount);
Assert.AreEqual(0, hits.HitsPerFacet.Length);
}
开发者ID:Nangal,项目名称:lucene.net,代码行数:10,代码来源:TestSimpleFacetedSearch.cs
示例17: Test5
public void Test5()
{
Query query = new MatchAllDocsQuery();
SimpleFacetedSearch sfs = new SimpleFacetedSearch(_Reader, "category");
SimpleFacetedSearch.Hits hits = sfs.Search(query);
Assert.AreEqual(7, hits.TotalHitCount);
}
开发者ID:Nangal,项目名称:lucene.net,代码行数:9,代码来源:TestSimpleFacetedSearch.cs
示例18: TestSortWithScoreAndMaxScoreTracking
public virtual void TestSortWithScoreAndMaxScoreTracking()
{
// Two Sort criteria to instantiate the multi/single comparators.
Sort[] sort = new Sort[]{new Sort(SortField.FIELD_DOC), new Sort()};
for (int i = 0; i < sort.Length; i++)
{
Query q = new MatchAllDocsQuery();
TopFieldCollector tdc = TopFieldCollector.Create(sort[i], 10, true, true, true, true);
full.Search(q, tdc);
TopDocs td = tdc.TopDocs();
ScoreDoc[] sd = td.ScoreDocs;
for (int j = 0; j < sd.Length; j++)
{
Assert.IsTrue(!System.Single.IsNaN(sd[j].Score));
}
Assert.IsTrue(!System.Single.IsNaN(td.GetMaxScore()));
}
}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:21,代码来源:TestSort.cs
示例19: MatchAllDocsWeight
public MatchAllDocsWeight(MatchAllDocsQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = searcher.Similarity;
}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:5,代码来源:MatchAllDocsQuery.cs
示例20: Browse
public static IndexItemCollection Browse(
int siteId,
Guid featureGuid,
DateTime modifiedBeginDate,
DateTime modifiedEndDate,
int pageNumber,
int pageSize,
out int totalHits)
{
totalHits = 0;
IndexItemCollection results = new IndexItemCollection();
using (Lucene.Net.Store.Directory searchDirectory = GetDirectory(siteId))
{
Filter filter = null;
BooleanQuery filterQuery = null;
if ((modifiedBeginDate.Date > DateTime.MinValue.Date) || (modifiedEndDate.Date < DateTime.MaxValue.Date))
{
filterQuery = new BooleanQuery(); // won't be used to score the results
TermRangeQuery lastModifiedDateFilter = new TermRangeQuery(
"LastModUtc",
modifiedBeginDate.Date.ToString("s"),
modifiedEndDate.Date.ToString("s"),
true,
true);
filterQuery.Add(lastModifiedDateFilter, Occur.MUST);
}
if (featureGuid != Guid.Empty)
{
if (filterQuery == null) { filterQuery = new BooleanQuery(); }
BooleanQuery featureFilter = new BooleanQuery();
featureFilter.Add(new TermQuery(new Term("FeatureId", featureGuid.ToString())), Occur.MUST);
filterQuery.Add(featureFilter, Occur.MUST);
}
if (filterQuery != null)
{
filter = new QueryWrapperFilter(filterQuery); // filterQuery won't affect result scores
}
MatchAllDocsQuery matchAllQuery = new MatchAllDocsQuery();
using (IndexSearcher searcher = new IndexSearcher(searchDirectory))
{
int maxResults = int.MaxValue;
TopDocs hits = searcher.Search(matchAllQuery, filter, maxResults);
int startHit = 0;
if (pageNumber > 1)
{
startHit = ((pageNumber - 1) * pageSize);
}
totalHits = hits.TotalHits;
if (startHit > totalHits)
{
startHit = totalHits;
}
int end = startHit + pageSize;
if (totalHits <= end)
{
end = totalHits;
}
int itemsAdded = 0;
int itemsToAdd = end;
for (int i = startHit; i < itemsToAdd; i++)
{
Document doc = searcher.Doc(hits.ScoreDocs[i].Doc);
IndexItem indexItem = new IndexItem(doc, hits.ScoreDocs[i].Score);
results.Add(indexItem);
itemsAdded += 1;
}
results.ItemCount = itemsAdded;
results.PageIndex = pageNumber;
results.ExecutionTime = DateTime.Now.Ticks; // -0;
}
// using (IndexReader reader = IndexReader.Open(searchDirectory, false))
// {
// totalHits = reader.NumDocs();
//.........这里部分代码省略.........
开发者ID:joedavis01,项目名称:mojoportal,代码行数:101,代码来源:IndexHelper.cs
注:本文中的Lucene.Net.Search.MatchAllDocsQuery类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论