apache / apache/lucene

CheckIndex.checkIndex throws IndexNotFoundException: no segments* file found in RAMDirectory@ [LUCENE-6765]

Open
#7,823 1 comment 0 reactions 0 assignees View on GitHub
affects-version:5.2.1 legacy-jira-priority:Minor module:core/index type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

I am testing upgrade from Lucene 4.1 to 5.2.1 and found that behavior of CheckIndex.checkIndex() changed. We used the following to create status for empty dir (we use it for some reporting purpose):

CheckIndex.Status status = new CheckIndex(new RAMDirectory()).checkIndex();

At 5.2.1 it throws:

org.apache.lucene.index.IndexNotFoundException: no segments\* file found in RAMDirectory@51f090da lockFactory=org.apache.lucene.store.SingleInstanceLockFactory@8b6023d: files: []
at org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:487)
at org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:466)

I expect that it should returns status with cantOpenSegments flag on. https://lucene.apache.org/core/5_2_1/core/org/apache/lucene/index/CheckIndex.Status.html#cantOpenSegments

Is it expected behavior?

If this isn't expected, I am willing to provide a fix (should be minor) that I could figure out on it how to contribute.

---
Migrated from [LUCENE-6765](https://issues.apache.org/jira/browse/LUCENE-6765) by Vladimir Kuzmin
Environment:
```
OS X, Lucene 5.2.1
```

Contributor guide

Open the contributing guide

Research direction

Start with CheckIndex.java at the reported checkIndex stack-trace lines and compare the empty RAMDirectory behavior with the Status documentation for cantOpenSegments. Reproduce the example on Lucene 5.2.1, then determine whether an empty directory should return a status or throw IndexNotFoundException; done means the intended behavior is confirmed and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.