You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erick Erickson <er...@gmail.com> on 2011/09/01 14:45:53 UTC

Re: [Q]Solr response passed to remote JsonStore - highlighting properties embed in the response part

You probably want to write your own ResponseWriter,
since you're working in JSON, maybe
JSONResponseWriter is the place to start.

Best
Erick

On Wed, Aug 31, 2011 at 4:58 AM, malic <be...@yahoo.com.hk> wrote:
> Hello, I have a very specific question about the Solr response passed to
> remote JsonStore.
>
> *Solr response passed to remote JsonStore*
>
> var myJsonStore =  new Ext.data.JsonStore({
>            // store configs
>                        url: myurl,
>                        baseParams:
> {'wt':'json','facet':true,'facet.limit':-1,'facet.sort':'description','hl':true,'hl.fl':'*'},
>          // reader configs
>                        totalProperty: 'total',
>                        idProperty: 'handle',
>                        root:function(v){
>                                return v.response.docs;
>                        },
>                        fields: ['handle', 'description']
> })
>
> *Solr standard output:*
>
> {
>    "responseHeader": {
>        "status": 0,
>        "QTime": 32
>    },
>    "response": {
>        "total": 21,
>        "start": 0,
>        "docs": [
>            {
>                "description": "The matte finish waves on this wedding band
> contrast with the high polish borders. This sharp and elegant design was
> finely crafted in Japan.",
>                "handle": "8252",
>
>            },
>            {
>                "description": "This elegant ring has an Akoya cultured
> pearl with a band of bezel-set round diamonds making it perfect for her to
> wear to work or the night out.",
>                "handle": "8142",
>
>            },
>
>        ]
>    },
>    "highlighting": {
>        "8252": {
>            "description": [
>                " and <em>elegant</em> design was finely crafted in Japan."
>            ]
>        },
>        "8142": {
>            "description": [
>                "This <em>elegant</em> ring has an Akoya cultured pearl with
> a band of bezel-set round diamonds making"
>            ]
>        },
>
>    }
> }
>
>
> *What I want:* to change the output by embedding the highlighting properties
> into the response properties, such that the response part looks like:
>
>    "response": {
>        "numFound": 21,
>        "start": 0,
>        "docs": [
>            {
>                "description": "The matte finish waves on this wedding band
> contrast with the high polish borders. This sharp and <em>elegant</em>
> design was finely crafted in Japan.",
>                "UID_PK": "8252",
>
>            },
>            {
>                "description": "This <em>elegant</em> ring has an Akoya
> cultured pearl with a band of bezel-set round diamonds making it perfect for
> her to wear to work or the night out.",
>                "UID_PK": "8142",
>
>            },
>
>        ]
>    },
>
> Can anyone suggest an approach to do this? Thx a lot.
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Q-Solr-response-passed-to-remote-JsonStore-highlighting-properties-embed-in-the-response-part-tp3297811p3297811.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>