Ravendb includes - little help required please

25 views
Skip to first unread message

greg

unread,
Aug 14, 2012, 6:53:34 AM8/14/12
to rav...@googlegroups.com
HI Folks
 
I am stuck trying to figure out how to get the includes feature working with the following:-
 
var rq = RavenSession.Query<Product, Products_QueryIndex>()
                .Customize(x => x.Include<Product>(d => d.ManufacturerId).WaitForNonStaleResultsAsOfNow())
                .Search(x => x.Code, term)
                .Search(x => x.Description, term)
                .Search(x => x.Name, term)
                .Take(50);
 
I am trying to return 50 product documents which match the term which is passed in elsewhere (temr will be a serach term passed in via front end), but I want to be able to search on manufacturer's name. The manufacturerid is stored within the product document and so I hope to be able to load the Manufacturer name from the include statement. (manufacturerid in product document links to manaufacturer documents and then I get access to manufacturer name)
 
Not sure what I am missing in order for this to work - any advice wuold be great.

Paul Hinett

unread,
Aug 14, 2012, 6:59:38 AM8/14/12
to rav...@googlegroups.com
You can't do this like that, you only get access to the properties of a single document at query time.

I think you probably want to use a multimap index to join 2 docs together, you can then query on both docs.

Paul

Sent from my iPad

greg

unread,
Aug 14, 2012, 7:09:12 AM8/14/12
to rav...@googlegroups.com
You can do this as I have done something similarly before just cant figure this one out.

Paul Hinett

unread,
Aug 14, 2012, 7:18:16 AM8/14/12
to rav...@googlegroups.com
With a normal map-only index i'm pretty sure you can't. But you can
with a multimap index, unless someone wants to correct me?

On 14 August 2012 12:09:12, greg wrote:
> You can do this as I have done something similarly before just cant
> figure this one out.
>
> On Tuesday, 14 August 2012 11:59:38 UTC+1, Paul wrote:
>
> You can't do this like that, you only get access to the properties
> of a single document at query time.
>
> I think you probably want to use a multimap index to join 2 docs
> together, you can then query on both docs.
>
> Paul
>
> Sent from my iPad
>
> On 14 Aug 2012, at 11:53, greg <gsutt...@hotmail.com

Itamar Syn-Hershko

unread,
Aug 14, 2012, 9:26:58 AM8/14/12
to rav...@googlegroups.com

Paul is corrrect, multi maps will allow you to do this

Includes only control what gets sent, not what u can query on

Reply all
Reply to author
Forward
0 new messages