Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Or instead of And with multiple search filters #3440

Open
Quent1Pr opened this issue Nov 29, 2021 · 4 comments
Open

Use Or instead of And with multiple search filters #3440

Quent1Pr opened this issue Nov 29, 2021 · 4 comments

Comments

@Quent1Pr
Copy link
Contributor

Quent1Pr commented Nov 29, 2021

How is it possible to search in a rails admin list with "OR" multiple filters ?

It possible to add conditions but only with "AND".

@Quent1Pr Quent1Pr changed the title Use Or instead of And with multiple search conditions Use Or instead of And with multiple search filters Nov 29, 2021
@codealchemy
Copy link
Contributor

The open Search box will use OR to join across configured fields. You can also customize the search for a configured model.

if config.list.search_by
scope.send(config.list.search_by, query)
else
wb = WhereBuilder.new(scope)
fields.each do |field|
value = parse_field_value(field, query)
wb.add(field, value, field.search_operator)
end
# OR all query statements
wb.build
end

Does this help address what you're looking for?

@Quent1Pr
Copy link
Contributor Author

Quent1Pr commented Dec 2, 2021

@codealchemy Thank you for your answer.

I'm concerning about how to join filters and not the search box.
OR is used to join across configured fields but AND is used if we add filters with the same field multiple times.

Here is an example of input that will use AND

I think OR would be more appropriate in this case. It's impossible to a field to be exactly two different things. I have opened #3442 about that.

@rnevius
Copy link

rnevius commented Oct 30, 2024

Has this functionality been added? Double checking before I write my own methods.

@mshibuya
Copy link
Member

It's not added, that's why this issue is still open. Attempts were made like #3445 and #3696, but we're yet to solve this problem cleanly enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants