# Search with many words in the search bar - How is it done? how to add to existing search code

**URL:** <https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [June 23, 2020, 1:25pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955 "2020-06-23T13:25:45Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [June 23, 2020, 1:25pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/1 "2020-06-23T13:25:45Z")

</div>

Hi;

I have an existing calling code that works fine. But I want to search a few words at the same time. (within the same search reference column, that is, the place to search one by one)

For example: car, blue, black, truck  
If possible; I want to add additional functions to the search bar, for example, the two options below. When the user wants to make a call, when one of the two options is ticking his box, he should be able to make multiple calls according to the condition he has marked.

- containing all
- or containing any

This is how I make a search bar. Do you have a sample code?  
The example helps me a lot since I am a novice in code.

Thank you

#search #searchbar #manywords #wordssearch #orsearch #containingall #searchdatabase #database #examplecode #code

---

<div class="post-metadata">

**Author:** ![darak](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/darak/32/21140_2.png) [@darak](https://forum.wixstudio.com/u/darak)\
**Post date:** [June 23, 2020, 2:31pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/2 "2020-06-23T14:31:07Z")

</div>

Hey!

We have a complete tutorial with two different methods of allowing users to search within a database collection.

Please read the following article for a step-by-step guide on how to set this up.

[Corvid Tutorial: Adding Collection Data Search Functionality](https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality)

You can also create a search function on your site using the wix-search API. The [wix-search API](https://www.wix.com/corvid/new-reference/wix-search#top) has functions called [hasAll()](https://www.wix.com/corvid/new-reference/wix-search/wixsearchfilterbuilder/hasall) and [hasSome()](https://www.wix.com/corvid/new-reference/wix-search/wixsearchfilterbuilder/hassome) which will allow you to set functions to a selection box so a user can search something that contains all words or some.

I am unable to see the example code where you said “this is how I make a search bar”.

If this doesn’t help please send us a link to your site and an example of your code, and we will see what we can do to help further.

Dara | Corvid Team

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [June 23, 2020, 3:04pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/3 "2020-06-23T15:04:15Z")

</div>

Hi Umut,

If you want to include ALL, use the . [**eq()**](https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#eq) , if you want to include some of, use [**.contains()**](https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#contains) , or [**hasSome()**](https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#hasSome) .

Example:

1. Must include all what you wrote EXACTLY:

```javascript
wixData.query('myCollection').eq(fieldKey, fieldValue).find();

```

1. Must contain everything you wrote

```javascript
wixData.query('myCollection').contains(fieldKey, fieldValue).find();

```

1. Matches some of what you wrote

```javascript
wixData.query('myCollection').hasSome(fieldKey, fieldValue).find();

```

Please read more about wixData API.

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [June 24, 2020, 7:42am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/4 "2020-06-24T07:42:28Z")

</div>

Hi;  
Thank you for the answers. I will try to try the methods. It can be a little difficult for me because I’m a beginner and I’m in the initial learning phase.

But I am sharing the search code I am using now. It works pretty well Just reacts fast. As soon as you start typing words for the search entry for the search, it opens, it gives early results, but it doesn’t actually search exactly. If you press enter when the word you entered to search is finished, it gives correct results. It has no end, except that it moves early.

Of course, I am researching to do better. In other words, I want to improve the existing search code in a way that users can make multiple calls about the search input.

Including the conditions I wrote above.

Finally, if you update the existing shared code to include the conditions I mentioned, it will be a very good tutorial for me, and it will create a tutorial resource for those who are looking for information on the forum.

Thank you

```javascript
import wixData from 'wix-data';

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

});

let debounceTimer;
export function searchBar_keyPress(event) {
 
    $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);
 

}

```

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [June 24, 2020, 7:43am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/5 "2020-06-24T07:43:17Z")

</div>

Hi;  
Thank you for the answers. I will try to try the methods. It can be a little difficult for me because I’m a beginner and I’m in the initial learning phase.

But I am sharing the search code I am using now. It works pretty well Just reacts fast. As soon as you start typing words for the search entry for the search, it opens, it gives early results, but it doesn’t actually search exactly. If you press enter when the word you entered to search is finished, it gives correct results. It has no end, except that it moves early.

Of course, I am researching to do better. In other words, I want to improve the existing search code in a way that users can make multiple calls about the search input.

Including the conditions I wrote above.

Finally, if you update the existing shared code to include the conditions I mentioned, it will be a very good tutorial for me, and it will create a tutorial resource for those who are looking for information on the forum.

Thank you

```javascript
import wixData from 'wix-data';

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

});

let debounceTimer;
export function searchBar_keyPress(event) {
 
    $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);
 

}

```

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [June 30, 2020, 8:44pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/6 "2020-06-30T20:44:15Z")

</div>

???  
Find it in the repeater to find out which word filtered data for searched words  
Hi; I have a search page that searches from the database.

the feature I want to add;

- show which word came from the repeater (multiple words) for the searched words

For example;  
searched words; construction and electrical works

1- construction repair repair ------ includes the word: construction  
2- construction and electricity - includes the word: - construction, electricity  
3- includes electrical works and repair ------ word: electricity, works

my current search page code (how do i add the feature i mentioned? i would be glad if you share an example about this.)

**içe** wixData **den** ‘wix-veri’ ;  
**dışa aktarma işlevi** searchButton\_onClick (event) {  
**izin** searchValue = $ (ağırlık ’ [#SearchBox](https://www.wix.com/corvid/forum/search/~num~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](https://www.wix.com/corvid/forum/search/~num~resultsTable) ’ ) .rows = res.items;  
});  
}

[#search](https://www.wix.com/corvid/forum/search/~num~search)[#filter](https://www.wix.com/corvid/forum/search/~num~filter)[#](https://www.wix.com/corvid/forum/search/~num~multiple) [multiple](https://www.wix.com/corvid/forum/search/~num~multiple) [#words](https://www.wix.com/corvid/forum/search/~num~words) [#](https://www.wix.com/corvid/forum/search/~num~searchWords) [searchWords](https://www.wix.com/corvid/forum/search/~num~searchWords) [#query](https://www.wix.com/corvid/forum/search/~num~query) [#searchValue](https://www.wix.com/corvid/forum/search/~num~searchValue)

???

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [June 30, 2020, 8:47pm UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/7 "2020-06-30T20:47:00Z")

</div>

BRIEFLY; to be told

- Searched from multiple entries with input word.
- The search was made, the results came to the repeater in the database.
- to find out which word each entry contains in a column or in a text I want to learn as a result.

I hope you give an answer in 1 year (Unfortunately the average of the forum is like this)

example

 ![](https://us1.discourse-cdn.com/wix/original/3X/8/e/8e21ab447f43594f2af1b1abfc14131bbacfe169.jpeg)

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [July 1, 2020, 6:59am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/8 "2020-07-01T06:59:48Z")

</div>

I don’t understand what you’re saying or what you’re trying to achieve.

The help in this community is offered by passionate developers, and free of charge, they put their valuable time into helping others instead of using it for their projects, so you should be thankful to them.

You can always [**submit your project**](https://www.wix.com/marketplace) to **Wix Marketplace** to hire a developer, and they’ll find the right one for, alternatively , you can [**contact me**](https://www.wix.com/corvid/profile/1fb8da05-f026-41be-9fd3-5dc2c7d2e94a/profile) for any assistance you need in your projects.

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [July 1, 2020, 7:57am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/9 "2020-07-01T07:57:06Z")

</div>

Hi;  
Yes, you are one of the rare people trying to help and I appreciate it. But as a user and I am sure there are millions of users.

- They know the wix code references page. So sharing the link to this is not a great blessing!
- the main reason why people choose a platform like wix? “They want to develop a website themselves and make it easy / don’t need anyone”
  - if you think this is wrong you can comment

- If they need to hire a developer, why would they want to deal with my crawl or other issues? There are millions of people who will make both web design and the code they want as a whole package business … Or isn’t it?

In conclusion, I want to explain and what you are stubborn in understanding  
"We are the people who want to learn and develop their own solution … Doing the work to others does not improve you! and does not move you forward! (at least for me)  
Is it a crime to strive to learn? Is it a crime to ask questions?

if so, what is the purpose of this forum? Look at the answer and conclusion analysis that has been opened with many topics. How many concluded and resolved topics are there? If wix examines this statistically, what I want to tell is more accurate.

and … thank you all

---- Also Yisrael; I think it would be better to question the criticism and the overall structure and purpose of the forum, rather than like it. Thank you for your liking though …

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [July 1, 2020, 8:28am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/10 "2020-07-01T08:28:20Z")

</div>

Hey Umut

First of all, I want you to feel welcomed in this community, it’s not a crime to learn, you can ask anything you want as long as it doesn’t go against the community guidelines.

Now regarding your points, not all members know every single piece of page in Corvid API Reference, including me, that’s why we always provide links to the relevant API.Of course the main goal for Wix is giving the opportunity to people who can’t code the ability to create a stunning website without any code knowledge, but they also have tools for hardcore developers, and everyone needs help once a while (hence you’re here), there are many cases where people needs to hire developers to add custom functionalities and features they didn’t need at the beginning or as they scale they need improvements.

There are already many articles an tutorials to help beginners start, but they need to have at least basic knowledge of coding in general and JavaScript in particular, this forum is NOT meant to change people from beginners to experts, there are many websites with JavaScript courses that help people learn.

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [July 1, 2020, 8:32am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/11 "2020-07-01T08:32:25Z")

</div>

Good answer! Ahmad  
I understand you and there are the right things when they write. I think I wrote some of my own thoughts in the foreground. That’s why I deserve you. And I saw your efforts and attention to help in many topics on the forum.

Thank you also for trying to help.

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [July 1, 2020, 8:36am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/12 "2020-07-01T08:36:02Z")

</div>

You’re welcome Umut 😊

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [July 1, 2020, 8:55am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/13 "2020-07-01T08:55:28Z")

</div>

Ahmad  
the result of the job I try to achieve;  
mark the searched word on the repeater in the results or find out which word is searched in a text box

is it possible to do this? if so is there a sample code or solution

 ![](https://us1.discourse-cdn.com/wix/original/3X/3/a/3a8767a91669aca57be60ff1a244284dfe7400c3.jpeg)

---

<div class="post-metadata">

**Author:** ![darak](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/darak/32/21140_2.png) [@darak](https://forum.wixstudio.com/u/darak)\
**Post date:** [July 1, 2020, 9:12am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/14 "2020-07-01T09:12:16Z")

</div>

Hi Umut.

Please remember all questions on this forum must be posted in English.

Thank you!

Dara | Corvid Team

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [July 1, 2020, 9:26am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/15 "2020-07-01T09:26:21Z")

</div>

It is possible, however, it requires a lot of coding skills.

---

<div class="post-metadata">

**Author:** ![umut-cankurt](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/umut-cankurt/32/20370_2.png) [@umut-cankurt](https://forum.wixstudio.com/u/umut-cankurt)\
**Post date:** [July 1, 2020, 11:12am UTC](https://forum.wixstudio.com/t/search-with-many-words-in-the-search-bar-how-is-it-done-how-to-add-to-existing-search-code/31955/16 "2020-07-01T11:12:38Z")

</div>

ok update
