Hi,
I have query like so
Code:
public class Item{
@Field(index=Index.UN_TOKENIZED,store=Store.YES)
@Column(length=255)
public String getUrl() {
return url;
}
}
QueryBuilder qb = fts.getSearchFactory().buildQueryBuilder()
.forEntity(Item.class).get();
Query q = sj.must(qb.keyword().onField("url").matching(item.getUrl())
.createQuery());
This bombs if item.getUrl() is null. I get the message
Code:
org.hibernate.search.SearchException: Search parameter on field url could not be converted. Are the parameter and the field of the same type?Alternatively, apply the ignoreFieldBridge() option to pass String parameters
at org.hibernate.search.query.dsl.impl.Helper.getAllTermsFromText(Helper.java:78)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.getAllTermsFromText(ConnectedMultiFieldsTermQueryBuilder.java:173)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:98)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:73)
Why? Should I protect Hibernate against potential nulls? That would not make sense.
If I add the suggested ignoreFieldBridge, I get
Code:
org.hibernate.search.SearchException: Unable to search for null token on field url if field bridge is ignored.
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.buildSearchTerm(ConnectedMultiFieldsTermQueryBuilder.java:123)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:92)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:73)