Can the DataTables search functionality utilize boolean search (using AND, OR keywords etc.)?
Can the DataTables search functionality utilize boolean search (using AND, OR keywords etc.)?
dtdev
Posts: 9Questions: 4Answers: 0
Can the DataTables search functionality utilize boolean search (using AND, OR, etc. keywords and wildcard placeholders)?
Answers
Yes! You can utilize regex searches. See the
search()
docs for the different search modes available. The same applies tocolumn().search()
. If this option doesn't meet your needs you can create a Search Plugin where you have full control of how the search works.Kevin
Thanks Kevin. I'm aware of the RegEx search mode, but it doesn't seem to actually perform a BOOLEAN search from the search field. For example, if in the search field I type "foo OR bar" it doesn't filter only rows that contain either "foo" or "bar".
Thats because
OR
is not a regex operator. The token for regex OR searching is|
. You can experiment with this example. Either in the Global Search or the Office column search enable regex and disable smart search. Enter the search stringtokyo|london
to see the OR search work.If you wanted the user to type
tokyo OR london
you could replace theOR
with|
in the appropriate filter function to build a proper regex string.Kevin