Hi Chantal,
thank you for the feedback.
I did not see the wood for the trees!
The SolrDocument's javadoc says the following:
http://lucene.apache.org/solr/api/org/apache/solr/common/SolrDocument.html
|*getFieldValue
<../../../../org/apache/solr/common/SolrDocument.html#getFieldValue%28java.lang.String%29>*(String
<http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true> name)|
Get the value or collection of values for a given field.
The magical word here is that little "or" :-).
I will try that tomorrow and give you a feedback!
Are you sure that you cannot change the SOLR results at query time
according to your needs?
Unfortunately, it is not possible in this case.
Kind regards,
Mitch
Am 28.07.2010 16:49, schrieb Chantal Ackermann:
Hi Mitch
On Wed, 2010-07-28 at 16:38 +0200, MitchK wrote:
Thank you, Chantal.
I have looked at this one: http://www.json.org/java/index.html
This seems to be an easy-to-understand-implementation.
However, I am wondering how to determine whether a SolrDocument's field
is multiValued or not.
The JSONResponseWriter of Solr looks at the schema-configuration.
However, the client shouldn't do that.
How did you solved that problem?
I didn't. I'm not recreating JSON from the SolrJ results.
I would try to use the same classes that SolrJ uses, actually. (Writing
that without having a further look at the code.) I would avoid
recreating existing code as much as possible.
About multivalued fields: you need instanceof checks, I guess. The field
only contains a list if there really are multiple values. (That's what
works for my ScriptTransformer.)
Are you sure that you cannot change the SOLR results at query time
according to your needs? Maybe you should ask for that, first (ask for X
instead of Y...).
Cheers,
Chantal
Thanks for sharing ideas.
- Mitch
Am 28.07.2010 15:35, schrieb Chantal Ackermann:
You could use org.apache.solr.handler.JsonLoader.
That one uses org.apache.noggit.JSONParser internally.
I've used the JacksonParser with Spring.
http://json.org/ lists parsers for different programming languages.
Cheers,
Chantal
On Wed, 2010-07-28 at 15:08 +0200, MitchK wrote:
Hello ,
Second try to send a mail to the mailing list...
I need to translate SolrJ's response into JSON-response.
I can not query Solr directly, because I need to do some math with the
responsed data, before I show the results to the client.
Any experiences how to translate SolrJ's response into JSON without writing
your own JSON Writer?
Thank you.
- Mitch