Filter out attributes that don’t contain the searched string

Hi,
How can I filter out attributes that don’t contain the searched string?

search.addWidgets([
{
init(opts) {
const helper = opts.helper;
const input = document.querySelector(’#searchbox’);
input.addEventListener(‘input’, ({currentTarget}) => {
helper.setQuery(currentTarget.value)
.search();
});
}
},
{
render(options) {
const results = options.results;
var img = document.createElement(“img”);
img.src = “image.png”;
var src = document.getElementById(“clearfix”);
src.appendChild(img);
document.querySelector(’#hits’).innerHTML = results.hits
.map(
hit => <div id="clearfix" > ${instantsearch.highlight({ attribute: 'CONTENT', hit })} ${instantsearch.highlight({ attribute: 'GAIYO', hit })} ${instantsearch.highlight({ attribute: 'LOCATION', hit })} </div>
)
.join(’’);
},
}
]);

Hi @ynaka, you may need to save the query in a variable that can be accessed in your hits loop. Then check the query against the hit.attribute to see if it contains the query. Something like if (hit.GAIYO.includes(query)) …