When I open up my index with Luke, I can query on the subjectDN field with the string "subjectdn1", and get 10+ results back. When I do it in code... I don't get anything back. I think I'm missing something.
Code:
@Test
public void searchForUsers() throws Exception {
ftem = Search.getFullTextEntityManager(em); // em is initialized in setup()
QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEntity(JPAUser.class).get();
org.apache.lucene.search.Query qry = qb.keyword().onField("subjectDN").matching("subjectdn1").createQuery();
javax.persistence.Query JPAftq = ftem.createFullTextQuery(qry, JPAUser.class);
List<?> result = JPAftq.getResultList();
System.out.println(result.toString());
if(result.isEmpty())
System.out.println("empty result set");
else
System.out.println("non-empty result set");
}
output is:
[]
empty result set
I THINK the above code is properly setup. I have a feeling my mistake may lay in my JPAUser class:
Code:
@Indexed(index = "fulltext")
@Entity
@Table(name = "USER")
public class JPAUser extends User implements java.io.Serializable {
// there are no global variables
// left out constructors for the sake of space
@Override
@DocumentId
@Id
@Column(name = "user_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE)
public long getUserId() {
return super.getUserId();
}
@Override
public void setUserId(long userId) {
super.setUserId(userId);
}
@Override
@Field(analyze = Analyze.YES, index = Index.YES, store = Store.YES)
@Boost(value=2.0f)
public String getEmail() {
return super.getEmail();
}
@Override
public void setEmail(String email) {
super.setEmail(email);
}
@Override
@Field(analyze = Analyze.YES, index = Index.YES, store = Store.YES)
public String getSubjectDN() {
return super.getSubjectDN();
}
@Override
public void setSubjectDN(String subjectDN) {
super.setSubjectDN(subjectDN);
}
}
I'm not convinced I have this annotated properly.
Anyways, any ideas why I'm not getting anything?
Thanks.