Hi, I can't search Date fields:
Method in DAO (note: comments in queryBuilder call):
Code:
public List<T> search(String searchString, String sortField, String sortOrder, Integer offset, Integer limit)
{
FullTextEntityManager fullTextEntityManager = this.getFullTextEntityManager();
SearchFactory searchFactory = fullTextEntityManager.getSearchFactory();
QueryBuilder queryBuilder = searchFactory.buildQueryBuilder().forEntity(this.persistentClass).get();
org.apache.lucene.search.Query query = queryBuilder
.keyword()
.wildcard() // i also tried removing this line
.onField(sortField) // anyway, let's say sortField is "updatedAt"
.matching("*"+searchString+"*")
.createQuery();
FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(query, this.persistentClass);
Boolean isReversed = false;
if(sortOrder.equals("desc")) {
isReversed = true;
}
fullTextQuery.setSort(new Sort(new SortField(sortField, SortField.STRING, isReversed)));
fullTextQuery.setFirstResult(offset);
fullTextQuery.setMaxResults(limit);
return fullTextQuery.getResultList();
}
When it runs, I get this error:
Code:
org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
class: com.mycompany.system.model.MyModel
field bridge: updatedAt
at org.hibernate.search.bridge.util.ContextualExceptionBridge.buildBridgeException(ContextualExceptionBridge.java:77)
at org.hibernate.search.bridge.util.ContextualException2WayBridge.objectToString(ContextualException2WayBridge.java:76)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.objectToString(DocumentBuilderIndexedEntity.java:304)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.objectToString(DocumentBuilderIndexedEntity.java:596)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.buildSearchTerm(ConnectedMultiFieldsTermQueryBuilder.java:133)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:92)
at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:73)
at com.mycompany.web.dao.impl.GenericDaoJpa.search(GenericDaoJpa.java:235)
(rest of stack omitted...)
MyModel's updatedAt field is already indexed:
Code:
@Column(name="updated_at", nullable=false)
@Field(index=Index.UN_TOKENIZED, store=Store.YES)
@DateBridge(resolution=Resolution.SECOND)
private Date updatedAt = new Date();
Can anyone help? :D Thanks!