Duplicated Filter Results: Preview vs Live Site Results

Hello Forum,

I have an odd thing happening when I filter entries of a database. I have written a filter that incorporates dropdown menus and a text box. The results of the filter are then displayed in a repeater. In preview mode everything works as expected, but the filtered results in live mode are showing multiple times in my repeater.

My Website: https://www.socialdesigndirectory.com

In the developer’s preview mode, the filter works as expected. In the case that a single entry matches the search criterion, a single search result appears in the repeater as seen below. For example, by searching for the city “Abuja” from the dropdown menu, the only matching entry in my database is displayed once. This looks great, and is what I want.


However, in live mode, when I search “Abuja,” this single entry in the database is displayed multiple times, as shown below.

I have check multiple times in my database and there are no repeats, and the current database is synced to the live site. This also happens for other search results, where, for some reason, the displayed results are repeated generally 3 times. In a few cases, the single database result (such as a search for “Aukland” in the city dropdown menu) duplicates the result 2 times in the filtered repeater results.

Has anyone experienced this before? Any thoughts on how to solve this duplication issue in the live site?

I have also included the code for the filter below. It’s a bit long, but is essentially the same thing for multiple dropdown menus. Set indefinite variables, make menu onChange event to activate filter, and the filter for all of the menu options:

// ---------------------------------------
// Filtering Search Results
// ---------------------------------------

// Set some indefined variables that will hold the company and region search ()
let lastFilterConame;
let lastFilterRegion;
let lastFilterCountry;
let lastFilterCity;
let lastFilterState;
let lastFilterOrgType;
let lastFilterDevFocus;

let debounceTimer;
export function itbConame_keyPress_1(event, $w) {
    console.log('itbConame_keypress Activated')
 if(debounceTimer){
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w('#itbConame').value, lastFilterCountry, lastFilterCity, lastFilterState, lastFilterOrgType, lastFilterDevFocus, lastFilterRegion);
    },200);
}

export function iddRegion_change(event) {
    console.log('iddRegion change before filter')
    filter(lastFilterConame, lastFilterCountry, lastFilterCity, lastFilterState, lastFilterOrgType, lastFilterDevFocus, $w('#iddRegion').value);
    console.log($w('#iddRegion').value)
}

export function iddCountry_change_1(event) {
    console.log('iddCountry change before filter')
    filter(lastFilterConame, $w('#iddCountry').value, lastFilterCity, lastFilterState, lastFilterOrgType, lastFilterDevFocus, lastFilterRegion);
    console.log('iddCountry change activated After Filter')
}

export function iddCity_change_1(event) {
    console.log('iddCity change before filter')
    filter(lastFilterConame, lastFilterCountry, $w('#iddCity').value, lastFilterState, lastFilterOrgType, lastFilterDevFocus, lastFilterRegion);
}

export function iddState_change(event) {
    console.log('iddState change before filter')
    filter(lastFilterConame, lastFilterCountry, lastFilterCity, $w('#iddState').value, lastFilterOrgType, lastFilterDevFocus, lastFilterRegion);
}

export function iddOrgType_change(event) {
    console.log('iddOrgType change before filter')
    filter(lastFilterConame, lastFilterCountry, lastFilterCity, lastFilterState, $w('#iddOrgType').value, lastFilterDevFocus, lastFilterRegion);
}

export function iddDevFocus_change(event) {
    console.log('iddDevFocus change before filter')
    filter(lastFilterConame, lastFilterCountry, lastFilterCity, lastFilterState, lastFilterOrgType, $w('#iddDevFocus').value, lastFilterRegion);
}

function filter(Coname, countrydd, citydd, usstatedd, orgtypedd, devfocusdd, regiondd){
 if (lastFilterConame !== Coname || lastFilterCountry !== countrydd || lastFilterCity !== citydd || lastFilterState !== usstatedd || lastFilterOrgType !== orgtypedd || lastFilterDevFocus !== devfocusdd || lastFilterRegion !== regiondd){
 let newFilter = wixData.filter();
        console.log('filter activated')
 if (Coname)
            newFilter = newFilter.contains('organizationName', Coname);
            console.log('Coname Filtering')
 if (regiondd)
            console.log('region selected in filter')
 if (regiondd === 'Africa') {
                console.log('Africa Engaged')
                newFilter = newFilter.eq('africa', 1);
            }
 if (regiondd === 'Asia-Pacific') {
                newFilter = newFilter.eq('asiaAus', 1);
                console.log('Asia Engaged')
            }
 if (regiondd === 'Europe') {
                newFilter = newFilter.eq('eur', 1);
                console.log('Europe Engaged')
            }
 if (regiondd === 'Latin America') {
                newFilter = newFilter.eq('latAm', 1);
                console.log('LatAm Engaged')
            }
 if (regiondd === 'Middle East') {
                newFilter = newFilter.eq('midEast', 1);
                console.log('MidEast Engaged')
            }
 if (regiondd === 'North America') {
                newFilter = newFilter.eq('nAmerica', 1);
                console.log('NorthAmerica Engaged')
            }
 if (countrydd)
            newFilter = newFilter.eq('country', countrydd);
            console.log('countrydd Filtering')
 if (citydd)
            newFilter = newFilter.eq('city', citydd);
            console.log('citydd Filtering')
 if (usstatedd)
            newFilter = newFilter.eq('state', usstatedd);
            console.log('statedd Filtering')
 if (orgtypedd)
            newFilter = newFilter.eq('sector', orgtypedd);
            console.log('orgtypedd Filtering')
 if (devfocusdd)
            newFilter = newFilter.eq('developmentFocus', devfocusdd);
            console.log('devfocusdd Filtering')

        $w('#dataset1').setFilter(newFilter);
        lastFilterConame   = Coname;
        lastFilterCountry  = countrydd;
        lastFilterCity     = citydd;
        lastFilterState    = usstatedd;
        lastFilterOrgType  = orgtypedd;
        lastFilterDevFocus = devfocusdd;
        lastFilterRegion   = regiondd;
    }
}

I finally figured it out. This was not an issue with the filter, but discovering that “syncing sandbox to live” does not overwrite all live database results. It only updates those particular entries that are in the sandbox at that time. From the content manager sandbox view, I switched to the “live” database values and found repeated values from previous edits that were synced to live. I cleared those values and synced again, and the repeated results are no longer an issue on the live site.