response XML

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

response XML

Erik Hatcher
I'm adding multiple documents per <add> POST and getting a response  
that looks like this:

<result status="0"></result><result status="0"></result><result  
status="0"></result><result status="0"></result><result status="0"></
result><result status="0"></result>

This response is several separate XML documents, rather than a single  
one as I was expecting - which makes parsing the response more  
difficult.

I'm curious why this approach was taken rather than a single well-
formed XML response being returned, and whether changing this is  
acceptable.  It would perhaps also be nice to get some context back  
for each document added, like its unique key, so a response can  
easily be correlated with an <add> other than aligning indexes.

Thanks,
        Erik

Reply | Threaded
Open this post in threaded view
|

Re: response XML

Chris Hostetter-3

: I'm curious why this approach was taken rather than a single well-
: formed XML response being returned, and whether changing this is
: acceptable.  It would perhaps also be nice to get some context back
: for each document added, like its unique key, so a response can
: easily be correlated with an <add> other than aligning indexes.

Accepting multiple <docs> in a single <add> was kind of hacked on very
late in Sol[a]r's development.  I don't think Yonik really thought about
the format of the resulting response (or the fact that it's not a valid
document in and of itself.

This was/is accutally the first reported "Apache Solr" bug, still open...

        http://issues.apache.org/jira/browse/SOLR-2


I think if nothing else, the response should be wellformed, and the
outermost tag should be a <result status=""> indicating the result of the
entire add operation.  in the case of multiple docs (or perhaps in all
cases) it can contain a seperate nested <result status=""/> for each doc
... adding an attribute with the uniqueKey (if there is a uniqueKey field
in the schema) would probably be a good idea as well.



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: response XML

Yonik Seeley
In reply to this post by Erik Hatcher
On 4/27/06, Erik Hatcher <[hidden email]> wrote:

> I'm adding multiple documents per <add> POST and getting a response
> that looks like this:
>
> <result status="0"></result><result status="0"></result><result
> status="0"></result><result status="0"></result><result status="0"></
> result><result status="0"></result>
>
> This response is several separate XML documents, rather than a single
> one as I was expecting - which makes parsing the response more
> difficult.
>
> I'm curious why this approach was taken rather than a single well-
> formed XML response being returned

The ability to add more than one document at once was an undocumented
feature (untested even) that became semi-documented/supported when
someone discovered it (mostly) worked.  Things just sort of defaulted
to responding as if multiple add commands had been received.

Since the request is a single XML document, so should the response.

>, and whether changing this is
> acceptable.

+1

> It would perhaps also be nice to get some context back
> for each document added, like its unique key, so a response can
> easily be correlated with an <add> other than aligning indexes.

Document's aren't always required to have a unique id, but when they
do, it could be added to a response.

What about other commands that aren't related to a single document?
Is there a need for a correlationId that Solr can echo back?

-Yonik