Issue Type: Bug Bug
Affects Versions: 4.1.1.Final
Assignee: Unassigned
Components: query
Created: 05/Nov/12 3:45 PM
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:

  1. I create a new Foo, id: 1, and persist it through entityManager.persist()
  2. I examine indexes with Luke, they are updated. Foo #1 is present.
  3. 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?

Project: Hibernate Search
Priority: Major Major
Reporter: Clark Duplichien
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira