Hello all. My apologies if this particular search function has been addressed, but I was not able to find it. I was able to successfully search the “name” and “bio” fields, but when I changed it to search the “address” field, the search no longer functions. I need to be able to search by ZIP code. I tried adding a number field and just entering the ZIP, but that didn’t function either.
Please help! Thanks in advance.
Here’s my site: puspinsmedia com / search (I cannot post the link)
Here’s my code:
import wixData from ‘wix-data’ ;
let debounceTimer;
export function search_keyPress(event, $w) { //enable onKeypress for input form if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( “#search” ).value); //ID of input form
}, 200 );
}
let lastFilterSearch;
function filter(search) { if (lastFilterSearch !== search) {
$w( “#dataset1” ).setFilter(wixData.filter().contains( ‘address’ , search)); // ID of the dataset
lastFilterSearch = search;
}
1 - Number (could’t pull results)
2 - Text (wouldn’t let me enter in numbers only)
3 - Address - (Which is my preference for the field type and couldn’t pull results)
@jonatandor35 what can I use? For a workaround, I added another text field and entered in the zip codes with a hashtag in front (#92113 for example). Without entering in the hashtag with the zip code, the search functions as I wish. Although I feel there should be code that allows to search the address field. Obviously coding is not my thing.
@robert not sure what you meant when you wrote about the hashtag (it looks like you wrote it quickly skipped a few words. But I can guess. Anyway no need to add a hashtag there).
You’re right that we should be able to search inside an object, and maybe we can but I don’t how,
Of course you can retrieve all the items and search in the address object using JavaScript, but it less efficient if you have a lot of records.