Swift - InstantSearch - Filtering Numeric Values doesn't work

Hello guys,

I am trying to filter an index by using numeric filter. Therefore, I am using following approach:

    let currentDate = Date()
    let currentDateIntValue = Int(currentDate.timeIntervalSince1970)
    let filterState = FilterState()

    // search for active challenges
    if (challengeStateSegmentedControl.selectedSegmentIndex == 1) {
       filterState[or: "disjunctiveGroup"].add(Filter.Numeric(attribute: "beginningTimeStamp",operator: .lessThan, value: Double(currentDateIntValue)),
        Filter.Numeric(attribute: "endingTimeStamp",operator: .greaterThan, value: Double(currentDateIntValue)))

The approach above gives me all the content so the filtering seems not to work. I already checked the condition - I should get at least one result. I also checked the configuration of my index. The attributes ** beginningTimeStamp** and ** endingTimeStamp** are set for faceting (filter only).

Can anyone help here, please? thank you very much

Best regards,

Sorry, my mistake. I used an OR filter instead of an AND filter. Now it works :slight_smile:

1 Like