Query against multiple values in a collection

286 vues
Accéder directement au premier message non lu

Benjamin

non lue,
24 janv. 2011, 14:28:0424/01/2011
à 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

non lue,
25 janv. 2011, 07:05:5925/01/2011
à 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

non lue,
25 janv. 2011, 08:40:3525/01/2011
à ravendb

Benjamin

non lue,
25 janv. 2011, 17:05:1525/01/2011
à 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

non lue,
26 janv. 2011, 02:30:5126/01/2011
à 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

non lue,
26 janv. 2011, 12:24:2426/01/2011
à rav...@googlegroups.com
Fixed
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message