-->
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.  [ 1 post ] 
Author Message
 Post subject: filter child object properties in a FullTextFilter
PostPosted: Mon May 27, 2013 11:03 am 
Newbie

Joined: Mon May 27, 2013 10:41 am
Posts: 1
I am using a LuceneQuery to do a spatial search to find locations within a certain lat and long. This works as expected. I want to add to the search by filtering all locations that have a particular item in their store. I am trying to use @FullTextFilterDefs but am not sure how I can filter on the properties of Item.class when I set the enableFullTextFilter("filt").setParameter("", "").

Here is my configuration. I have condensed the code for simplicity sake.

Code:
@Entity
@Indexed
@Spatial
@FullTextFilterDefs( {
    @FullTextFilterDef(name = "filt", impl = filter.class)})
public class Location {

private Long id;
private List<Item>items;

... all other fields declared

@IndexEmbedded
@OneToMany(mappedBy="location")
public List<Item> getItems() {
return this.items;
}

@Entity
@Indexed
public class Item {

... all other fields

@ContainedIn
@ManyToOne
public Location getLocation() {
return location;
}

public class LocationLoader {

public List<Location> load(Item i) {

List<Location> result = new ArrayList<Location>();

//setup query builder .....

org.apache.lucene.search.Query luceneQuery = builder.spatial()
            .onCoordinates(Location.class.getName())
            .within(radius, Unit.KM)
            .ofLatitude(lat)
            .andLongitude(lon)
            .createQuery(); 

      
final FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, Location.class);

//filter locations that have a particular item
fullTextQuery.enableFullTextFilter("filt").setParameter("item.itemRef", i.getItemRef() ); //<- how can you filter on a field from the Item object?

result.addAll(fullTextQuery.list());

return result;

}
}


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

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.