Search returns results for empty search term when opened


  • GNU/Linux

    I have enabled search button in navigation only for admins. When I click on button I get redirected to /search and it also returns search results for empty term - "".

    I've tried uninstalling and installing dbsearch plugin, restarted NodeBB and behavior is still the same.
    This bug occurs only on production, I have same settings on testing forum and it works properly. I'm using version 1.1.2.

    I have some custom CSS and following changes made both on testing and production sites:

    1. https://github.com/NodeBB/NodeBB/pull/5003/commits/fc68b64fe0565a9252c7f54a82b455f800658c97

    2. /nodebb/src/controllers/search.js file:

    1. Custom header:
    <script>
    $(window).on('action:ajaxify.contentLoaded', function(){
      $('.page-category-480 [component="category/post"]').text('Click here to ask a question')
    })
    
    $(window).on('action:composer.loaded', function(event, data){
      // Get the composer elements.
      var comp = $('#cmp-uuid-' + data.post_uuid);
      var catlist = comp.find('.category-list');
      var title = comp.find('input.title');
      if (catlist.length) { // If there's no catlist, then the post is a reply.
        var defaultPlaceholder = title.attr("placeholder");
    
        // Update the placeholder if category is 480, else set it to the default.
        function updatePlaceholder() {
          if (catlist.val() === '480') {
            title.attr("placeholder", "Ask a question");
          } else {
            title.attr("placeholder", defaultPlaceholder);
          }
        }
        // Update placeholder each time the category changes, and once when loaded.
        catlist.change(updatePlaceholder);
        updatePlaceholder();
      }
    });
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(ev, data) {
            $('.page-search #advanced-search button[type="submit"]').clone(true).appendTo('.panel-body.search-options');
        });
    });
    </script>
    

    Is there any existing cache for search terms? Perhaps hasn't been cleared properly? Otherwise I'm out if ideas what could be causing this kind of behavior.


  • Global Moderator

    @metalkramp is your site available to test? It's easier to debug directly.


  • Plugin & Theme Dev

    Opening search seems to be searching for "" when using the nodebb-plugin-dbsearch plugin. Can't replicate on this community as solr plugin is used here instead.


  • GNU/Linux

    Due to problems with dbsearch plugin mentioned above I switched to solr plugin. Seems to resolve problems that occured with dbsearch + solr gives better search results.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.