コード例 #1
0
ファイル: IndexStorage.cs プロジェクト: cocytus/ravendb
        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());
            }
        }
コード例 #2
0
ファイル: IndexStorage.cs プロジェクト: mdavis/ravendb
		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();
			}
		}