Есть:
Поиск в строке и магазинвыполняется следующим образом:
@Override
public List<Delivery> searchNewDeliveriesBy(long storeId, String text, Long selectedDateAsMills) {
try (Session session = createSession()) {
Store store = session.get(Store.class, storeId);
FullTextEntityManager fullTextSession = Search.getFullTextSession(session);
QueryBuilder qb = fullTextSession.getSearchFactory()
.buildQueryBuilder()
.forEntity(Delivery.class)
.get();
org.apache.lucene.search.Query luceneQuery = qb.bool()
.must(
qb.keyword().onFields(DELIVERY_SEARCH_FIELDS).matching(text).createQuery()
)
.must(
qb.keyword().onField("store").matching(store).createQuery()
)
.createQuery();
//noinspection unchecked
return Search.getFullTextSession(session)
.createFullTextQuery(luceneQuery, Delivery.class)
.setSort(sortByFieldScore)
.list();
}
}
Моя сущность (без слишком большого):
public class Delivery {
...
private LocalDateTime deliveryDateMin;
private LocalDateTime deliveryDateMax;
...
}
Мне нужно добавить условие, чтобы выбранное время (переменная метода selectedDateAsMills
) быломежду deliveryDateMin
и deliveryDateMax
.
Существует класс, подобный LocalDateTimeBridge, но в Интернете нет примеров использования.Этот ответ ( Как искать между датами (Hibernate Search)? ) не подходит, потому что есть java.util.Date
, а не java.time.LocalDateTime
.
UPDATE
@Entity
@Table(name = "DELIVERY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Cacheable
@Indexed
public class Delivery {
@Column(name = "delivery_date_min")
@JsonFormat(pattern = "yyyy-mm-dd HH:MM")
@Field
@FieldBridge(impl = LocalDateTimeBridge.class)
private LocalDateTime deliveryDateMin;
@Column(name = "delivery_date_max")
@JsonFormat(pattern = "yyyy-mm-dd HH:MM")
@Field
@FieldBridge(impl = LocalDateTimeBridge.class)
private LocalDateTime deliveryDateMax;
}