Results 1 to 8 of 8

Thread: ExtJS Store not able to display SOLR JSON string

  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158

    Default ExtJS Store not able to display SOLR JSON string

    I am working with Apache SOLR search engine to display search results into an ExtJS Grid. SOLR supports a JSON result so I've mapped up just ID to start with to see if I could get that to work. Whenever I try to run this, I don't see the grid getting filled in. Any ideas?

    Here's my JSON result from SOLR:

    Code:
    strcallback1001({
     "responseHeader":{
      "status":0,
      "QTime":2,
      "params":{
    	"json.wrf":"strcallback1001",
    	"indent":"on",
    	"wt":"json",
    	"rows":"10",
    	"version":"2.2",
    	"fl":"*,score",
    	"start":"0",
    	"q":"bird",
    	"qt":"dismax",
    	"fq":""}},
     "response":{"numFound":3293,"start":0,"maxScore":0.14686589,"docs":[
    	{
    	 "id":"1088101",
    	 "timestamp":"2009-11-19T19:55:14.392Z",
    	 "popularity":0,
    	 "score":0.14686589},
    	...
    Heres is the ExtJS code:

    Code:
        
         var ds = new Ext.data.Store({
            proxy: new Ext.data.ScriptTagProxy({
                url: 'http://solrdev/solr/select/'
            }),
            reader: new Ext.data.JsonReader({
                id:   'id',
                totalProperty: 'response.numFound',
                root: 'response.docs'
            }, Ext.data.Record.create([
                {
                    name:'id'
                }
            ])),
            baseParams: {q:'bird',version:'2.2',start:'0',rows:'10',indent:'on',qt:'dismax',wt:'json',"json.wrf":"strcallback1001"}
        });
    
        var grid = new Ext.grid.GridPanel({
            store: ds,
    
            columns: [
                {
                    header: 'ID',
                    width: 120,
                    sortable: true,
                    dataIndex: 'id'
                }
            ],
            viewConfig: {
                forceFit: false
            },
            renderTo: 'content',
            title: 'SOLR Grid',
            width: 500,
            autoHeight: true,
            frame: true
        });
    
        grid.getSelectionModel().selectFirstRow();
        ds.load();

  2. #2
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78

    Default

    I'm not real familiar with script tag proxy's, how is your function strcallback1001 getting called?

  3. #3
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78

    Default

    do you need to add callbackParam: "strcallback1001" to your scriptTagProxy config?

  4. #4
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158

    Default

    Quote Originally Posted by jnicora View Post
    do you need to add callbackParam: "strcallback1001" to your scriptTagProxy config?
    Yes, I've tried that as well. I've tried with and without the callback approach as well as moving the params up into the URL and that didn't work either.

  5. #5
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158

    Default

    Actually, I had a typo. It should of been "stcCallback1001". That works when setting both in the params and the callback param. Thank you!

  6. #6

    Default Actually you dont need to state the function name at all

    It seems im doing the same as you are .. This is my working code. You just specify callbackParam:'json.wrf' and Ext will tell SOlr whar the function should be called.

    Code:
    proxy: new Ext.data.ScriptTagProxy({
               url: 'http://solr.mydomain.com:8080/solrdev/select/?',
               method: 'GET',
    	   callbackParam:'json.wrf'
    }),
    baseParams: {
               q: 'test',
    	   start:'0',
    	   version:'2.2',
    	   rows:'10',
    	   indent:'on',
    	   sort:'subject asc',
    	   wt:'json'
    }

  7. #7
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158

    Default How about remote sorting?

    Thank you Fredric...that works much better for me.

    I noticed that you have sort as part of your base params. This works fine for the initial pull but I've noticed that if I try to sort a column (using GroupingStore) it only sorts the rows on that page. I've read that you need to use "remoteSort:true" to get it to call the service again but it requires you to have two parameters (sort and dir). Unfortunately, SOLR sort of combines those in "sort". Have you found a way to manage sort with SOLR without writing some sort of wrapper?

  8. #8

    Default Combining sort and dir into one parameter

    Hi locutusUT

    Nice that im not the only one that uses solR. Well i havent come that far yet , but it will certantly be crucual for me to solve that issue too.

    There must be a way to override that handling on remoteSort. If you beat me to the goal, please let me know.

    Some more useful things regarding SolR and Ext JS together

    *If you start using comboboxes with livesearch functions. Dont forget the queryParam: 'q' for changing the pameter name for "query"

    *if you use pagination you must change parameter name for "limit" to "rows" using the paramNames: {limit:'rows'} on the store you are using

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •