Question

I'm using Hibernate Search 4.4.0 in Infinispan. I'm trying to search the date of inserting docs. And I have saved date in type String.

This is the definition of date in my class:

private String ins = Constants.dateFormat.format(new Date());

And the dateFormat is:

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

Now I mapping this field like:

mapping.entity(Entity.class)
   .property("ins", ElementType.FIELD).field().analyze(Analyze.NO);

I have verified that there are objects in my cache whose date property is 2012-09-17 14:28:32.0. But when I use query like:

Query query = queryBuilder.keyword().onField("ins").matching("2012-09-17").creatQuery();

to search in cache, there is no result.

Is there something I messed up??

Was it helpful?

Solution

I'm not an expert in Hibernate Search, but I think that instead of

.analyze(Analyze.NO)

you shall write

.analyze(Analyze.NOT_TOKENIZED)

or alike

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top