Keyword search not working

Can someone help me with the following codes? I’m trying to create a keyword search so that users can look up specific words in the Job Listing and Description pages.

import wixData from ‘wix-data’;

var lastJobType;
var lastIndustry;
var lastKeyword = ‘’;
var timer;

$w.onReady(function () {});

// Job Type Dropdown
function filterResults(jobType, industryType, keyword){

var newFilter = wixData.filter(); 

newFilter = newFilter.eq('jobType', jobType); 
newFilter = newFilter.eq('industry', industryType); 
newFilter = newFilter.contains('jobDescription', keyword) 
            .or(newFilter.contains('title', keyword)) 
            .or(newFilter.contains('location', keyword)) 
            .or(newFilter.contains('requirements', keyword)) 
            .or(newFilter.contains('aboutUs', keyword)); 

$w("#dbJob").setFilter(newFilter) 
            .then(() => { 
                resultChecker(); 
            }); 

lastJobType = jobType; 
lastIndustry = industryType; 
lastKeyword = keyword; 

}

export function iptJobType_change(event) {

var allJobType; 

if($w("#iptJobType").value !== 'All'){ 
    allJobType = $w("#iptJobType").value; 
} 

filterResults(allJobType, lastIndustry, lastKeyword); 

}

// Industry Dropdown
export function iptIndustry_change(event) {

var allIndustryType; 

if($w("#iptIndustry").value !== 'anyIndustry'){ 
    allIndustryType = $w("#iptIndustry").value; 
} 

filterResults(lastJobType, allIndustryType, lastKeyword); 

}

//Job title / Keyword search
export function iptKeyword_keyPress(event) {

if(timer){ 
    clearTimeout(timer); 
    timer = undefined; 
} 

timer = setTimeout(() => {  
    filterResults(lastJobType, lastIndustry, $w("#iptKeyword").value) 
    }, 2000); 

}

function resultChecker(){

var count = $w("#dbJob").getTotalCount(); 

if(count === 0){ 
    $w("#txtMsg").show(); 
    $w("#jobListingRep").hide(); $w("#jobListingRep").collapse(); 
    $w("#pagJob").hide(); $w("#pagJob").collapse(); 
}else{ 
    $w("#txtMsg").hide(); 
    $w("#jobListingRep").show(); $w("#jobListingRep").expand(); 
    $w("#pagJob").show(); $w("#pagJob").expand(); 
} 

}

The text colors make it hard to read.
Please change it and put it inside a code block.

I can see a lot of errors in the filters and I have to ask, did any of this code work before? Because the function that you created to filter things is most of the times being executed with undefined values.

I’ve updated the codes. Now you can read easily :slight_smile:

Hi Bruno,

Thank you so much for your time to look into the query.

for jobType and industryType filter work as intend but they keyword filter not working properly. When I’m going to search any keyword related to jobDescription, title, location, requirements, aboutUs seams it’s working as intend

You can look over the website to obtain some ideas.

Thanks!