Search results only display a single product collection rather than 'all products'

I have recently built a basic custom search page on my dev website (https://francisdavidjones.wixsite.com/mysite-1/search) to allow users to search for products.

I currently have two types of product, one being full-priced (in a collection called ‘non-member’) and a cloned version which is discounted for subscribers (in a collection called ‘BSM’).

I need to know if there is a way to remove all the subscriber products (BSM) from the results, so that only ‘non-member’ products appear, rather than pulling through all products.

import wixData from 'wix-data';

$w.onReady(function () {
 // Write your JavaScript here

 // To select an element by ID use: $w("#elementID")

 // Click "Preview" to run your code
});

export function dataset2_ready() {
     $w("#repeater1").onItemReady( ($item, itemData, index) => {
        $item("#price").text = itemData.price + ' ' + itemData.currency;
    });
}

let lastFilterName;
let lastFilterPrice;
let debounceTimer;

function filter(name) {
 if (lastFilterName !== name) {
 let newFilter = wixData.filter();
 if(name)
        newFilter = newFilter.contains('name', name);
        $w("#dataset2").setFilter(newFilter);
        lastFilterName = name;
    }
}

export function searchBar_keyPress(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w("#searchBar").value, lastFilterPrice);
    }, 100);
}

Put a filter for the collection like this

$w("#dataset2").setFilter(newFilter.and(newFilter.eq("collectionField", "COLLECTION_ID")));

Hey Shan, thanks for your reply. I think I used your tutorial video as a starting point (I recognise the name Dude Lemon), so thank you! I have tried to add this as a filter, but I am a noob (first time using Corvid) and I’m still stuck. I have added the code where I thought it should be and changed the collectionField and COLLECTION_ID but it’s not working. Please can you point me in the right direction?

import wixData from 'wix-data';

$w.onReady(function () {
 // Write your JavaScript here

 // To select an element by ID use: $w("#elementID")

 // Click "Preview" to run your code
});

export function dataset2_ready() {
     $w("#repeater1").onItemReady( ($item, itemData, index) => {
        $item("#price").text = itemData.price + ' ' + itemData.currency;
    });
}


let lastFilterName;
let lastFilterPrice;
let debounceTimer;

function filter(name) {
 if (lastFilterName !== name) {
 let newFilter = wixData.filter();
 if(name)
        newFilter = newFilter.contains('name', name);
        $w("#dataset2").setFilter(newFilter);
        lastFilterName = name;
      
$w("#dataset2").setFilter(newFilter.and(newFilter.eq("collections", "#Non-member")));
    }
}


export function searchBar_keyPress(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w("#searchBar").value, lastFilterPrice);
    }, 100);
}

@oscar The code I wrote should work on a normal database field (text, numerical, etc) but I think the ‘collections’ field is a reference/multi-reference field so you might have to use .hasSome

$w("#dataset2").setFilter(newFilter.and(newFilter.hasSome("collections", "COLLECTION_ID")));

Note that you need to get the exact collection id from the collections database

@shantanukumar847 it worked! A sincere thank you.