Ajax-solr stops working if search returns no results

74 views
Skip to first unread message

Dave Kaye

unread,
Nov 7, 2014, 3:54:07 PM11/7/14
to ajax...@googlegroups.com
I posted this a few weeks ago but then talked myself out of thinking there's a bug.  There is but it only comes about under specific conditions.

One specific condition is if I search for something that's not in the database, like "gniorb."  Once a search returns no results the site does not work again without a reload.

Any suggestions?  I unfortunately can't point y'all to the site since it's behind our corporate firewall...

Thanks,

Dave.

Dave Kaye

unread,
Nov 7, 2014, 5:48:32 PM11/7/14
to ajax...@googlegroups.com
And who doesn't want to see some code!  Here's the part that's not working (I think):

var Manager;

function managerMaker() {
    Manager.init();
   var langVal = $('#langSelect').val(), langQ = langVal + ':[* TO *]', searchVal = 'enu:' + $('#sLangSearch').val(), rowsReturned = $('#numItemsSelect').val();
   Manager.store.addByValue('q', langQ);
   Manager.store.addByValue('fq', searchVal);
   console.log(rowsReturned);
   Manager.store.addByValue('rows', rowsReturned);
   Manager.store.addByValue('fl', 'product enu resource release ' + langVal);
   Manager.doRequest();
}

(function ($) {

  $(function () {
    Manager = new AjaxSolr.Manager({
      solrUrl: 'http://xx.xx.xx.xx:8983/solr/'
    });

    Manager.addWidget(new AjaxSolr.ResultWidget({
    id:'result',
    target:'#docs'
    }));

    Manager.addWidget(new AjaxSolr.PagerWidget({
    id: 'pager',
    target: '#pager',
    prevLabel: 'Previous',
    nextLabel: 'Next',
    innerWindow: 1,
    renderHeader: function (perPage, offset, total) {
    $('#pager-header').html($('<span></span>').text('displaying ' + Math.min(total, offset + 1) + ' to ' + Math.min(total, offset + perPage) + ' of ' + total));
    $('#rResults').text("Total results: " + total);
    }

    }));

    //tag cloud addition
    /*var fields = ['enu','id','product', 'resource'];
    for (var i = 0, l = fields.length; i<l; i++) {
    Manager.addWidget(new AjaxSolr.TagcloudWidget({
    id:fields[i],
    target: '#' + fields[i],
    field: fields[i]
    }));
    }*/


  });

})(jQuery);

Dave Kaye

unread,
Nov 10, 2014, 9:51:23 AM11/10/14
to ajax...@googlegroups.com
This is going to happen to someone else...the problem is I was not clearing out the fq: setup each time so of course the search wouldn't run.  So no, not a crash, just an inability to find anything matching as the search continued to build and build.

Dave.

James McKinney

unread,
Nov 10, 2014, 10:59:32 AM11/10/14
to ajax...@googlegroups.com
Thanks for posting the solution!

On Nov 10, 2014, at 9:51 AM, Dave Kaye <ray...@gmail.com> wrote:

This is going to happen to someone else...the problem is I was not clearing out the fq: setup each time so of course the search wouldn't run.  So no, not a crash, just an inability to find anything matching as the search continued to build and build.

Dave.

--
You received this message because you are subscribed to the Google Groups "ajax-solr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ajax-solr+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages