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

Problem with multi-column search #428

Open
ecarlotti opened this issue Feb 11, 2019 · 2 comments
Open

Problem with multi-column search #428

ecarlotti opened this issue Feb 11, 2019 · 2 comments

Comments

@ecarlotti
Copy link

First of all, let me start by saying this component is AMAZING! This saved me lots of programming hours.

I'm now trying to implement individual column searching, as specified by the DataTables documentation on https://datatables.net/examples/api/multi_filter.html, but I'm unable to make it work properly. It seems the search function will work correctly if the data is all in memory, but it seems to fail when the data is loaded from the server.

I'm not really sure this is an issue on the DataTables component itself or something you can fix here, so please feel free to direct me to the proper help channel if needed.

Right now my code is implemented exactly as found in the documentation I pointed above, but the search works only on the first column I try whatever it is. From the second column on, the search is returning something I cannot identify. With my data, the first search (which is a username) returns a total of 987 documents. The second criteria alone (which is a table name) returns a total of 292,056 documents and both should return 27 documents ($and) or 293,016 documents ($or) but the table info gives me back 286,126 entries which I cannot understand because it doesn't fits any logical criteria.

Can you help? What I could possibly be doing wrong?

Thanks in advance,
/Edson

@ecarlotti
Copy link
Author

I actually found out what is happening with the queries. The component is doing a "OR" with the fields but in MongoDB the search is performed using regular expressions to simulate a search that "contains" the column text. Using the 'contains' syntax in MongoDB (i.e. { $or: [ { field1: /.value1./i }, { field2: /.value2./i } ] }) the search returns the exact number of records I was seeing before.

This is not what I expected, because if I do the same search using the Datatables component alone, the multi-column search is performed like a "AND" operator, so I now believe this change in behaviour is directly related to the search enhancements implemented in Tabular.

Could you please verify if this is the case, and if so, clarify if this is the planned behaviour or is this a bug?

Thanks again,
/Edson

@evolross
Copy link

evolross commented Jan 4, 2023

Either way, the search in this package needs to be redesigned. Doing a massive $or $regex is causing us optimization problems with MongoDB's Atlas constantly complaining. There's no way to write a good index for it. We're about to do a fork and rework this, unless I can find a ticket or developer on here that's also doing this or is intereseted.

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

2 participants