Question

I am trying to implement a query on a RavenDB Lucene index and paging the results.

I have the following code:

        IDocumentQuery<Post> q = Session.Advanced.LuceneQuery<Post, Posts_Search>()
            .WhereContains("BodyHtml", query)
            .OrElse()
            .WhereContains("Title", query)
            .AddOrder("Published", true)
            .Skip(4).Take(4);

(The last pair of Skip and Take was added for the sake of a simple example).

This query always returns all of the 22 documents that matches my query, not only 4, as I would expect.

What am I doing wrong ?

Was it helpful?

Solution

This problem was occuring on the latest stable build (206).

I have now downloaded the latest unstable build (251), and with this build, my code works as expected. I guess it was a bug in the version I was using. If I get anything more meaningful insight from my question in the RavenDB group, I will make sure to post it here.

OTHER TIPS

Just a guess here as I don't know RavenDB. But perhaps the Raven provider does not support skip or take.

You could try converting to an IEnumerable after your .AddOrder to verify that. (You would then be using Linq to Objects to Skip and Take, note you would still be getting all your records from the DB first)

  ...
  .AddOrder("Published",True)
  .AsEnumerable()
  .Skip(4).Take(4);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top