show the results in a repeater if it contains multiple words individually but or any of the words with a single search entry - editing exist

Hi;

to the current search code below;

  • I want to search for each word written in the database separately. For example: paris eat cake
  • search (food and cake paris) should list the results even in the case of words.
  • I want to list all the results if one or more of them are in the text.

My current code is below. Can you send it back by adding the search feature I mentioned.
Note: I tried it in many different ways, but it didn’t. I would be glad if you could edit it for me as an example of the current code.

import wixData from 'wix-data';

$w.onReady(function () {
 //TODO: write your page related code here...

});

let debounceTimer;
export function searchBar_keyPress(event) {
 let str = 'searchBar';
 let words = str.split(" ");
    console.log('searchBar');

 const filterValue = ("words").value
 const byOverview = wixData.filter().contains("overview", filterValue)
    $w("#germany").setFilter(byOverview)
 
    $w("#loadingGif").show();
 

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

    debounceTimer = setTimeout(() => {
        $w("#germany").setFilter(wixData.filter().contains("overview", $w('#searchBar').value)
                .or(wixData.filter().contains("projectTitleDescription", $w('#searchBar').value)
 
                    .or(wixData.filter().eq("country", $w('#searchBar').value))))
            .then(() => {
 
                count();
            })
    }, 50);
 

}

#searchbar #filter #wixdata #eq #or #split #multiple #multiplewords #words #searchdata #search #addcode

Hi;

The second code I share provides the feature I am looking for. But how can I combine different words with code 1 in the previous post to include the words in the search. Could you please help me. I want to integrate the code in 2 shares into the code I shared first.

  1. Code + 2. Code= ?

  2. code

import wixData from 'wix-data';

$w.onReady(function () {
 //TODO: write your page related code here...

});



let debounceTimer;
export function searchBar_keyPress(event) {
 let str = 'searchBar';
 let words = str.split(" ");
    console.log('searchBar');

 const filterValue = ("words").value
 const byOverview = wixData.filter().contains("overview", filterValue)
    $w("#germany").setFilter(byOverview)
 
    $w("#loadingGif").show();
 

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

    debounceTimer = setTimeout(() => {
        $w("#germany").setFilter(wixData.filter().contains("overview", $w('#searchBar').value)
                .or(wixData.filter().contains("projectTitleDescription", $w('#searchBar').value)
 
                    .or(wixData.filter().eq("country", $w('#searchBar').value))))
            .then(() => {
 
                count();
            })
    }, 50);
 

}
  1. Code
import wixData from 'wix-data'; 
export function searchButton_onClick(event) {   
  let searchValue = $w('#searchButton').value;
  let searchWords = searchValue.split(' ');
  let query = wixData.query('my-collection')  
    .contains('physicalIssue', searchWords[0]);
    
  for (let i=1; i < searchWords.length; i++) {
    query = query.or(wixData.query('my-collection')
      .contains('physicalIssue', searchWords[i]));
  }  
      
  query.find() 
    .then(res => {  
      $w('#resultsTable').rows = res.items; 
    });
}

Can someone please help with this? I want to use a single combination of two codes.

After you split the words in the search input text, you will have an array of words in the variable words . You can then use the .hasSome() function for your query to return a search where the value of the specified property equals any of the specified values.

Hi; Yisrael
I tried to add to the existing code hasSome () but I couldn’t. The 2nd code I sent because I am a beginner does exactly what I want. But I want to add the same function to the existing code.

Or, if possible, could you send it by adding hasSome () to the code I added. I would have learned thanks to you

Note: I am satisfied with the operation of the code but I cannot search a few words independently. I’d better add the feature I’m talking about

import wixData from 'wix-data';

$w.onReady(function () {
 //TODO: write your page related code here...

});


let debounceTimer;
export function searchBar_keyPress(event) {
 let str = 'searchBar';
 let words = str.split(" ");
    console.log('searchBar');

 const filterValue = ("words").value
 const byOverview = wixData.filter().contains("overview", filterValue)
    $w("#germany").setFilter(byOverview)
 
    $w("#loadingGif").show();
 

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

    debounceTimer = setTimeout(() => {
        $w("#germany").setFilter(wixData.filter().contains("overview", $w('#searchBar').value)
                .or(wixData.filter().contains("projectTitleDescription", $w('#searchBar').value)
                .or(wixData.filter().hasSome("overview", $w('#searchBar').value)
 
                .or(wixData.filter().eq("country", $w('#searchBar').value)))))
            .then(() => {
 
                count();
            })
    }, 50);
 

}

.hasSome()
How do I add the code I shared above? Someone who is knowledgeable about the subject can make the necessary addition and share it as an example.

Aranan kelimeler için filtrelenmiş verilerin hangi kelimeyle filtrelendiğini bulmak için tekrarlayıcıda bulmak

Selam; Veritabanından arama yapan bir arama sayfam var.

eklemek istediğim özellik;

  • aranan kelimeler için tekrarlayıcıdan (birden fazla kelime) hangi kelimenin geldiğini göstermek

Örneğin;
aranan kelimeler; inşaat ve elektrik işleri

1- inşaat onarım onarım ------ kelimesini içerir: inşaat
2- inşaat ve elektrik ------ kelimesini içerir: inşaat, elektrik
3- elektrik işleri ve onarım ------ kelimesini içerir: elektrik, çalışır

mevcut arama sayfası kodum (Bahsettiğim özelliği nasıl eklerim? Bu konuda bir örnek paylaşırsanız memnun olurum.)

içe wixData den ‘wix-veri’ ;
dışa aktarma işlevi searchButton_onClick (event) {
izin searchValue = $ (ağırlık ’ #SearchBox ’ ) .value;
izin searchwords = searchValue.split ( ’ );
let query = wixData.query ( ‘SouthAfrica’ )
.contains ( ‘genel bakış’ , searchWords [ 0 ]);

for ( let i = 1 ; i <searchWords.length; i ++) {
query = query.or (wixData.query ( ‘SouthAfrica’ )
.contains ( ‘genel bakış’ , searchWords [i]));
}

query.find ()
. sonra (res => {
$ w ( ’ #resultsTable ’ ) .rows = res.items;
});
}

#search #filter # multiple #words # searchWords #query #searchValue

???