Search across aggregate documents and produce a pagable summary list

35 views
Skip to first unread message

billba...@hotmail.com

unread,
Jan 31, 2012, 8:19:16 AM1/31/12
to ravendb
I need to implement a search that will include elements from the
following documents (elements required are simplified. Search
parameters are listed):

Client (root)
ClientID
First Name (search parameter)
Last Name (search parameter)
Gender (search parameter. Value obtained from a lookup document)

ClientCase (root)
StartDate (search parameter. Current date within Start Date & EndDate
is returned as Active)
EndDate

Assessment
AssessmentID
Status(Value obtained from a lookup document)

*** Assessment is the core entity in connecting to the other
entities.There are multitple Assessment type documents that need to be
combined into the list.

Program (root)
ProgramID

The outputted list needs include all of the entity elements referenced
above. As mentioned above, there are multiple Assessment Types that
need to be combined in the list. Currently the Assessment classes do
not derive from a common base class.

I was able to combine two Assessment type classes using a MultiMap
techniqueas per: http://ayende.com/blog/89089/ravendb-multi-maps-reduce-indexes

Still need to add in the other document elements and have be
searchable.

I have several best practices questions:
Is a MultiMap the technique that should be used as the core of the
index?

What is the best technique to connect the other entities?

Should the other entities be combined in Reduce of the multimap index
or in the query on the index?

Does anything specific need to be done with respect to the search
parameters?

For context, below is the current multimap

public class CaseProgramSummary_List :
AbstractMultiMapIndexCreationTask<CaseProgramSummaryDto>
{
public CaseProgramSummary_List()
{
AddMap<MapcAssessment>(assessments => from assessment in
assessments
select new
{
AssessmentId = assessment.Id,
});

AddMap<MfpAssessment>(assessments => from assessment in
assessments
select new
{
AssessmentId = assessment.Id,
});

Reduce = results => from result in results
group result by result.AssessmentId
into g
select new
{
AssessmentId = g.Key,
};

// Will need LastName property as analyzed, which means
that we can issue full text queries against it?
// Index(x => x.LastName, FieldIndexing.Analyzed);
}
}


var results = session.Query<CaseProgramSummaryDto,
CaseProgramSummary_List>()
// .Where(x => x.LastName.StartsWith("rah"))
.ToList();

Oren Eini (Ayende Rahien)

unread,
Feb 1, 2012, 11:07:53 AM2/1/12
to rav...@googlegroups.com
I don't think that you need a reduce here, just a multi map.
If I search for a name, I don't need to find assessment. 
Just doing a multi map with no reduce would give you what you want, I tihnk

Chris Marisic

unread,
Feb 1, 2012, 11:53:58 AM2/1/12
to rav...@googlegroups.com
Take a look at this blog post it seems to be very high quality: http://daniellang.net/using-multi-maps-indexes-to-search-over-different-document-types/

billba...@hotmail.com

unread,
Feb 3, 2012, 7:43:49 PM2/3/12
to ravendb
Each returned "row" will need to be composed of elements from 3
documents. There will need to be a way to "join" and search multiple
document elements. For example, each item in the returned collection
would contain Client.LastName, ClientCase.StartDate and
Assessment.Status. And each field would be searchable/filterable. For
example, where Client.LastName = "Doe" AND Assessment.Status = Active.
So wouldn't a simple document map return something akin to a union
over the document elements but not elements from multiple documents?


On Feb 1, 11:07 am, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:
> I don't think that you need a reduce here, just a multi map.
> If I search for a name, I don't need to find assessment.
> Just doing a multi map with no reduce would give you what you want, I tihnk
>
> On Tue, Jan 31, 2012 at 3:19 PM, billbassl...@hotmail.com <

billba...@hotmail.com

unread,
Feb 3, 2012, 7:44:42 PM2/3/12
to ravendb
The article is close to the requirements but ... Each returned "row"
will need to be composed of elements from 3 documents. There will need
to be a way to "join" and search multiple document elements. For
example, each item in the returned collection would contain
Client.LastName, ClientCase.StartDate and Assessment.Status. And each
field would be searchable/filterable. For example, where
Client.LastName = "Doe" AND Assessment.Status = Active. So wouldn't a
simple document map return something akin to a union over the document
elements but not elements from multiple documents?

On Feb 1, 11:53 am, Chris Marisic <ch...@marisic.com> wrote:
> Take a look at this blog post it seems to be very high quality:http://daniellang.net/using-multi-maps-indexes-to-search-over-differe...

Itamar Syn-Hershko

unread,
Feb 5, 2012, 10:45:49 AM2/5/12
to rav...@googlegroups.com
This is the same topic as in the other thread, right?
Reply all
Reply to author
Forward
0 new messages