Thank you for the explanation.

It looks like the serialization routine in one case (solr) encodes
characters_to_binary()
and by normal fetch not. Assuming we fetch in JSON in both cases.

I'm requesting same data in same format, i.e. JSON.
Once by fetching object like /buckets/bucket/keys/key.
And second time by using solr query
/solr/index_name/select?q=kex_name:value.
And I get different results, i.e. differently encoded JSON.
Both requests give me exactly the same key back. From "user abstraction
level" I was expecting the same results.

Probably riak folks could give me an advice how to convince riak give me
exactly the same result back in both cases. Are there any config options
for?

Thanks in advance!
Vladimir



On Sun, Aug 26, 2012 at 6:07 PM, Olav Frengstad <o...@fwt.no> wrote:

> The current implementation uses mochiweb2 to serialize JSON. By itself
> mochijson2 produces the output you expect (src/riak_solr_output.erl):
>
> 55> io:format("~s~n", [mochijson2:encode("Sabinastraße")]).
> [83,97,98,105,110,97,115,116,114,97,223,101]
>
> But since everything is mapped according to your schema the actual
> call handling the encoding looks like this:
>
> 56 > io:format("~s~n",
> [mochijson2:encode([unicode:characters_to_binary("Sabinastraße")])]).
> ["Sabinastra\u00dfe"]
>
> The reason for the difference in your results comes down to JSON using
> convert_type/2 when serializing data and XML doesn't. Unfortunately I
> don't know why the the difference in serialization routines.
>
> Hope this answers your question.
>
> Olav
>
> 2012/8/26 Vladimir Shapovalov <shapova...@gmail.com>:
> > Hey Olaf,
> >
> > Thanks for the answer.
> >
> > Yep, I know, it's JSON compliant.
> > The question is, why the unicode escaped sequences appear only in case of
> > searching and retrieveing in JSON? This is not the case in XML output.
> >
> > If I just get the same key directly in JSON, the unicode chars are NOT
> > escaped.
> >
> > Cheers
> > Vladimir
> >
> >
> > On Sun, Aug 26, 2012 at 4:55 PM, Olav Frengstad <o...@fwt.no> wrote:
> >>
> >> Hey,
> >>
> >> \00df is the unicode representation of ß. The JSON spec states that
> >> "Any character may be escaped" so it is valid JSON.
> >>
> >> Your JSON parser should handle this automatic.
> >>
> >> Cheers,
> >> Olav
> >> 2012/8/25 Vladimir Shapovalov <shapova...@gmail.com>:
> >> > Hi all,
> >> >
> >> > I've a key in a bucket, witch is indexed.
> >> >
> >> > {
> >> > ...
> >> > "street":"Sabinastraße"
> >> > ...
> >> > }
> >> >
> >> > If I retrieve the key this way:
> >> > curl -i -v http://localhost:8098/buckets/is_solr/keys/123
> >> >
> >> > The response looks like:
> >> >
> >> > {
> >> > ...
> >> > "street":"Sabinastraße"
> >> > ...
> >> > }
> >> > which is correct.
> >> >
> >> > If I search for key and expect XML output:
> >> > curl -i -v
> >> >
> >> > "
> http://localhost:8098/solr/is_solr/select?wt=xml&q=street:Sabinastra%C3%9Fe
> "
> >> >
> >> > Response:
> >> > <response>
> >> > ...
> >> > <result name="response" numFound="1" start="0" maxScore="0.353553">
> >> > <doc>
> >> > ...
> >> >   <str name="street">Sabinastraße</str>
> >> >   ...
> >> > </doc>
> >> > </result>
> >> > </response>
> >> >
> >> > wich is also correct.
> >> >
> >> > But in case the format of the output is JSON:
> >> > curl -i -v
> >> >
> >> > "
> http://localhost:8098/solr/is_solr/select?wt=json&q=street:Sabinastra%C3%9Fe
> "
> >> >
> >> > result looks differently:
> >> > ...
> >> > "street":"Sabinastra\u00dfe"
> >> > ...
> >> >
> >> > Why is the JSON response looks differently then XML?
> >> > Is it an expected output or I'm doing something wrong?
> >> >
> >> > Thanks in advance!
> >> > Vladimir
> >> >
> >> > _______________________________________________
> >> > riak-users mailing list
> >> > riak-users@lists.basho.com
> >> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> >> >
> >>
> >>
> >>
> >> --
> >> Med Vennlig Hilsen
> >> Olav Frengstad
> >>
> >> Systemutvikler // FWT
> >> +47 920 42 090
> >
> >
>
>
>
> --
> Med Vennlig Hilsen
> Olav Frengstad
>
> Systemutvikler // FWT
> +47 920 42 090
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to