Hello, I recently started adding code to my site and don’t have much experience yet. I created a searchbar for my product database so people can find what they want. The problem is, that when someone only types one of the keywords, the accessory product shows up. However, when that exact keyword is written in a sentence, no product will appear. Does anyone here have a solution for this problem please?
This is my code for this portion:
searchBar = My searchbar
dataset1 = The dataset that I use
Zoekwoorden1 = The database I use, where my keywords are stored
keywordsProbleem = The words where the products are linked with
import {local} from ‘wix-storage’ ;
import wixData from ‘wix-data’ ;
$w.onReady( function () {
var sameWord = local.getItem( “searchWord” );
$w( "#searchBar" ).value = sameWord;
$w( "#searchBar" ).placeholder = sameWord;
$w( '#dataset1' ).onReady( **function** () {
search();
});
});
export function searchButton_click() {
search();
}
function search() {
wixData.query( ‘Zoekwoorden1’ )
.contains( ‘keywordsProbleem’ , $w( “#searchBar” ).value)
.find()
.then(res => {
$w( ‘#repeater1’ ).data = res.items;
});
}