You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gabriele Kahlout <ga...@mysimpatico.com> on 2011/07/14 10:26:06 UTC

Why cannot I open a read-only IndexReader from TestHarness.getIndexDir() ?

 IndexReader getReader() throws CorruptIndexException, IOException {
        return IndexReader.open(FSDirectory.open(new
File(h.getCore().getIndexDir())), true);
    }

*org.apache.lucene.index.IndexNotFoundException: no segments* file found in
org.apache.lucene.store.NIOFSDirectory@/private/var/folders/54/54wUdohaH8eR-mvbJL0l2k+++TI/-Tmp-/solrtest-SolrTestCaseJ4-1310631397578/index
lockFactory=org.apache.lucene.store.NativeFSLockFactory@62d337d3: files: []*
    at
org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:694)
    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)
    at org.apache.lucene.index.IndexReader.open(IndexReader.java:428)
    at org.apache.lucene.index.IndexReader.open(IndexReader.java:288)
    at com.mysimpatico.me.indexplugins.SolrTest.getReader(SolrTest.java:43)

I'm calling it right after a assertU(commit()) and assertQ(req("*:*"),
getNumFoundXPath(1)) which asserts a document has been indexed.

-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: Why cannot I open a read-only IndexReader from TestHarness.getIndexDir() ?

Posted by Chris Hostetter <ho...@fucit.org>.
:         return IndexReader.open(FSDirectory.open(new
: File(h.getCore().getIndexDir())), true);
:     }
: 
: *org.apache.lucene.index.IndexNotFoundException: no segments* file found in

I haven't dug into it, but i seem to recall that there were some changes a 
while back to the TestHarness and solr base test classes to start using 
Randomized Directory impls that help with verifying the code on more 
varieties of platforms.  I suspect that it's also using a RAM Based 
directories, and that nothing is ever actually getting 
written to the getIndexDir() directory.

IN general, now that multiple types of IndexReader and DirectoryProvider 
factories are supported, you can't (in general) assume that 
SolrCore.getIndexDir() will actually exist (let alone be used)

As a side comment...

You seem to be going out of your way to work arround the abstraction solr 
provides, which isn't really a good idea in Solr, let alone in tests of 
solr.  I smell a probable XY problem...

	http://people.apache.org/~hossman/#xyproblem

...can you explain what your *goal* is (indepentent of the approach you 
are taking to do it), and then maybe folks can make better suggestions 
about a better approach?



-Hoss

Re: Why cannot I open a read-only IndexReader from TestHarness.getIndexDir() ?

Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
i don't know about the path, TestHarness chose it (seems like a temporary
directory). Does this work for you?


        assertU(adoc(id, "0", "url", getURL(docUID), content, "blah blah
blah");
        assertU(commit());
        assertNumFound(1); //this is a helper method of mine
IndexReader.open(FSDirectory.open(new File(h.getCore().getIndexDir())),
true); //for me it fails here. But since the document was added I suspect
this is a bug


On Thu, Jul 14, 2011 at 10:48 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Thu, Jul 14, 2011 at 1:56 PM, Gabriele Kahlout
> <ga...@mysimpatico.com>wrote:
>
> >  IndexReader getReader() throws CorruptIndexException, IOException {
> >        return IndexReader.open(FSDirectory.open(new
> > File(h.getCore().getIndexDir())), true);
> >    }
> >
> > *org.apache.lucene.index.IndexNotFoundException: no segments* file found
> in
> > org.apache.lucene.store.NIOFSDirectory@
> >
> /private/var/folders/54/54wUdohaH8eR-mvbJL0l2k+++TI/-Tmp-/solrtest-SolrTestCaseJ4-1310631397578/index
> > lockFactory=org.apache.lucene.store.NativeFSLockFactory@62d337d3: files:
> > []*
> >    at
> >
> >
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:694)
> >    at
> org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)
> >    at org.apache.lucene.index.IndexReader.open(IndexReader.java:428)
> >    at org.apache.lucene.index.IndexReader.open(IndexReader.java:288)
> >    at
> com.mysimpatico.me.indexplugins.SolrTest.getReader(SolrTest.java:43)
> >
> > I'm calling it right after a assertU(commit()) and assertQ(req("*:*"),
> > getNumFoundXPath(1)) which asserts a document has been indexed.
> >
> >
> I'm not sure but the error indicates that the index does not exist. Perhaps
> the path is wrong?
>
> --
> Regards,
> Shalin Shekhar Mangar.
>



-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: Why cannot I open a read-only IndexReader from TestHarness.getIndexDir() ?

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Thu, Jul 14, 2011 at 1:56 PM, Gabriele Kahlout
<ga...@mysimpatico.com>wrote:

>  IndexReader getReader() throws CorruptIndexException, IOException {
>        return IndexReader.open(FSDirectory.open(new
> File(h.getCore().getIndexDir())), true);
>    }
>
> *org.apache.lucene.index.IndexNotFoundException: no segments* file found in
> org.apache.lucene.store.NIOFSDirectory@
> /private/var/folders/54/54wUdohaH8eR-mvbJL0l2k+++TI/-Tmp-/solrtest-SolrTestCaseJ4-1310631397578/index
> lockFactory=org.apache.lucene.store.NativeFSLockFactory@62d337d3: files:
> []*
>    at
>
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:694)
>    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)
>    at org.apache.lucene.index.IndexReader.open(IndexReader.java:428)
>    at org.apache.lucene.index.IndexReader.open(IndexReader.java:288)
>    at com.mysimpatico.me.indexplugins.SolrTest.getReader(SolrTest.java:43)
>
> I'm calling it right after a assertU(commit()) and assertQ(req("*:*"),
> getNumFoundXPath(1)) which asserts a document has been indexed.
>
>
I'm not sure but the error indicates that the index does not exist. Perhaps
the path is wrong?

-- 
Regards,
Shalin Shekhar Mangar.