My problem is that the in the BaseSolrServer the add(Collection,
Boolean) call does the req.process call inside of it.. so I can't add a
setAction to the updateRequest before it processes. And the add method
also creates a *new* update request inside of it, so I can't set the
action beforehand either.. (the method that gets called is on line 44 of
the BaseSolrServer):
public UpdateResponse add(Collection<SolrInputDocument> docs, boolean
overwrite ) throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.add(docs);
req.setOverwrite(overwrite);
return req.process(this);
}
So there is no way to get at the action of that request.
-----Original Message-----
From: Ryan McKinley [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 15, 2008 1:19 PM
To: [email protected]
Subject: Re: solrj patch to COMMIT with xml
hymm - with 1.3, the standard solrj should work without issue. What do
the logs say when you call commit? What container are you running? I
have tested this extensivly with resin and jetty, but have not touched
tomcat...
To add and commit in one shot, try:
UpdateRequest up = new UpdateRequest();
up.add( docs );
up.setAction( ACTION.COMMIT, true, false );
up.process( client );
ryan
Keene, David wrote:
> Nope, I'm using 1.3 (synced 2 days ago). I'm indexing using using
code
> similar to below, and it creates 2 connections when doing so. Perhaps
> there is a better way to do my indexing so the commit is included with
> the add connction.
>
> Sample indexing code:
>
> UpdateResponse addResponse = client.add( docs );
> UpdateResponse commitResponse = client.commit();
>
> Is there a way to make the client.add(docs) connection add a commit?
>
>
> -----Original Message-----
> From: Ryan McKinley [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 15, 2008 12:54 PM
> To: [email protected]
> Subject: Re: solrj patch to COMMIT with xml
>
> Are you hitting a 1.2 solr index? Using ?commit=true assumes you are
> hitting a 1.3 index...
>
> The reason for it is so you can optionally add docs and commit in one
> call.
>
> ryan
>
>
> Keene, David wrote:
>> Hey guys,
>>
>>
>>
>> I'm not sure why, but the solrj client relies on commit=true on the
>> querystring for committing an index() call. But with the latest svn
>> trunk, my index() calls were not committing. I made a patch to add a
>> <COMMIT/> element to the posted xml so I could index using the solrj
>> client.
>>
>>
>>
>> Did I miss something about how to get commits working in 1.3?
Anyway,
>> here's the patch if you want it.
>>
>>
>>
>> Thanks,
>>
>> Dave
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Index: C:/Documents and
>>
>
Settings/dkeene/workspace/solr.trunk/client/java/solrj/src/org/apache/so
>> lr/client/solrj/request/UpdateRequest.java
>>
>> ===================================================================
>>
>> --- C:/Documents and
>>
>
Settings/dkeene/workspace/solr.trunk/client/java/solrj/src/org/apache/so
>> lr/client/solrj/request/UpdateRequest.java (revision 611919)
>>
>> +++ C:/Documents and
>>
>
Settings/dkeene/workspace/solr.trunk/client/java/solrj/src/org/apache/so
>> lr/client/solrj/request/UpdateRequest.java (working copy)
>>
>> @@ -171,7 +171,14 @@
>>
>> writer.append( "</delete>" );
>>
>> }
>>
>>
>>
>> - // If action is COMMIT or OPTIMIZE, it is sent with params
>>
>> + if (action != null ) {
>>
>> + if (action == ACTION.OPTIMIZE) {
>>
>> +
>> writer.append("<optimize/>");
>>
>> + } else if (action ==
ACTION.COMMIT)
> {
>> +
>> writer.append("<commit/>");
>>
>> + }
>>
>> + }
>>
>> +
>>
>> String xml = writer.toString();
>>
>> //System.out.println( "SEND:"+xml );
>>
>> return (xml.length() > 0) ? xml : null;
>>
>>
>
>