Description:
|
Complex issue; I don't have time to boil it down to a simple test case, but will attempt to explain clearly:
Recent Index changes are not visible through the IndexReader passed to a Lucene Filter set on a FullTextQuery.
Example:
- I create a new Foo, id: 1, and persist it through entityManager.persist()
- I examine indexes with Luke, they are updated. Foo #1 is present.
- I perform a simple lucene search using Hibernate Search, Foo #1 is fetched.
Now, I run another query, this time using a query Filter that reads from the IndexReader passed to the getDocIdSet(IndexReader reader) method like so:
reader.docFreq(new Term("id", "1"))
I would expect this to return 1, since I just persisted a Foo with ID 1. However, it returns 0.
If however, I check out an IndexReader instance from the searchFactory, and perform the same command like so:
IndexReader reader = entityManager.getSearchFactory().getIndexReaderAccessor().open(Foo.class);
reader.docFreq(new Term("id", "1"))
Now the reader successfully returns 1, for the entity I had recently persisted.
Currently I work around this issue by manually checking out an IndexReader from the searchFactory, passing it to my Filter, and checking it in after the query runs. But, this is pretty clunky.
Shouldn't the Filter be getting the same current IndexReader?
|