Changing filters dynamically

Hi there,
We're using the jquery client library for our custom search along with using "domain-identifier" to filter our results from 3 different domains.

Im having a hard time trying to figure out how to use the jquery swiftype-search-jquery to change the filter parameter and have it picked up by the plugin object.

Currently have 3 call to actions, each with a click event to build a new filter object, however i dont know how to pass this changed object to the existing $el.swifttypeSearch({}) object. I hope that makes sense.

var searchScope = function(){
	....some biz logic here...

	if(onClickSearchScope>0){
		return {'page': {'domain-identifier':onClickSearchScope}};
	} else {
		return {};
	}
	
};

$('.st-default-search-input').swiftypeSearch({
		resultContainingElement: '.st-search-container',
		engineKey: 'myEngineIDHere',
		renderFunction: customRenderFunction,
		perPage: 20,
		filters: searchScope()		
	});

Any help would be appreciated

I finally figured out how to accomplish this, by putting the function call directly within the swiftypeSearch instantiation call:

$('.st-default-search-input').swiftypeSearch({
	resultContainingElement: '.st-search-container',
	engineKey: 'myEngineIDHere',
	renderFunction: customRenderFunction,
	perPage: 20,
	filters:  function(){
		return {'page': {'domain-identifier':1}};
	}		
});
2 Likes

Hey there, cakePlease.

Looks like you have found the right solution.

Enjoy the week,

Kellen

Ps. "Uh, death, please. No, cake! Cake! Cake, sorry. Sorry..."

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