0
我有我想查詢以下索引POJO:的Hibernate搜索通配符搜索不返回預期的結果
@Entity
@Indexed
@AnalyzerDef(name="userAnalyzer",
tokenizer = @TokenizerDef(factory=StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory=LowerCaseFilterFactory.class),
@TokenFilterDef(factory=SnowballPorterFilterFactory.class, params = {
@Parameter(name="language", value="English"
})
}
)
public class User {
@Id
private long id;
@IndexEmbedded
private List<Address> addresses; // Address.street is what I am looking for
@Field
private String firstName;
@Field
private String lastName;
private List<AKA> akas;
private List<Wife> wives;
...
}
從本質上講,我試圖做在Hibernate中搜索以下SQL(Lucene的):
select u.*
from User
where u.firstName like ':fname%'
and u.lastName like ':lname%'
以下是我有什麼不工作始終:
...
if(Objects.nonNull(u.getFirstName()){
luceneBoolQuery.must(queryBuilder.keyword().wildcard().onField("firstName").matching(u.getFirstName().toLowerCase()).createQuery());
}
if(Objects.nonNull(u.getLastName()){
luceneBoolQuery.must(queryBuilder.keyword().wildcard().onField("lastName").matching(u.getLastName().toLowerCase()).createQuery());
}
Query luceneQuery = luceneBoolQuery.createQuery();
Query jpaQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, User.class);
...
...
可以將某些一個幫助我製作這個查詢來撤回上面的SQL會返回什麼?