Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

one to many relationship

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


sfaiz.inbox at gmail

Nov 3, 2009, 2:44 AM

Post #1 of 3 (170 views)
Permalink
one to many relationship

Hi,

Could anyone comment on how should I handle one-to-many relationship of
domain objects in lucene? I have been searching the archive but was unable
to find any answer. I have read about Compass but I am afraid it will also
cost some performance penalty, any link to performance comparison will be
really helpful.

In my application, I have two entities e.g Article and Group. One article
can be categorized under zero or many groups. I don't need to index groups
data but while indexing Articles, I have to store groups information (at
least group ids) with each article, so that user can search articles in a
particular group.

Thanks,
sfaiz


ian.lea at gmail

Nov 3, 2009, 3:03 AM

Post #2 of 3 (161 views)
Permalink
Re: one to many relationship [In reply to]

> Could anyone comment on how should I handle one-to-many relationship of
> domain objects in lucene? I have been searching the archive but was unable
> to find any answer. I have read about Compass but I am afraid it will also
> cost some performance penalty, any link to performance comparison will be
> really helpful.

Sorry, can't give you any Compass info but from posts to this list it
appears to be fairly well used. And there is a good argument that you
shouldn't worry about performance in advance.

> In my application, I have two entities e.g Article and Group. One article
> can be categorized under zero or many groups. I don't need to index groups
> data but while indexing Articles, I have to store groups information (at
> least group ids) with each article, so that user can search articles in a
> particular group.

Just do as you say: store the group ids with each article e.g.

id: article1
text: some text about something
groupid: 100 200 300

id: article2
text: some other text about something else
groupid: 400

Then you can add a groupid: nnn clause to your query. As ever, you'll
need to make sure that you use a suitable analyzer at indexing and
search time.


--
Ian.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


chris.lu at gmail

Nov 5, 2009, 10:19 AM

Post #3 of 3 (132 views)
Permalink
Re: one to many relationship [In reply to]

Shahid, As Ian described, for one-to-many relationships, you need to
flatten the relationship and store it into Documents.

It's not efficient to search for Articles, and then based on the results
to search for related groups.
The database "good" 3NF model does not apply to Lucene for performance
reason.

--
Chris Lu
-------------------------
Instant Scalable Full-Text Search On Any Database/Application
site: http://www.dbsight.net
demo: http://search.dbsight.com
Lucene Database Search in 3 minutes: http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes
DBSight customer, a shopping comparison site, (anonymous per request) got 2.6 Million Euro funding!


Ian Lea wrote:
>> Could anyone comment on how should I handle one-to-many relationship of
>> domain objects in lucene? I have been searching the archive but was unable
>> to find any answer. I have read about Compass but I am afraid it will also
>> cost some performance penalty, any link to performance comparison will be
>> really helpful.
>>
>
> Sorry, can't give you any Compass info but from posts to this list it
> appears to be fairly well used. And there is a good argument that you
> shouldn't worry about performance in advance.
>
>
>> In my application, I have two entities e.g Article and Group. One article
>> can be categorized under zero or many groups. I don't need to index groups
>> data but while indexing Articles, I have to store groups information (at
>> least group ids) with each article, so that user can search articles in a
>> particular group.
>>
>
> Just do as you say: store the group ids with each article e.g.
>
> id: article1
> text: some text about something
> groupid: 100 200 300
>
> id: article2
> text: some other text about something else
> groupid: 400
>
> Then you can add a groupid: nnn clause to your query. As ever, you'll
> need to make sure that you use a suitable analyzer at indexing and
> search time.
>
>
> --
> Ian.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.