-->
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.  [ 2 posts ] 
Author Message
 Post subject: Projection - show/return only fields that match
PostPosted: Wed Oct 28, 2009 11:51 am 
Newbie

Joined: Mon Aug 31, 2009 6:46 am
Posts: 11
Hi,

I'll explain what I am trying to do - I'm not sure if it is entirely possible!

Basically, I have an entity with multiple fields that are stored in the index (store = Store.YES). I'm using projections to return just the fields that I am interested in, but I only want those fields that actually match to be returned. At the moment, when 1 field matches, all fields are returned in the object[].

Here is some code that may explain better:
Code:
String[] assetFields = new String[]{"description","notes","reference","manufInfo"};
MultiFieldQueryParser assetParser = new MultiFieldQueryParser(assetFields, new StandardAnalyzer());

assetParser.setDefaultOperator(Operator.AND);
org.apache.lucene.search.Query assetQuery = assetParser.parse(term);

org.hibernate.search.FullTextQuery assetQueryRes = fullTextSession.createFullTextQuery(assetQuery,Asset.class);
assetQueryRes.setProjection("description","notes","reference","manufInfo");
List<Object[]> assetResults = assetQueryRes.list();


Now lets say I have an Asset with the following values for the fields:

description = "personal mobile."
notes = "Just some random notes."
reference = "Just a reference."
manufInfo = "Three"

If my search term is "no*" (I'm using a wildcard here) then the result array has all the results, but basically I just want the notes field.

Is this possible?

Thanks in advance!

K


Top
 Profile  
 
 Post subject: Re: Projection - show/return only fields that match
PostPosted: Wed Oct 28, 2009 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
No, there is currently no out of the box solution for that. Have a look at this thread as well - viewtopic.php?f=9&t=999114


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.