Code for a Site Search to query the Title Field of all datasets

So, I’ve watched lots of videos and read multiple articles, and I pieced together something that searches my database using a keyword, but not displaying as I want. I decided to make things as easy as possible, at least for now, and put all of my graphics into one database.

The code I have for my search and results page has a search bar, and it works as it should. The results are shown in a repeater. However, the code I found and used is connected to the dataset, so it shows all of the graphics in my collection prior to a search and then renders the specific search results. I don’t want to see all of the graphics. I want a blank page with a search bar to start with. I tried inserting a collapse code, but that works only after a search doesn’t render any results. I know this issue is because the code is connected to the dataset, but when I replace that with the name of my collection, it doesn’t work. Is there a way to make this code search the collection? Thank you for your time!

devin

import wixData from ‘wix-data’;

let debounceTimer;

$w(“#searchInput”).onKeyPress( (event) => {
if(event.key === “Enter”){

$w(“#clearbutton”).show();

$w(“#searchInput”).value;

if (debounceTimer) {
    clearTimeout(debounceTimer);
    debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
    filter($w("#searchInput").value); //ID of input form
}, 200);

}

let searchWord;

function filter(search) {
if (searchWord !== search) {
$w(“#dataset1”).setFilter(wixData.filter().contains(‘title’, search)); // ID of the dataset
searchWord = search;
}

}

$w(“#repeater1”).onItemReady(($item, itemData, index) => {
$item(“#text1”).text = itemData.title;
$item(“#mainImage”).src = itemData.mainImage;
$item(“#mainImage”).link = itemData[‘link-all-graphics-1-title’];

                if (itemData.title=== "N" ){
                    $w('#repeater1').collapse()
                }

}
,
)
})
$w.onReady(() => {

$w('#clearbutton').onClick(() => {

    $w("#searchInput").value = undefined
    $w("#dataset1").setFilter(wixData.filter())

    $w("#clearbutton").hide();

})

})