-->
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: Trouble with filter
PostPosted: Wed May 28, 2008 7:08 am 
Newbie

Joined: Tue May 27, 2008 10:23 am
Posts: 5
Hello everybody, I need your help.

I implemented fulltext search in my entitys using lucene.

Here is part of entity class.
Code:
@Indexed
@FullTextFilterDefs({
   @FullTextFilterDef(name = "company", impl = CompanyFilter.class, cache = false),
   @FullTextFilterDef(name = "roleFilter", impl = RoleFilter.class, cache = false)
})
@Entity
@Table(name="project")

public class EdsProject extends EdsObject implements Indexable {
   
    public static final String PROJECT_STATUS = "_PROJECT_STATUS";
    public static final String ONGOING="ONGOING";
    public static final String NOT_STARTED="NOT_STARTED";
    public static final String COMPLETED="COMPLETED";
   
 
   @Field(index = Index.UN_TOKENIZED)
   @DocumentId
   @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   @Column(name="id")
   private Integer objectID;
   
   public Integer getObjectID() {
        return objectID;
    }

    public void setObjectID(Integer objectID) {
        this.objectID = objectID;
    }


Here - code, which returns the search query result
FullTextQuery query = getFullTextQuery(fields, keyword);
Also, I have Integer[] of id's, and I should show to user not the whole query.getResultList() but only that results, which id's is in array.
I.E. - if query.getResultList() returns EdsProjects with id's 1, 5, 7 and 10
but in array I have only 5 and 7, I must not show 10 and 1 to user.

I suggested do this using filter
(RoleFilter) - and here is it

public class RoleFilter extends Filter{

Integer[] ids;

public Integer[] getIds() {
return ids;
}

public void setIds(Integer[] ids) {
this.ids = ids;
}

@Override
public BitSet bits(IndexReader reader) throws IOException {
BitSet bitSet = new BitSet(reader.maxDoc());
for (Integer id : ids) {
TermDocs termDocs = reader.termDocs(new Term("id", id.toString()));
while (termDocs.next()) {
bitSet.set(termDocs.doc());
}
}
return bitSet;
}

}

But it doesn't works.
After applyin' this filter - via
(projectIds - Integer[], contains allowed id's)
query.enableFullTextFilter("roleFilter").setParameter("ids", projectIds);
there are no elements in query at all (

I successfully implemented filters by another fields, but by this field (id) - I cannot ((


Top
 Profile  
 
 Post subject: It's funny!!
PostPosted: Sat Jun 07, 2008 5:43 am 
Newbie

Joined: Tue May 27, 2008 10:23 am
Posts: 5
But all this - I-am-java-expert- army on this site could't give me an answer for this question?
I am totally embarassed by this.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 8:13 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
did you use the "@Key" annotation as in reference docs?
Maybe you're not actually setting the Integer[] array in your filter.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: @key?
PostPosted: Sun Jun 08, 2008 1:39 pm 
Newbie

Joined: Tue May 27, 2008 10:23 am
Posts: 5
Well, I'll take a look on it on Monday, but - isn't it reference must be in filterfactory?


Top
 Profile  
 
 Post subject: @key?
PostPosted: Sun Jun 08, 2008 1:40 pm 
Newbie

Joined: Tue May 27, 2008 10:23 am
Posts: 5
Well, I'll take a look on it on Monday, but - isn't it reference must be in filterfactory?


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.