在Integer字段上搜索时无法获取结果,数据仍然存在。谁能弄清楚我在做什么错?
int status = 0;
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
QueryBuilder qb = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(ProcessActivity.class).get();
System.out.println(""+status);
org.apache.lucene.search.Query luceneQuery = qb.keyword().onFields("status").matching(status).createQuery();
FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, ProcessActivity.class);
fullTextQuery.setFirstResult(0).setMaxResults(recordMaxLength);
return fullTextQuery.getResultList();
//Following is main Entity text
@Fields({ @Field(index = Index.YES, analyze = Analyze.NO), @Field(name = "status", index = Index.YES, analyze = Analyze.NO) })
@Column(name = "STATUS")
public int getStatus() {
return status;
}
答案 0 :(得分:0)
使用NumericRangeQuery,例如
NumericRangeQuery.newIntRange("status", 1, value, value, true, true)
或字符串阶段,如
status[value TO value]