I can access facet data, but how do I update it after selections are made?

Following the guide here I've created the following search request:

api_search_builder(query_parameters) {
	check(query_parameters, {
		call_type: String,
		query: String,
		page: {
			current: Number,
			size: Number,
		},
	});

	// avoid blocking other method calls from the same client
	this.unblock();

	const query_to_array = [];
	const query_array = query_parameters.query.split(' ');
	const query_array_count = query_array.length;

	for (let i = 0; i < query_array_count; i++) { query_to_array[i] = `${query_array[i]}`; }

	const query = query_to_array.join(' AND ');
	const data = {
		query,
		page: {
			current: query_parameters.page.current,
			size: query_parameters.page.size,
		},
		facets: {
			leaf_class: [{
				type: 'value',
				sort: {
					count: 'desc',
				},
				size: 10,
			}],
			product_type: [{
				type: 'value',
				sort: {
					count: 'desc',
				},
				size: 10,
			}],
			brand_name: [{
				type: 'value',
				sort: {
					count: 'desc',
				},
				size: 10,
			}],
		},
	};

	const headers_and_data = { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${search_api_key}` }, data };
	let complete_api_url = api_url;

	if (query_parameters.call_type === 'search_settings' || query_parameters.call_type === 'search' || query_parameters.call_type === 'multi_search') {
		complete_api_url = `${api_url}${query_parameters.call_type}/?`;
	}

	return HTTP.post(complete_api_url, headers_and_data);
},

But I don't see in the guide how to refine the search more once someone starts clicking on facet options (like color, size, shapet, etc)

Please advise if you require anything further from me to help identify my challenge.

Thank you

Nevermind, I figured out my problem, I was testing with data I typed, not realizing the data needing to be checked had to be case sensitive, and I wasn't typing my test in as case sensitive.

Link for anyone else who might have challenges with thinking they aren't sending the correct API call when searching using filters.

1 Like

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