How to search multiple fields in a database?

Hi everyone,

So I’m trying to create a search engine on my website - www.thedailypush.com/skatehealth-search - I have 2 search boxes - one for “speciality” and second for “location” and I have it set up so the results appear on a different page. I want the results to be filtered so the repeater only displays results that match the search terms from both boxes. So for example if someone searches “physiotherapy” in the speciality box and “USA” in the location box it will only show results that match both search terms, or if someone searches “physiotherapy” and leaves the location box blank it will display only the results that match physiotherapy. Btw I’m a complete newbie with coding.

Thank you very much for the help!

The code I have so far on the “results” page is:

import {local} from ‘wix-storage’;
import wixData from ‘wix-data’;

$w.onReady( function () {

var sameWord = local.getItem(“searchWord”);
$w(“#iTitle”).value = sameWord;
$w(“#iTitle”).placeholder = sameWord;
var sameWord2 = local.getItem(“searchWord2”);
$w(“#iLocation”).value = sameWord2;
$w(“#iLocation”).placeholder = sameWord2;
$w(‘#itemsDataset’).onReady( function () {

    search(); 

}); 

});

export function iSearch_click() {

search(); 

}

function search() {
wixData.query(‘Items’)
.contains(“specialities”, $w(“#iTitle”).value)
.contains(“locationSearch”, $w(“#iLocation”).value)
.find()

   .then(res => { 

$w(‘#listRepeater’).data = res.items;

}); 

}

You can already do something similar, like dependant dropdowns based on previous results for example.

https://www.wix.com/corvid/example/cascading-form

https://codequeen.wixsite.com/dropdown
https://www.youtube.com/watch?v=EhXed0u6wh0

Wix Code Tutorial | How to Filter Items on Repeater Using a Dropdown and Boolean Values on Wix Code

Thanks for the reply givemeawhisky. I’m not really sure how to apply the information from these dropdown articles to what I want to do. Do you have any ideas on how I could just edit my code?

I’ve made it work! No idea how because I know nothing about code haha but it’s working, got lucky I guess. Here’s the code I used for anyone else that might have the same problem (btw this is the code on the results page. For the code for the search page, see this video: https://www.youtube.com/watch?v=ZiKcx2nlrkw ):

import {local} from ‘wix-storage’;
import wixData from ‘wix-data’;

$w.onReady( function () {

var sameWord = local.getItem(“searchWord”);
$w(“#iTitle”).value = sameWord;
$w(“#iTitle”).placeholder = sameWord;
var sameWord2 = local.getItem(“searchWord2”);
$w(“#iLocation”).value = sameWord2;
$w(“#iLocation”).placeholder = sameWord2;
$w(‘#itemsDataset’).onReady( function () {

    search(); 

}); 

});

function search() {
wixData.query(‘Items’)
.contains(“specialities”, $w(“#iTitle”).value)
.contains(“locationSearch”, $w(“#iLocation”).value)
.find()

   .then(res => { 

$w(‘#listRepeater’).data = res.items;

}); 

}