Filter an array of values against an attribute

Hi all, bit of an awkward one here…

Is it possible to query an array of values against an attribute with a custom MenuSelect?

The background
I have a series of locations, each location has various ‘high season’ months added to it. Alongside that I have some other data like clothing and weather conditions. The clothing and weather conditions (wind strength) relate to specific months. So in January a location could have a clothing value of shorts and a wind strength of 6. There’s only ever one clothing and weather value for each month.

Currently I have the data setup as objects (see below) and I’ve got select menus on the front end to filter it. I currently have it working so you have to select a month before you can choose your clothing type. The month value is then taken and added to the clothing query so I can search for january.shorts in the clothing object . When you select a different month the clothing section is reset and the process repeats. This works great, apart from…

  • I need to implement a multi-select menu for months, which would mean I’d need to query an array of values against clothing
  • I need to query clothing as a standalone filter (without a month selected)

Ideally when I select one of the defined items of clothing I’d like to build an array that combines each selected month with the chosen clothing type, something like… [january.shorts, april.shorts] then run that against the clothing attribute.

To further complicate things on the front end the Clothing filter is a hard coded select list (shorts, trousers, shirt etc).

I’m happy to re-work the data structure to something that’ll help solve this. As it stands, no matter what I think of, I always come back to the same issue… querying an array of data against an attribute.

To solve selecting some clothing without a month I’ve thought about reconfiguring the clothing object to an array (see possible clothing array below). That way if the value i’m querying doesn’t have a month it’ll still return for say trousers.

Any help on this is hugely appreciated.


---- Existing data structure ----
Search should return the following location based off of this criteria…

  • August & trousers

  • August OR June & trousers

  • August OR January & trousers (should still be returned thanks to the OR)

    “highseason”: [
    “clothing”: {
    “january”: “shorts”,
    “february”: “shorts”,
    “march”: “shorts”,
    “april”: “shorts”,
    “may”: “shorts”,
    “june”: “trousers”,
    “july”: “trousers”,
    “august”: “trousers”,
    “september”: “trousers”,
    “october”: “warm trousers”,
    “november”: “warm trousers”,
    “december”: “trousers”

Possible clothing array

"clothing": [

Hi @markaugias, You could use logical operators in the filters:

{“filters”: “highseason:August AND clothing.august:shorts”}

{“filters”: “highseason:August OR clothing.june:trousers”}

You can learn more about filtering with the logical operators here.

Thanks so much @cindy.cullen - I’m using React so am using this approach with the element. Seems grand so far so thanks for your help!

1 Like