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/05/21 15:29:30 UTC

(How) can I use SolrTestCaseJ4.assertQ(..) to test an existing index?

Hello,

Examining Solr Core example it seems that a new index is created in a temp
dataDir deleted after each test (Good practice - agreed). But before I start
debugging adoc(..) I'm wondering if I can query the same index which I see
to work through Solr Web Server interface. Also for large indeces I see it
faster and easier to just copy paste a test resource index and just
assertQ(..) on it.

Examining the logs I figure out that SolrCore.initIndex() never picks up my
index.
The issue is
So far, it's not working me, although I specify the dataDir it always finds
no document.
The issue is that SolrCore.initDirectoryFactory() called from
SolrCore.initIndex()is initialized to RAMDirectoryFactory which
understandably returns false to getDirectoryFactory().exists(indexDir).

Other than hacking to use the StandardDirectoryFactory* how I can test an
existing index?*

It's been multiple days that I'm trying to figure out how to test with Solr!

-- 
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: (How) can I use SolrTestCaseJ4.assertQ(..) to test an existing index?

Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
On Sat, May 21, 2011 at 3:29 PM, Gabriele Kahlout
<ga...@mysimpatico.com>wrote:

> Hello,
>
> Examining Solr Core example it seems that a new index is created in a temp
> dataDir deleted after each test (Good practice - agreed).
>

errr..from a test to the other only dataDir is rm but not the in-memory
index. That's blown away with the core in  @AfterClass . I'm not sure what's
the point then of deleting the dataDir after each test. It's at least
counter-intuitive (to me).

    @Test
    public void testAddDoc() throws Exception {
        final String docUID = getDocUID();
        assertU(*adoc*("id", docUID, "url", getURL(docUID), "content", "blah
blah blah"));
        assertU(commit());
        assertQ(req(anythingQ), "//*[@numFound='*1*']");
    }

    @Test
    public void testAddOtherDoc() throws Exception {
        final String docUID = getDocUID();
        assertU(*adoc*("id", docUID, "url", getURL(docUID), "content", "blah
blah blah"));
        assertU(commit());
        assertQ(req(anythingQ), "//*[@numFound='*2*']");
    }


> But before I start debugging adoc(..) I'm wondering if I can query the
> same index which I see to work through Solr Web Server interface. Also for
> large indeces I see it faster and easier to just copy paste a test resource
> index and just assertQ(..) on it.
>
> Examining the logs I figure out that SolrCore.initIndex() never picks up
> my index.
> The issue is
> So far, it's not working me, although I specify the dataDir it always finds
> no document.
> The issue is that SolrCore.initDirectoryFactory() called from
> SolrCore.initIndex()is initialized to RAMDirectoryFactory which
> understandably returns false to getDirectoryFactory().exists(indexDir).
>
> Other than hacking to use the StandardDirectoryFactory* how I can test an
> existing index?*
>
>  It's been multiple days that I'm trying to figure out how to test with
> Solr!
>
> --
> 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)).
>
>


-- 
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)).