-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: [Hibernate Search] searching associated fields
PostPosted: Wed Oct 24, 2007 6:59 pm 
Newbie

Joined: Wed Oct 24, 2007 5:49 pm
Posts: 5
Hi, I'm struggling with a design problem

Just for simplicity, lets assume I've got 3 entities mapped and all should be returned as a result (they don't meet parent/child relation).

I have to make it possible to query associated fields. Initially I planned to create one index that joins all entities but the problem is that i want to get the closest match. That mean if my query uses attributes from A and B entities both objects should be in the outcome. If it uses fields only from A entity, *only* A is supposed to be returned

Does hibernate search makes it possible?

The only way I can think about it is like having one index per class without associated fields, ignoring other fields during quering and making intersection of all sets on my own if all searchable fields are required.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 11:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
CAn you make your question more concrete for example by providing some class examples. From what I understood it might be possible.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 3:28 am 
Newbie

Joined: Wed Oct 24, 2007 5:49 pm
Posts: 5
@Indexed
public class Tasks {
@DocumentId
private Long id;

@Field
private String title;

@IndexedEmbedded
private List<Attributes> attributes;


@IndexedEmbedded
private List<Contents> contents;
....
}


@Indexed
public class Attributes {
@DocumentId
private Long id;

@Field
private String name;

@Field
private String value;

@IndexedEmbedded
private Tasks task;
....
}


@Indexed
public class Contents {
@DocumentId
private Long id;

@Field
private String content;

@IndexedEmbedded
private Tasks task;
....
}

Although it looks as if Tasks where at the top of hierarchy, it's mandatory in my project to query all 3 objects, thus all must be indexed. Besides that, query like that:

+title:java +content:java
should return appropriate Tasks and Contents objects

but

+contents:java
is supposed to return only Contents objects (which is not in my case since due to @IndexedEmbedded query will hit associated Tasks as well).

Although i could restrict my search like that: fullTextSession.createFullTextQuery( luceneQuery, Contents.class ) ,
i need to allow searching all indexed objects.
Another workaround that occuried to me might be checking where query's fields belong to and then restricting to that classes in
'createFullTextQuery' but that sounds quite rough to me.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 3:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
AFAIK +title:java +content:java should return nothing since you have no object having both fields title and content.

but

"title:java content:java" should return all tasks having java in the title and all content objects having java in the content field.

"contents:java" will return all tasks having a content whose content field contains java.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 9:31 am 
Newbie

Joined: Wed Oct 24, 2007 5:49 pm
Posts: 5
Thanks for answer and sorry for my delay.

That's everything correct except one thing:

If user query for

+title:java +content:java

I should return both entities (contents and tasks) that meet the query. Previously we thought about making use of IndexEmbedded. I've prototyped it, however since we must provide functionality to query for all indexed fields at once it involved making one big denormalized table (that has some performance issue and renders hibernate search useless).

I'm wondering if there is any feature that i don't know that would ease us the pain making two separate queries "+title:java" and "+content:java" and then making intersaction of the results (Probably still writing some more sophisticated QueryParser from scratch)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.