lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Sokolov <msoko...@gmail.com>
Subject Re: SearcherManager not seeing changes in IndexWriteral and
Date Fri, 09 Nov 2018 13:29:26 GMT
I'm not seeing anything there that would synchronize, or serialize, the
read after the write and commit. Did you expect that for some reason?

On Fri, Nov 9, 2018, 6:00 AM Boris Petrov <boris_petrov@live.com wrote:

> Hi all,
>
> I'm using Lucene version 7.5.0. We have a test that does something like:
>
> Thread 1:
>
>             Field idStringField = new StringField("id", id,
> Field.Store.YES);
>             Field contentsField = new TextField("contents", reader);
>             Document document = new Document();
>             document.add(idStringField);
>             document.add(contentsField);
>
>             writer.updateDocument(new Term(ID_FIELD, id), document);
>             writer.flush(); // not sure this flush is needed?
>             writer.commit();
>
> Thread 2:
>
>             searchManager.maybeRefreshBlocking();
>             IndexSearcher searcher = searchManager.acquire();
>             try {
>                 QueryParser parser = new QueryParser("contents", analyzer);
>                 Query luceneQuery = parser.parse(queryText);
>                 ScoreDoc[] hits = searcher.search(luceneQuery,
> 50).scoreDocs;
>             } finally {
>                 searchManager.release(searcher);
>             }
>
> Thread 1 happens before Thread 2.
>
> Sometimes, only sometimes, the commit from thread 1 is not *immediately*
> visible in Thread 2. If I put a "Thread.sleep(1000)" it always works.
> Without it, sometimes the search is empty. I'm not sure if I'm doing
> something wrong or this is a bug?
>
> Thanks!
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message