jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael MacFadden <m...@macfadden.org>
Subject Searching Multiple Node Types
Date Tue, 15 Apr 2008 14:24:40 GMT

I have a question regarding searching.  In my repository, I have two 
different node types.  One for regular typed in content and one for 
attachments.  Each of these node types has a node type definition loaded 
and they each have different properties.  What I want to do is allow the 
user to enter a search term and have the content nodes and attachments 
searched an provide a single list ordered by the results score.  I have 
the full text (text extractor) search already working and am using the 

The issue I have is that since the nodes I am trying to search have two 
different types it seems like I need two separate queries:


"SELECT * FROM mynt:content WHERE CONTAINS(* , '" + 
queryString.toLowerCase().trim() + "') order by jcr:score DESC"


"SELECT * FROM mynt:attachments WHERE CONTAINS(* , '" + 
queryString.toLowerCase().trim() + "') order by jcr:score DESC"

I could execute both of these queries and try to merge the results and 
then sort them.  The issue is that I also need to page the results, 
because there could be thousands.  I would either use the skip function 
in the NodeIterator class or I would use the limit and offset functions 
in the jackrabbit specific api.  However to really do this I would need 
to have a single merged result list.  If I don't then I wouldn't know 
where to page when making the two different queries since I would not 
know how many results were coming in the other query.  I would 
essentially have to get all results, merge them, sort them, and then 
select a subset.

This seems like the performance would be impacted for large result 
sets.  Is there a way to query multiple node types, my understanding is 
that you can only do so if the nodes share some inherited node type, but 
when you do that you can only search the properties that are in the 
parent node type.  This wouldn't work either since the child node types 
have differing properties that need to be searched.  So far the only way 
I can see to do this would be to merge the definitions of my nodes into 
one type and then just not use certain properties depending on which 
type of node I really want.  However this doesn't really seem like a 
clean approach.

Any ideas would be welcome.  Thanks.


View raw message