That’s exactly what will happen when you use @GenericField.
I’d advise you to read the getting started guide first. This section in particular explains how to define analyzers in Hibernate Search 6, and how to assign them to fields.
Define analyzers by implementing LuceneAnalysisConfigurer and then setting the configuration property hibernate.search.backend.analysis.configurer to the fully-qualified name of your implementation class (e.g. com.mycompany.config.MyAnalysisConfigurer).
Assign analyzers to field by mapping them using @FullTextField (instead of @GenericField) and then setting @FullTextField(analyzer = "emailNgram").
Range queries will work out of the box without the need to use a string encoding type.
So essentially you should map the date like this:
private Date creationDate;
And then query like this:
Date before = ...;
Date after = ...;
List<MyEntity> hits = Search.session(session).search(MyEntity.class)
.where(f -> f.range().field("creationDate").between(before, after))
Something in your predicates isn’t matching. Without knowledge of your predicates and your data, I can’t tell you what is not matching.
One way you could debug this is by commenting out most conditions, then uncommenting them one by one, until you get no results. Then have a look at the last you uncommented, that’s probably the one that doesn’t work.
Ah, and one more thing… when you update associations, you must update both sides. If for example you didn’t add the ticket to SaleSaga.tickets when it was created, then Hibernate Search will not be able to know that this ticket must be indexed-embedded inside this SaleSaga; it won’t be, and you won’t get any match.
here is the query string when its not working
The owning side of your association is Ticket.saleSaga, and you didn’t set that property before saving your ticket. In that case, the association was not persisted, and the result you’re getting reflects the content of the database. Like I said, you must set both sides of your associations. The problem is in how you saved your entity, and everything works well on the Hibernate Search side. Note that you most likely would have the same problem with Hibernate Search 5, since the problem is in how you used Hibernate ORM, not Hibernate Search.
You’re accessing SaleSaga.tickets outside of your transaction or after you closed the session. That’s dodgy and certainly will never work correctly. You should use the DTO pattern to copy data to an object that’s no linked to the session before you transfer it to other components of your application (REST service, …).