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

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

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

malic
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.
Reply | Threaded
Open this post in threaded view
|

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

Erick Erickson
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 <[hidden email]> 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.
>
Reply | Threaded
Open this post in threaded view
|

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

Chris Hostetter-3
In reply to this post by malic

: *What I want:* to change the output by embedding the highlighting properties
: into the response properties, such that the response part looks like:

Work along the lines of making this a generally available feature is
already in progress on the trunk as part of the "psuedo fields" work
(SOLR-2444) ... as i understand it from Ryan/Yonik, the idea would be to
implement a "highlight" transformer...

        https://issues.apache.org/jira/browse/SOLR-2444
        https://wiki.apache.org/solr/CommonQueryParameters#Transformers:

...but i don't think anyone has taken a crack at it yet (i don't see any
open issues specificly for this) so feel free to give it a shot.



-Hoss