SiteSearch Jquery results

I'm trying to use the jquery plugin to load different views of a search, e.g. A search for apples populates view 1 with regular results, and view 2 only with results tagged with 'featured'. I have gotten this working locally, but when running on my cloud implementation the results from view 1 are being shown in view 2.

The cache div's aren't the same, and i've tried making the id's unique anyway which didn't change behavior. I noticed that the page view count property is being honored, so featured results will return the limit (say, 3), when it should be returning less (there is only one result with a 'featured' tag).

Can i get some help with why i'm getting different results in these circumstances?

Do you have a code sample (e.g., a Gist, CodePen, or Glitch) to look at? It's a little hard to say without any actual code in front of us, sorry (especially puzzling that it would work locally but not on prod!)

      $(function() {
        var query = $('#st-search-input');
          resultContainingElement: '#regular-results-container',
          fetchFields: {"page": ['url','title','subject','keywords','featured','domain']}, 
          engineKey: '<Engine_Key>',
          perPage: 5,

          resultContainingElement: '#featured-results-container',
          fetchFields: {"page":['url','title','subject','keywords','featured','domain']},
          filters: {"page": {"domain": [0],"featured": [1]}},
          perPage: 3,
          engineKey: '<Engine_Key>'


      <input type="text" placeholder="Search" id="st-search-input" />
      <div><h3>These are featured results:</h3></div>
      <div id="featured-results-container"></div>
      <div><h3>These are not featured results:</h3></div>
      <div id="regular-results-container"></div>

Since the featured results are being populated by the non-featured results, i first thought it was a local cache issue, but checking the cache divs revealed nothing. Noteworthy to me is the perPage field, which is behaving correctly in either environment, making me think of a server side cache race condition.

The target production environment is on AEM and Wordpress sites. AEM serving an html page with this code is where i am experiencing this issue.

Edit: Also while investigating this i ran across this stack overflow conversation about jquery libraries that suggests the swiftype code is structured in a risky way.

Thanks for the code snippet! I dug into our Site Search jQuery repo a bit more and it looks like we don't actually have any examples / may not technically support having multiple calls of .swiftypeSearch() per input/per page. @JasonStoltz, can you confirm whether this is a supported or unsupported part of the plugin?

Re: jQuery library setup - very possibly the case, yeah :grimacing: Unfortunately it's an older plugin that predates my time at Elastic, so I'm not sure where we're at on current planned development for it.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.