// I'm using a raw query to work around this issue: https://groups.google.com/forum/#!topic/ravendb/nrUl1CaMCY8
var query = session.Advanced.AsyncRawQuery<MyClass>("from index my_index where string_field != null order by Id select Id, and bunch of other fields")
.Skip(skip);
var stream = await session.Advanced.StreamAsync(query);
while (await stream.MoveNextAsync())
{
var company = stream.Current.Document;
// export data to file
}
Nevermind the ...
Nevermind the .Skip(skip) on a RawQuery which does nothing, I just did some changes to the code to make it prettier. The problem persisted when really skipping various number of results.
On Thursday, June 21, 2018 at 1:54:33 PM UTC+2, Andrej Krivulčík wrote:// I'm using a raw query to work around this issue: https://groups.google.com/forum/#!topic/ravendb/nrUl1CaMCY8
var query = session.Advanced.AsyncRawQuery<MyClass>("from index my_index where string_field != null order by Id select Id, and bunch of other fields")
.Skip(skip);
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
using NLog;
using Raven.Client.Documents;
using Raven.Client.Documents.Indexes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace RavenDB4Tests.Tryouts
{
public static class QueryDisconnect
{
private static Logger _logger = LogManager.GetCurrentClassLogger();
public static async Task QueryDisconnectTest()
{
using (var store = new DocumentStore
{
Urls = new[] { "http://localhost:8080" },
Database = "QueryDisconnect"
}.Initialize())
{
await new DocsIndex().ExecuteAsync(store);
using (var session = store.OpenAsyncSession())
{
if (await ShouldInitData(store))
{
await InitializeData(store);
}
// wait for indexing manually
}
var docs = await LoadDocs(store);
}
}
private static async Task<Dictionary<string, Doc>> LoadDocs(IDocumentStore store)
{
var docs = new Dictionary<string, Doc>();
using (var session = store.OpenAsyncSession())
{
var indexQuery = session.Query<Doc, DocsIndex>();
_logger.Info("Creating index stream");
var indexStream = await session.Advanced.StreamAsync(indexQuery);
_logger.Info("Index stream created");
while (await indexStream.MoveNextAsync())
{
var doc = indexStream.Current.Document;
docs[doc.Id] = doc;
if (doc.Id.EndsWith("00"))
{
_logger.Info($"Processing (index) {doc.Id}");
}
Thread.Sleep(50);
}
}
return docs;
}
private static async Task<bool> ShouldInitData(IDocumentStore documentStore)
{
using (var session = documentStore.OpenAsyncSession())
{
var doc = await session.LoadAsync<Doc>("doc/1");
return doc == null;
}
}
private static async Task InitializeData(IDocumentStore documentStore)
{
_logger.Info("Generating data.");
var rng = new Random();
var batches = 20;
var perBatch = 1000;
for (int batchNo = 0; batchNo < batches; batchNo++)
{
_logger.Info($"Generating batch {batchNo + 1}/{batches}");
using (var session = documentStore.OpenAsyncSession())
{
for (int i = 1; i <= perBatch; i++)
{
await session.StoreAsync(new Doc
{
Id = "doc/" + (batchNo * perBatch + i),
StrVal = new string(Enumerable.Repeat('A', 10000).ToArray()),
});
}
await session.SaveChangesAsync();
}
}
_logger.Info("Data generated.");
}
public class Doc
{
public string Id { get; set; }
public string StrVal { get; set; }
}
public class DocsIndex : AbstractIndexCreationTask<Doc>
{
public DocsIndex()
{
Map = docs =>
from doc in docs
select new
{
doc.Id,
doc.StrVal,
};
StoreAllFields(FieldStorage.Yes);
}
}
}
}
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811