lucene - Querying Raven with Where() only filters against the first 128 documents? -


we're using raven validate logins people can our site.

what we've found if this:

// context idocumentsession  context.query<usermodels>()            .singleordefault(u => u.email.tolower() == email.tolower());  

the query filters on first 128 docs of documents in raven. there several thousand in our database, unless email happens in first 128 returned, you're out of luck.

none of raven samples code or sample code i've come across on net performs looping using skip() , take() iterate through set.

  1. is desired behavior of raven?
  2. is same behavior if use advanced lucene query? ie; advanced queries behave differently?
  3. is solution below appropriate? looks little ugly. :p

my solution loop through set of documents until encounter non null result, break , return .

public t singlewithindex(string indexname, func<t, bool> where) {     var pageindex = 1;     const int pagesize = 1024;     ravenquerystatistics stats;  var queryresults = context.query<t>(indexname)     .statistics(out stats)     .customize(x => x.waitfornonstaleresults())     .take(pagesize)     .where(where).singleordefault();  if (queryresults == null && stats.totalresults > pagesize) {     (var = 0; < (stats.totalresults / (pageindex * pagesize)); i++)     {         queryresults = context.query<t>(indexname)             .statistics(out stats)             .customize(x => x.waitfornonstaleresults())             .skip(pageindex * pagesize)             .take(pagesize)             .where(where).singleordefault();          if (queryresults != null) break;          pageindex++;     }  }  return queryresults; 

}

edit:

using fix below not passing query params ravendb instance. not sure why yet.

context.query<usermodels>()     .where(u => u.email == email)     .singleordefault(); 

in end using advanced lucene syntax instead of linq queries , things working expected.

ravendb not understand singleordefault, performs query without filter. condition executed on result set, per default raven returns first 128 documents. instead, have call

context.query<usermodels>()        .where(u => u.email == email)        .singleordefault(); 

so filtering done ravendb/lucene.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -