Advanced Search

I'm trying to build a search code and in the meantime I just managed to do it with a search bar and a drop down options.
I have to add a checkbox option and a between option (for price) and i cant find a way to do it.
This is the code:

 

let sameWord = local.getItem(“searchWord”);

$w(“#searchBar”).value = sameWord;
$w(“#searchBar”).placeholder = sameWord;

let sameType = local.getItem(“typeV”);

$w("#typeBar").value = sameType;
$w("#typeBar").placeholder = sameType;

let sameType2 = local.getItem(“type2V”);

$w("#typeBar2").value = sameType2;
$w("#typeBar2").placeholder = sameType2;

$w(‘#apartmentId’).onReady(function () {

search();
searchF();
searchH();

$w.onReady(function () {

import wixData from ‘wix-data’;

import wixSite from ‘wix-site’;

})

});

export function searchButton_click(event) {

          search();
           searchH(); 
           searchF();  

}

export function search () {

let nDataV = wixData.query(‘apartments’);
/* let acBoxV = $w(“#acBox”).value;
let rangeStartSqm = $w(“#sqmMinBar”).value;
let rangeEndSqm = $w(“#sqmMaxBar”).value;
let sameType2 = $w(“#typeBar2”).value;

*/

    nDataV.contains('name', $w("#searchBar").value)
    .or(nDataV.contains('nighberhood', $w("#searchBar").value))
    .and(nDataV.contains('typeSOrR', $w("#typeBar2").value))
    .and(nDataV.contains('type', $w("#typeBar").value))

// .and(aDataV.ge(‘sqm’, rangeStartSqm))

// .and(boxName.contains(‘ac’, $w(“#acBox”).value))
// .and(sDataV.eq(“ac”, acBoxV))

    .find()

    .then(res => {

    $w('#repeater1').data = res.items

if (res !== null) {

        $w("#repeater1").expand();

    }
      }

    );

    }

and one other thing, the search is on the home page and it send you to a search results page.
the drop down options are on request, and if i don’t put one of the option, on the search results window, it showing “undefined”.

this is the code of the home page :

export function typeBar2_change_1(event) {

let type = $w(“#typeBar2”).value;

local.setItem("typeV", type);

}

export function typeBar_change_1(event) {

let type = $w(“#typeBar”).value;

local.setItem("typeV", type);

}

export function searchbar_change_1(event) {

let word = $w(“#searchbar”).value;

local.setItem("searchWord", word);  

}

export function searchbar_keyPress_1(event) {

if(event.key === “Enter”){

            searchbar_change_1();
            typeBar2_change_1();
            typeBar_change_1();

         wixLocation.to('/search') ;
    }

}

export function searchButton_click(event) {

         wixLocation.to('/search') ;

}

Undefined normailly means that the field that iit is looking at is empty or null, if that is going to happen all the time, then you will need to add to your code so that it does something when the field is empty.

As for code, this needs to be at the top of your page and not in the middle.

import wixData from 'wix-data';
import wixSite from 'wix-site'; // Do you really want this one? Are you actually using it in your code?

$w.onReady(function () {

See the api reference for more.
Wix Editor Elements ($w) - Velo API Reference - Wix.com

Also, are you sure you are wanting to use Wix Site?
wix-site-frontend - Velo API Reference - Wix.com

Are you sure you are not looking for Wix Storage through local, session or memory storage with the set item calls in your code?
wix-storage-frontend - Velo API Reference - Wix.com

Whilst there, have a look at the other api references too for data query and the different queries that it can run, along with on change too.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html
ValueMixin - Velo API Reference - Wix.com

Finally, there are already tutorials for creating a search on your website which you can simply open up in Wix Editor and see the elements all laid out on the page with the code all setup too.
https://www.wix.com/corvid/example/search
https://www.wix.com/corvid/tutorial/how-to-create-a-search-for-your-database - video of above.

A few pages about the dropdown lists and doing it through a dataset or manually with your own choices.
Velo Tutorial: Adding Collection Data Search Functionality | Help Center | Wix.com
Wix Support
- YouTube