# Create search function in velo with mutliple contains

**URL:** <https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975>\
**Category:** Ask the community\
**Tags:** question, code, wix\
**Created:** [November 23, 2024, 12:43pm UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975 "2024-11-23T12:43:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roberto\_Bortoli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roberto_bortoli/32/100432_2.png) [@Roberto\_Bortoli](https://forum.wixstudio.com/u/Roberto_Bortoli)\
**Post date:** [November 23, 2024, 12:43pm UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/1 "2024-11-23T12:43:34Z")

</div>

**Question:**  
I’ve created a search function in velo, so that websites-guests can seach by topic. I tried to embedd the possibility to search for more than one field, but this doesn’t work. The goal is, that in one search field, the user can search for whatever he wants. as example:

if the collection is an adress-list, I want to have the possibility, that the user can put either the name, the city, the street or the country. not depending on which of them he is putting in, the searchbar should find the appropriate entries. how to do this?

This is the current code:

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

$w('#suche').onClick((event) => {
  wixData
        .query("Verbandsmitglieder")
          .contains("title", $w("#suchfeld").value)
        .find()
        .then((results) => {
         if (results.totalCount > 0) {
         $w("#suchresultate").data = results.items;
         }
        })
        .catch((error) => {
         console.error(error);
        });  
  
  $w("#suchresultate").onItemReady(($item, itemData, index) => {
        $item("#title").text = itemData.title;
        $item("#strasse").text = itemData.strasse;
        $item("#ort").text = itemData.ort;
        $item("#webseite").link = itemData.webseite;
  });
});

```

I tried with multiple contains:

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

$w('#suche').onClick((event) => {
  wixData
        .query("Verbandsmitglieder")
          .contains("title", $w("#suchfeld").value)
          .contains("ort", $w("#suchfeld").value)
          .contains("kanton", $w("#suchfeld").value)
        .find()
        .then((results) => {
         if (results.totalCount > 0) {
         $w("#suchresultate").data = results.items;
         }
        })
        .catch((error) => {
         console.error(error);
        });  
  
  $w("#suchresultate").onItemReady(($item, itemData, index) => {
        $item("#title").text = itemData.title;
        $item("#strasse").text = itemData.strasse;
        $item("#ort").text = itemData.ort;
        $item("#webseite").link = itemData.webseite;
  });
});

```

But it doens’t work. the searchbar works only for the last contains entry.

**Product:**  
Wix Editor

**What are you trying to achieve:**  
See question

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [November 23, 2024, 5:17pm UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/3 "2024-11-23T17:17:13Z")

</div>

Hi, Roberto\_Bortoli !!

If you want to achieve what you’re aiming for, you’ll likely need to connect the queries using `.or()`. I’ll include a reference link below, so please check it out for more details. 😉

[https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/or](https://dev.wix.com/docs/velo/api-reference/wix-data/wix-data-query/or)

I think something like this might be necessary…

```javascript

let query1 = wixData.query("Verbandsmitglieder").contains("title", $w("#suchfeld").value);
let query2 =wixData.query("Verbandsmitglieder").contains("ort", $w("#suchfeld").value); 
let newQuery = query1.or(query2);

newQuery.find()
       .then((results) => {
           if (results.totalCount > 0) {
               $w("#suchresultate").data = results.items;
           }
        })
        .catch((error) => {
         console.error(error);
        });  

```

---

<div class="post-metadata">

**Author:** ![Roberto\_Bortoli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roberto_bortoli/32/100432_2.png) [@Roberto\_Bortoli](https://forum.wixstudio.com/u/Roberto_Bortoli)\
**Post date:** [November 24, 2024, 7:51am UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/4 "2024-11-24T07:51:45Z")

</div>

That’s great onemoretime. Thanks a lot for your support - it works. 🙂

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [November 24, 2024, 8:08am UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/5 "2024-11-24T08:08:25Z")

</div>

Enjoy Wix together !! 😁

P.S.

I forgot to mention earlier, but if possible, I think the `onItemReady` callback should be set up before the query. Therefore, it would be better to place it outside the `onClick` event. 🤔

---

<div class="post-metadata">

**Author:** ![Roberto\_Bortoli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roberto_bortoli/32/100432_2.png) [@Roberto\_Bortoli](https://forum.wixstudio.com/u/Roberto_Bortoli)\
**Post date:** [November 24, 2024, 8:32am UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/6 "2024-11-24T08:32:29Z")

</div>

yes, you’re right. Will change that.

I’m struggling with the property types. What is the property for the field type “Number”. Or what ist the property for the field type “Tags”?

---

<div class="post-metadata">

**Author:** ![kaylag](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kaylag/32/31519_2.png) [@kaylag](https://forum.wixstudio.com/u/kaylag)\
**Post date:** [December 18, 2025, 2:16pm UTC](https://forum.wixstudio.com/t/create-search-function-in-velo-with-mutliple-contains/64975/7 "2025-12-18T14:16:37Z")

</div>

If you’re reading this, you’re officially too observant.
