Are there any filter options limit?

Hey all,

I have a collection that I am filtering.
There are 58 options that can be used to filter the collection.
Obviously no one will use all 58 options (-;

The filter is working great in most cases but in some cases when it used for more than about 5 variants or in certain combinations it brings back results which some of them are not relevant to the options selected.

I am using “.contains” for the filter.

So, the question is:
does the filter function has a limit of options?
or this is a bug?
or any other idea?

Thanks in advance,

#filter #limit

Hello Benny

Contains() refines a filter to match the items that contain the string value you specified (for example if you set a filter for the string “san”, san diego, san francisco … , will be returned).

However, you can use hasAll() if you have multiple values for each property, or you can use eq() is you have single value for each property. This way exact matches will be returned.

Check this documentation out to know more about filters. and for further help please provide you editor’s link :slight_smile:

Best
Massa

Hey @massasalah18
Thanks for your input.

The idea of the filter is to check and see if column in the collection has the string in it.

This is a link to the editor: https://editor.wix.com/html/editor/web/renderer/edit/e09cdd65-a3a9-4c1d-a5f5-98bef8ef1d86?metaSiteId=37761560-61b3-4b30-b0a1-c1e7df861f36&editorSessionId=ae341137-e4c5-4c98-bfd6-f9dd1acac6c1&referralInfo=my-account

Here is a glimpse of the code (try not to look directly at it as it might burn your eyes)

$w(‘#ResearchData’).setFilter(wixData.filter()
.contains(‘researchTitle’, $w(‘#namesearchInput’).value)
.contains(‘researchBody’, $w(‘#BodySearchInput’).value)
//Age קבוצת גיל
.contains(‘ageGroupAll’, $w(‘#Age1’).value)
.contains(‘ageGroupAll’, $w(‘#Age2’).value)
.contains(‘ageGroupAll’, $w(‘#Age3’).value)
.contains(‘ageGroupAll’, $w(‘#Age4’).value)
.contains(‘ageGroupAll’, $w(‘#Age5’).value)
.contains(‘ageGroupAll’, $w(‘#Age6’).value)
.contains(‘ageGroupAll’, $w(‘#Age7’).value)
.contains(‘ageGroupAll’, $w(‘#Age8’).value)

//Population מאפיין אוכלוסייה
.contains(‘populationAll’, $w(‘#P1’).value)
.contains(‘populationAll’, $w(‘#P2’).value)
.contains(‘populationAll’, $w(‘#P3’).value)
.contains(‘populationAll’, $w(‘#P4’).value)
.contains(‘populationAll’, $w(‘#P5’).value)
.contains(‘populationAll’, $w(‘#P6’).value)
.contains(‘populationAll’, $w(‘#P7’).value)
.contains(‘populationAll’, $w(‘#P8’).value)
.contains(‘populationAll’, $w(‘#P9’).value)
//Plan Field (PF) תחום התוכנית
.contains(‘fieldAll’, $w(‘#PF1’).value)
.contains(‘fieldAll’, $w(‘#PF2’).value)
.contains(‘fieldAll’, $w(‘#PF3’).value)
.contains(‘fieldAll’, $w(‘#PF4’).value)
.contains(‘fieldAll’, $w(‘#PF5’).value)
.contains(‘fieldAll’, $w(‘#PF6’).value)
.contains(‘fieldAll’, $w(‘#PF7’).value)
.contains(‘fieldAll’, $w(‘#PF8’).value)
.contains(‘fieldAll’, $w(‘#PF9’).value)
.contains(‘fieldAll’, $w(‘#PF10’).value)
.contains(‘fieldAll’, $w(‘#PF11’).value)
.contains(‘fieldAll’, $w(‘#PF12’).value)
.contains(‘fieldAll’, $w(‘#PF13’).value)
.contains(‘fieldAll’, $w(‘#PF14’).value)
.contains(‘fieldAll’, $w(‘#PF15’).value)
.contains(‘fieldAll’, $w(‘#PF16’).value)
.contains(‘fieldAll’, $w(‘#PF17’).value)
.contains(‘fieldAll’, $w(‘#PF18’).value)
.contains(‘fieldAll’, $w(‘#PF19’).value)
.contains(‘fieldAll’, $w(‘#PF20’).value)
.contains(‘fieldAll’, $w(‘#PF21’).value)
.contains(‘fieldAll’, $w(‘#PF22’).value)
.contains(‘fieldAll’, $w(‘#PF23’).value)
.contains(‘fieldAll’, $w(‘#PF24’).value)
.contains(‘fieldAll’, $w(‘#PF25’).value)
.contains(‘fieldAll’, $w(‘#PF26’).value)
.contains(‘fieldAll’, $w(‘#PF27’).value)
.contains(‘fieldAll’, $w(‘#PF28’).value)
.contains(‘fieldAll’, $w(‘#PF29’).value)
.contains(‘fieldAll’, $w(‘#PF30’).value)
.contains(‘fieldAll’, $w(‘#PF31’).value)
.contains(‘fieldAll’, $w(‘#PF32’).value)
.contains(‘fieldAll’, $w(‘#PF33’).value)
//Rסוג מערך מחקר Research Type
.contains(‘researchTypeCategory’, $w(‘#RT1’).value)
.contains(‘researchTypeCategory’, $w(‘#RT2’).value)
.contains(‘researchTypeCategory’, $w(‘#RT3’).value)
//Research Focus (FG) מוקד המחקר
.contains(‘researchFocus’, $w(‘#FG1’).value)
.contains(‘researchFocus’, $w(‘#FG2’).value)
.contains(‘researchFocus’, $w(‘#FG3’).value)
.contains(‘researchFocus’, $w(‘#FG4’).value)
.contains(‘researchFocus’, $w(‘#FG5’).value)
.contains(‘researchFocus’, $w(‘#FG6’).value)
//Population עיתוי מדידה אחרון
.contains(‘LastMesurmentCategory’, $w(‘#LM1’).value)
.contains(‘LastMesurmentCategory’, $w(‘#LM2’).value)
.contains(‘LastMesurmentCategory’, $w(‘#LM3’).value)
.contains(‘LastMesurmentCategory’, $w(‘#LM4’).value)
.contains(‘LastMesurmentCategory’, $w(‘#LM5’).value)
.contains(‘LastMesurmentCategory’, $w(‘#LM6’).value)
//שנה
.contains(‘yearCategory’, $w(‘#radioButtonsYear’).value)
)
console.log(‘filter Done’)

@Massa salah
Hey,

Any update on this issue?
Thanks,
Benny

@benny-glaser

so to make sure I understand what you want here, When a check box is checked u want to add a filter of its value to the data set?
Why are adding all those filter values and what is the exact purpose of it ?

@massasalah18
the purpose it to create filtered results for the data based on the different choices of check box’s selected.

For example:
Population has 9 options in the collection.
Some items have more then one options (this is why I use the ‘contains’)
/Population
.contains(‘populationAll’, $w(’ #P1 ‘).value) .contains(‘populationAll’, $w(’ #P2 ‘).value) .contains(‘populationAll’, $w(’ #P3 ‘).value) .contains(‘populationAll’, $w(’ #P4 ‘).value) .contains(‘populationAll’, $w(’ #P5 ‘).value) .contains(‘populationAll’, $w(’ #P6 ‘).value) .contains(‘populationAll’, $w(’ #P7 ‘).value) .contains(‘populationAll’, $w(’ #P8 ‘).value) .contains(‘populationAll’, $w(’ #P9 ').value)

The idea is that the user can create a filler based on many selections and get back ONLY the result that HAS ALL the option chosen.

As I wrote before it works just great when running the filter based on 3-4 options but on more complex cases it gets irrelevant results.

I hope this is clear.

@benny-glaser then a good approach is to set the filter after the value is checked .

Example scenario:
user opens the page checks P3 and P2, then clicks a button called ‘show result’, what happens next is that inside the on click function you get the boxes checked and add a filter on the data set that has all those values.

Scenario code example:

export function showResultBtn_click(event) {

 //array to store values of checked check boxses
 let filtringArray=[];

 //for loop to see whick check box is checked
 for (var i = 1; i < 10; i++) {
 
    if($w('#P'+ i).checked){
            //this point will be accessed only when i = 2 & i =3
            filtringArray.push($w('#P'+ i).value)
        }
    }
 
    $w('#dataset').setFilter(wixData.filter().hasSome('populationAll', filtringArray));
}

Using this code you get the items from the data set that has any of the checked boxes values. this way you can organize your code and set the filter on each database the same way.
if you want it to oly return items with all the values use .hasAll instead of .hasSome
note that you only need one button click event, you can add all other filters inside that function.

Best
Massa