[
https://issues.apache.org/jira/browse/SOLR-9442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15683903#comment-15683903
]
Christine Poerschke commented on SOLR-9442:
-------------------------------------------
bq. Well, I guess don't really see what usecases the "arrnvp" format (already
committed) serves that aren't equally/better served with the "arrntv" format
... if you find it more useful then what I suggested then i guess it has a
purpose as well ... i'm just not seeing it.
The difference, as I see it, between "arrnvp" and "arrntv" format is very
subtle, let's see if perhaps an example helps illustrate it.
Both "arrnvp" result
{code}
NamedList(foo=42) => [ { "name":"foo", "int":42 } ]
{code}
and "arrntv" result
{code}
NamedList(foo=42) => [ { "name":"foo", "type":"int", "value":42 } ]
{code}
contain information equivalent to
{code}
<lst name="someField">
<int name=“foo”>42</int>
</lst>
{code}
xml format.
In the "know beforehand what to expect" use case, let's say the expectation is
"int" type and hence the client does
{code}
myName = asString(someField, "name")
myInt = asInt(someField, "int")
{code}
for the "arrnvp" format.
For the "arrntv" format
{code}
# option 1
myName = asString(someField, "name")
myInt = asInt(someField, "value")
{code}
means that the "type" attribute is totally ignored or alternatively
{code}
# option 2
myName = asString(someField, "name")
assert "int" == asString(someField, "type")
myInt = asInt(someField, "value")
{code}
means "int-ness" checks happens twice since theoretically "type" and "value"
could mismatch.
bq. I suppose my main concern with having both is making sure the tests/docs
make it very clear how things behave with either the name or the value (or
both) are null.
I agree the tests and docs could have been clearer (not just for "arrnvp") as
far as null name and/or null value go. SOLR-9782 has now improved them.
bq. ... what JSON attribute(s) will exist for the equivalents of things like
<null name="bar"/> or <null/> since there is no "type" to use as a JSON
attribute name ...
Taking your {{NamedList("bar”=null,null=true,null=null)}} example,
with "arrnvp" the result is
{code}
[
{ "name":"bar", "null":null },
{ "name":null, "bool":true },
{ "name":null, "null":null }
]
{code}
and with "arrntv" the result will be
{code}
[
{ "name":"bar", "type":"null", "value":null },
{ "name":null, "type":"bool", "value":true },
{ "name":null, "type":"null", "value":null }
]
{code}
i.e. the "type" for null values is called "null".
> Add json.nl=arrnvp (array of NamedValuePair) style in JSONResponseWriter
> ------------------------------------------------------------------------
>
> Key: SOLR-9442
> URL: https://issues.apache.org/jira/browse/SOLR-9442
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Components: Response Writers
> Reporter: Jonny Marks
> Assignee: Christine Poerschke
> Priority: Minor
> Fix For: master (7.0), 6.4
>
> Attachments: SOLR-9442-arrntv.patch, SOLR-9442.patch,
> SOLR-9442.patch, SOLR-9442.patch
>
>
> The JSONResponseWriter class currently supports several styles of NamedList
> output format, documented on the wiki at http://wiki.apache.org/solr/SolJSON
> and in the code at
> https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java#L71-L76.
> For example the 'arrmap' style:
> {code}NamedList("a"=1,"b"=2,null=3) => [{"a":1},{"b":2},3]
> NamedList("a"=1,"bar”=“foo",null=3.4f) => [{"a":1},{"bar”:”foo"},{3.4}]{code}
> This patch creates a new style ‘arrnvp’ which is an array of named value
> pairs. For example:
> {code}NamedList("a"=1,"b"=2,null=3) =>
> [{"name":"a","int":1},{"name":"b","int":2},{"int":3}]
> NamedList("a"=1,"bar”=“foo",null=3.4f) =>
> [{"name":"a","int":1},{"name":"b","str":"foo"},{"float":3.4}]{code}
> This style maintains the type information of the values, similar to the xml
> format:
> {code:xml}<lst name=“someField”>
> <int name=“a”>1</int>
> <str name=“bar”>foo</str>
> <float>3.4</float>
> </lst>{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]