solrj and appending to existing index

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

solrj and appending to existing index

Otis Gospodnetic-2
Hi,

I took a quick look at solrj.  One thing I didn't find is a way to add documents to an existing index without overwriting the index.  I looked at the sources and the unit tests, but didn't spot the "append modus operandi".  Ryan, or somebody, where should I look?

Thanks,
Otis


Reply | Threaded
Open this post in threaded view
|

Re: solrj and appending to existing index

Brian Whitman



On Jun 26, 2007, at 4:11 PM, Otis Gospodnetic wrote:

> Hi,
>
> I took a quick look at solrj.  One thing I didn't find is a way to  
> add documents to an existing index without overwriting the index.  
> I looked at the sources and the unit tests, but didn't spot the  
> "append modus operandi".  Ryan, or somebody, where should I look?
>


I may be misunderstanding, but I use solrj on an existing index all  
the time. I just

     solr = new CommonsHttpSolrServer(new URL(url));

and then

     SimpleSolrDoc solrDoc = new SimpleSolrDoc();
     solrDoc.addField(field.name(), field.stringValue());
     solr.add(solrDoc);


The indexes in question were created by 'normal solr' and don't get  
overwritten.


Reply | Threaded
Open this post in threaded view
|

RE: solrj and appending to existing index

Will Johnson
In reply to this post by Otis Gospodnetic-2
If you create a SolrServer and start adding documents you are updating
the index with new documents.  If you're id's happen to collide with
ones in the index then you will overwrite those documents but that's the
only way you could end up with less than existing docs + docs added.

- will

-----Original Message-----
From: Otis Gospodnetic [mailto:[hidden email]]
Sent: Tuesday, June 26, 2007 4:12 PM
To: [hidden email]
Subject: solrj and appending to existing index

Hi,

I took a quick look at solrj.  One thing I didn't find is a way to add
documents to an existing index without overwriting the index.  I looked
at the sources and the unit tests, but didn't spot the "append modus
operandi".  Ryan, or somebody, where should I look?

Thanks,
Otis


Reply | Threaded
Open this post in threaded view
|

RE: solrj and appending to existing index

Will Johnson
I just spotted one thing looking at the unit test
org.apache.solr.client.solrj.SolrExampleTestBase

SolrServer server = getSolrServer();
// Empty the database...
server.deleteByQuery( "*:*" );// delete everything!

This is here purely for testing purposes and only so that we know what
is in the index prior to running the rest of the tests (namely nothing).
It's not at all required and probably not really recommended as a best
practice. :)

- will



-----Original Message-----
From: Will Johnson [mailto:[hidden email]]
Sent: Tuesday, June 26, 2007 4:16 PM
To: [hidden email]
Subject: RE: solrj and appending to existing index

If you create a SolrServer and start adding documents you are updating
the index with new documents.  If you're id's happen to collide with
ones in the index then you will overwrite those documents but that's the
only way you could end up with less than existing docs + docs added.

- will

-----Original Message-----
From: Otis Gospodnetic [mailto:[hidden email]]
Sent: Tuesday, June 26, 2007 4:12 PM
To: [hidden email]
Subject: solrj and appending to existing index

Hi,

I took a quick look at solrj.  One thing I didn't find is a way to add
documents to an existing index without overwriting the index.  I looked
at the sources and the unit tests, but didn't spot the "append modus
operandi".  Ryan, or somebody, where should I look?

Thanks,
Otis


Reply | Threaded
Open this post in threaded view
|

Re: solrj and appending to existing index

Otis Gospodnetic-2
In reply to this post by Otis Gospodnetic-2
Aha, maybe that is what happened, thanks!
So this means there is no "switch" for "clear the index first" as there is with Lucene's IndexWriter, for example.  An explicit server.deleteByQuery( "*:*" ); is needed.

Otis

----- Original Message ----
From: Will Johnson <[hidden email]>
To: [hidden email]
Sent: Tuesday, June 26, 2007 10:16:22 PM
Subject: RE: solrj and appending to existing index

If you create a SolrServer and start adding documents you are updating
the index with new documents.  If you're id's happen to collide with
ones in the index then you will overwrite those documents but that's the
only way you could end up with less than existing docs + docs added.

- will

-----Original Message-----
From: Otis Gospodnetic [mailto:[hidden email]]
Sent: Tuesday, June 26, 2007 4:12 PM
To: [hidden email]
Subject: solrj and appending to existing index

Hi,

I took a quick look at solrj.  One thing I didn't find is a way to add
documents to an existing index without overwriting the index.  I looked
at the sources and the unit tests, but didn't spot the "append modus
operandi".  Ryan, or somebody, where should I look?

Thanks,
Otis