Query against multiple values in a collection

286 views
Skip to first unread message

Benjamin

unread,
Jan 24, 2011, 2:28:04 PM1/24/11
to rav...@googlegroups.com
I am attempting to run a query using the andalso command to filter on a dictionary.  I haven't been able to figure out how to query (with or without a pre-defined index) to retrieve the items I want.  I created a test that fails that should demonstrate my intention. If I remove either of the subclauses, it returns the expected value, but the current test fails.

Any suggestions are welcome.

Cheers,

Benjamin

Ayende Rahien

unread,
Jan 25, 2011, 7:05:59 AM1/25/11
to rav...@googlegroups.com
Okay, here you need to use something like this:

from user in docs.UserWithIDictionaries
select new 
{
 _ = Project(p.Properties, prop=> new Field(prop.Key, prop.Value.Value, Field.Store.NO, Field.Index.ANALYZED))
}

This will generate an index structure like:

{ LoginCount = 50, QueueLength = 120 }

Which you could query

vlko

unread,
Jan 25, 2011, 8:40:35 AM1/25/11
to ravendb

Benjamin

unread,
Jan 25, 2011, 5:05:15 PM1/25/11
to rav...@googlegroups.com
Ok, I'll go back to using Project as a way to solve this (I think this is _the_ way to do it).

For my case, I'll need to use .WhereGreaterThan on the value.  In order to accomplish this, I believe I need to use NumericField in something like this:
Project(p.Properties, prop=> new NumericField(prop.Key, Field.Store.NO, true).SetDoubleValue(prop.Value.Value))

Is this the correct way to be getting the result I want (range queries to function on a numeric)?

If so, there is a bug.  When you generate the text (tmp file) of the index to compile, the text is changing the text to:
Project(p.Properties, prop=> new NumericField(prop.Key, Field.Store.NO, True).SetDoubleValue(prop.Value.Value))

Note the capital "T" in true for the parameter in NumericField.  This causes a compilation error at runtime.

Is there another/better way to go about finding a solution?

_IF_ the NumericField should be supported inside a Project function, I have submitted a pull request with a failing test:

vlko

unread,
Jan 26, 2011, 2:30:51 AM1/26/11
to ravendb
Sorry this should be in different thread.

/vlko

On Jan 25, 2:40 pm, vlko <v...@zilina.net> wrote:
> I have extension method WhereContainsAsOr for thishttps://github.com/vlko/vlko/blob/master/vlko.BlogModule.RavenDB/Repo...
> Sample usagehttps://github.com/vlko/vlko/blob/master/vlko.BlogModule.RavenDB/Acti...

Ayende Rahien

unread,
Jan 26, 2011, 12:24:24 PM1/26/11
to rav...@googlegroups.com
Fixed
Reply all
Reply to author
Forward
0 new messages