# Filter database by location

**URL:** <https://forum.wixstudio.com/t/filter-database-by-location/39882>\
**Category:** Ask the community\
**Tags:** question, code, wix-stores\
**Created:** [June 1, 2018, 10:36pm UTC](https://forum.wixstudio.com/t/filter-database-by-location/39882 "2018-06-01T22:36:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smihtp004](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@smihtp004](https://forum.wixstudio.com/u/smihtp004)\
**Post date:** [June 1, 2018, 10:36pm UTC](https://forum.wixstudio.com/t/filter-database-by-location/39882/1 "2018-06-01T22:36:25Z")

</div>

Hi there. Is there a way to create a database as shown on website. But have people search for certain parts of data based on location… For example putting in your postcode only shows the stores nearby which have been inputted on the database?

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 3, 2018, 7:50am UTC](https://forum.wixstudio.com/t/filter-database-by-location/39882/2 "2018-06-03T07:50:53Z")

</div>

Hey Paul,

Welcome to the Wix Code forum.

Yes, you could [search the database](https://support.wix.com/en/article/how-to-add-a-search-of-your-data-collection-to-a-page) but you will need to be able to deal with the postcodes. You can learn how to use [Google Maps services](https://www.wix.com/code/home/forum/advanced-tips-tricks/how-to-use-google-maps-services-in-wix-code) which can assist in the handling of the postcodes.

A gentle warning: The system you are describing is quite complex and will be a challenge for beginner coders. You might want to consider checking out the [WixArena](https://www.wix.com/arena/web-designers/1) - it’s a hub where you can look for Wix Code (and other) experts for hire.

Feel free to post any questions here.

Have fun and good luck,

Yisrael

---

<div class="post-metadata">

**Author:** ![dippachernico](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dippachernico/32/27495_2.png) [@dippachernico](https://forum.wixstudio.com/u/dippachernico)\
**Post date:** [March 28, 2021, 10:20am UTC](https://forum.wixstudio.com/t/filter-database-by-location/39882/3 "2021-03-28T10:20:26Z")

</div>

Hello everybody.I have a similar problem or question. I tried to use a filter function to filter the database for address data. The problem with this is that it only works for one place. As soon as you enter other places or postcodes in the search bar, no result comes out. Do you have any idea why that is? I haven’t been at Wix too long, so my assembled code might seem a bit weird.  
I use the address app from Wix. Everything is connected to the Maps API.

```javascript
export function searchBar_keyPress(event) {
    $w.onReady(function () {
    $w("#loadingGif").show();
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
           $w("#dataset11").setFilter(wixData.filter().contains("title", $w('#searchBar').value)
                .or(wixData.filter().contains("Address", //<------ $w('#searchBar').value) //<---------This point doesnt work
        ))
            .then(() => {
                count();
            })
         }, 300);

```

If someone could help me, I would be very grateful.I’ve been trying to solve this problem for weeks.

Thank you in advance  
best regards  
Phoenix of Music

---

<div class="post-metadata">

**Author:** ![webbcraft](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/webbcraft/32/12114_2.png) [@webbcraft](https://forum.wixstudio.com/u/webbcraft)\
**Post date:** [March 28, 2021, 11:15am UTC](https://forum.wixstudio.com/t/filter-database-by-location/39882/4 "2021-03-28T11:15:52Z")

</div>

.contains(value) checks the database for what information you pass to it.

e.g. “Location1, Location2” will only return data which contains the text “Location1, Location2”, not “Location1”, “Location2”. as it is can only search for the string given.

Instead try splitting the search up using something like .split(“,”);  
and use multiple .contains for each value you want to be included:
