0
votes

I want to implement a query to get entities where endDate is null, for this i use indexNullAs because null values are not indexed

@Field(analyze = Analyze.NO, indexNullAs = Field.DEFAULT_NULL_TOKEN)
@DateBridge(resolution = Resolution.DAY)
private Date endDate;

but i have the below error

HSEARCH000325: The 'indexNullAs' property for field 'endDate', with value 'null', has invalid format: HSEARCH000293: The 'indexNullAs' property for fields indexed as Longs must represent a Long number. Could not parse 'null'.

1

1 Answers

1
votes

Pretty much what the error says. Internally, dates are indexed as long numbers, so your null token must be a long too.

Just pick a long value that will not conflict with the representation of valid dates, for example 9223372036854775807 (the maximum long value).

Alternatively, if your project is not too large (yet), you can also migrate to Hibernate Search 6 (in beta, but well tested and approaching the final release). Among many improvements, Hibernate Search 6 has an exists predicate, making the "null token" unnecessary.