Skip to content

Comments

fix(search): advanced search now ORs same-column filters#207

Open
sreeshanth-soma wants to merge 1 commit intoopenbroadcaster:5.5-developfrom
sreeshanth-soma:search-filter-or-grouping
Open

fix(search): advanced search now ORs same-column filters#207
sreeshanth-soma wants to merge 1 commit intoopenbroadcaster:5.5-developfrom
sreeshanth-soma:search-filter-or-grouping

Conversation

@sreeshanth-soma
Copy link
Member

@sreeshanth-soma sreeshanth-soma commented Feb 19, 2026

Closes: #129

Summary

Fixes Advanced Search logic so multiple values for the same field are OR-grouped, while different fields remain AND-combined.

This makes queries behave as expected:

(genre = Action OR genre = ComedyFunny)
AND type =AND additional filters

Problem

search_filters_where_array() previously built a flat list of SQL conditions, and the caller joined everything with AND.

So selecting two genres produced:
genre_id = "1" AND genre_id = "2"

which can never match a single row, causing zero results.

Changes

Backend — core/models/media_model.php

  • Updated search_filters_where_array() to:
    • Build each filter SQL condition as before.
    • Group conditions by resolved SQL column name (after metadata/alias resolution)
    • OR conditions inside each same-column group.
    • Return grouped clauses for existing outer AND join behavior.
  • Kept all existing operator/default handling intact (eq, contains, has, metadata defaults, etc.).
  • Hoisted metadata/column mapping setup outside the per-filter loop for better efficiency.

Verification Steps

  • Open Sidebar → Media → Advanced Search.
  • Add filter: Genre is Action, click Add.
  • Add filter: Genre is ComedyFunny, click Add.
  • Add filter: Include in Dynamic Selections? is Yes, click Add.
  • Click Search.
  • Confirm results match:
    (Genre = Action OR Genre = ComedyFunny)
    AND Include in Dynamic Selections = Yes.
image image image

- Multiple genres / tags / etc. now return correct results
- (genre=Action OR genre=Comedy) AND type=...
- Zero regression on single filters or simple search
@sreeshanth-soma sreeshanth-soma changed the title fix(129): advanced search now ORs same-column filters fix: advanced search now ORs same-column filters Feb 19, 2026
@sreeshanth-soma sreeshanth-soma changed the title fix: advanced search now ORs same-column filters fix(search): advanced search now ORs same-column filters Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant