i have a search function that works properly but half of the items cant be found by it.
i checked the fields and the value from each items in the search and it’s all fine.
code :
import { local } from ‘wix-storage’;
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(‘#group25’).hide();
////////////////////p r i c e//////////////////////////////////////////////////////
let sameMinPrice = local.getItem(“minPriceV”);
$w(“#minPrice”).placeholder = sameMinPrice;
$w(“#minPrice”).value = sameMinPrice;
if ( $w(“#minPrice”).value === “”) {
$w("#minPrice").value = $w("#minPrice").options[0].value;
}
else {
$w(“#minPrice”).value = sameMinPrice;
}
let sameMaxPrice = local.getItem(“maxPriceV”);
$w(“#maxPrice”).placeholder = sameMaxPrice;
$w(“#maxPrice”).value = sameMaxPrice;
if ( $w(“#maxPrice”).value === “”) {
$w("#maxPrice").value = $w("#maxPrice").options[0].value;
}
else {
$w(“#maxPrice”).value = sameMaxPrice;
}
//////////////////////R o o m s///////////////////////////////////////////////////////////////////
let sameMinRooms = local.getItem(“minRoomsV”);
$w(“#minRooms”).placeholder = sameMinRooms;
$w(“#minRooms”).value = sameMinRooms;
if ( $w(“#minRooms”).value === “”) {
$w("#minRooms").value = $w("#minRooms").options[0].value;
}
else {
$w(“#minRooms”).value = sameMinRooms;
}
let sameMaxRooms = local.getItem(“maxRoomsV”);
$w(“#maxRooms”).placeholder = sameMaxRooms;
$w(“#maxRooms”).value = sameMaxRooms;
if ( $w(“#maxRooms”).value === “”) {
$w("#maxRooms").value = $w("#maxRooms").options[0].value;
}
else {
$w(“#maxRooms”).value = sameMaxRooms;
}
////////////////////////S Q M//////////////////////////////////////////////////
let sameMinSqm = local.getItem(“minSqmV”);
$w(“#minSqm”).placeholder = sameMinSqm;
$w(“#minSqm”).value = sameMinSqm;
if ( $w(“#minSqm”).value === “”) {
$w("#minSqm").value = $w("#minSqm").options[0].value;
}
else {
$w(“#minSqm”).value = sameMinSqm;
}
let sameMaxSqm = local.getItem(“maxSqmV”);
$w(“#maxSqm”).placeholder = sameMaxSqm;
$w(“#maxSqm”).value = sameMaxSqm;
if ( $w(“#maxSqm”).value === “”) {
$w("#maxSqm").value = $w("#maxSqm").options[0].value;
}
else {
$w(“#maxSqm”).value = sameMaxSqm;
}
//////////////////////W o r d/////////////////////////////////////////////
let sameWord = local.getItem(“searchWord”);
$w(“#searchBar”).value = sameWord;
$w(“#searchBar”).placeholder = sameWord;
//////////////////////P R O P E R T Y - T Y P E//////////////////////////////////////////////////////
let sameType = local.getItem(“typeV”);
$w(“#typeBar”).value = sameType;
$w(“#typeBar”).placeholder = sameType;
//////////////////////T r a n s a c t i o n - T Y P E//////////////////////////////////////////////////////
let sameType2 = local.getItem(“type2V”);
$w("#typeBar2").value = sameType2;
$w("#typeBar2").placeholder = sameType2;
$w(‘#apartmentId’).onReady( function () {
search();
searchF();
searchH();
})
});
export function advanceSearch_click_1(event) {
if ($w(‘#group25’).hidden) {
$w('#group25').show("fade");
}
else {
$w(‘#group25’).hide();
}
}
export function searchButton_click(event) {
search();
searchH();
searchF();
console.log($w("#minSqm"));
console.log($w("#maxSqm"));
console.log($w("#minRooms"));
console.log($w(“#maxRooms”));
console.log($w(“#minPrice”));
console.log($w(“#maxPrice”));
console.log($w(“#searchBar”));
console.log($w(“#typeBar”));
console.log($w(“#typeBar2”));
}
export function search () {
let nDataV = wixData.query(‘apartments’);
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(nDataV.ge('price1', $w("#minPrice").value))
.and(nDataV.le('price1', $w("#maxPrice").value))
.and(nDataV.ge('rooms1', $w("#minRooms").value))
.and(nDataV.le('rooms1', $w("#maxRooms").value))
.and(nDataV.ge('sqm1', $w("#minSqm").value))
.and(nDataV.le('sqm1', $w("#maxSqm").value))
.find()
.then(res => {
$w('#repeater1').data = res.items
if (res !== null ) {
$w("#repeater1").expand();
}});
}
//apartmentHeb
export function searchH () {
let nDataV = wixData.query(‘apartments’);
nDataV.contains('nameH', $w("#searchBar").value)
.or(nDataV.contains('neigborhood', $w("#searchBar").value))
.and(nDataV.contains('typeSOrR', $w("#typeBar2").value))
.and(nDataV.contains('type', $w("#typeBar").value))
.and(nDataV.ge('price1', $w("#minPrice").value))
.and(nDataV.le('price1', $w("#maxPrice").value))
.and(nDataV.ge('rooms1', $w("#minRooms").value))
.and(nDataV.le('rooms1', $w("#maxRooms").value))
.and(nDataV.ge('sqm1', $w("#minSqm").value))
.and(nDataV.le('sqm1', $w("#maxSqm").value))
.find()
.then(res => {
$w('#repeater2').data = res.items
if (res !== null ) {
$w("#repeater2").expand()
}
}
);
}
//apartmentHeb
function searchF () {
let nDataV = wixData.query(‘apartments’);
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(nDataV.ge('price1', $w("#minPrice").value))
.and(nDataV.le('price1', $w("#maxPrice").value))
.and(nDataV.ge('rooms1', $w("#minRooms").value))
.and(nDataV.le('rooms1', $w("#maxRooms").value))
.and(nDataV.ge('sqm1', $w("#minSqm").value))
.and(nDataV.le('sqm1', $w("#maxSqm").value))
.find()
.then(res => {
$w('#repeater3').data = res.items
if (res !== null ) {
$w("#repeater3").expand();
}
}
);
}
export function repeater3_itemRemoved(itemData) {
$w(“#repeater3”).collapse();
}
export function repeater1_itemRemoved(itemData) {
$w(“#repeater1”).collapse();
}
export function repeater2_itemRemoved(itemData) {
$w(“#repeater2”).collapse();
}