Explicit Search in Pi-hole Admin Console

When using the Query Log Search field, I can't seem to search explicitly, even with quotation marks. For example I want to filter/search for IP 10.0.1.6, but instead I'm getting 10.0.1.6*, where the * is all other numbers as well.

Is there a way to do this through the admin console or must I use the terminal? Thanks.

Are you seeing all the other IP's, or only those IPs that lead with 10.0.1.6 (i.e. 10.0.1.6, 10.0.1.61, etc.).

Just ones that lead with 10.0.1.6, so for example 10.0.1.69 and 10.0.1.6

This is normal and the same thing I see.

You can avoid this by mapping IPs to client names in either /etc/hosts or in a new configuration file in /etc/dnsmasq.d

Or, from the CLI, you can search the query log with grep "10.0.1.6" /var/log/pihole.log

It's the current behavior but I wouldn't say it's normal. A search for 192.168.0.1 should return just that IP and not 192.168.0.121.

I'll agree with that. My comment was poorly worded and I intended it to mean that the OP's Pi-hole was not malfunctioning.

1 Like

Well take it into suggestion then, thanks. And great work anyway you look at it ;).

I converted the post to a feature request.

Well, everything the on-click does is copying the current text into the search box on the top right. Would you like to change the search behavior to need to be exact? I'm pretty sure we'll loose more functionality than we get.

For instance, you can now type: google and the search result will be all domain containing google somewhere in their name.

If we change this to exact search, such a thing will not be possible any more. For instance, using our "smart" search algorithm, you can currently put multiple constraints at the same time, e.g.,


where I searched for a client + domain contribution. Both only in parts.

However, I'm always open for ideas and happy to try and discuss them with you.

I suggest a combination:

Let your smart search algorithm understand quotation marks as exact search. On click on type/domain/client (with filtering activated) add quotation marks to the search string to make it exact too. This would solve the above query log client sort issue as I would guess most users expect an exact search when they click on one of those fields.

This way you won't loose the flexibility of the current implementation but add the ability for exact search and change the default (and expected?) on-click behavior.

I added some improvements to the Query Log page (no other page so far, this is only for testing the behavior).

Please try

pihole checkout web tweak/exact_searching

What I did was decoupling filtering and searching as this made things cleaner. As it is not immediately obvious what is now being filtered on, we show this in the reset button.

What you can do now is:

  1. Click on an item (query type, domain, client) to filter exactly on this item (clicking on github.com will not show collector.github.com)

    Probably a better example is that clicking on A doesn't show any AAAA queries any longer:
  2. You can combine filtering when you hold [Ctrl] when clicking, the reset button text will again tell you what you did:

    It is possible to add the same field multiple times to the filter, this will cause no issues, even when it doesn't make too much sense:
  3. Searching works on top of this filtering, for instance, you can still get all *.github.com requests from an exact filtering on a specific client by clicking on the client and then entering github into the search field:
  4. Clearing the filtering does not empty the search field any longer as filtering is now separate from searching.

Testing would be highly appreciated as such a fundamental rewrite is likely to have some side-effects I have not yet considered.

edit: I already added the missing space in front of the and in the button seen in the screenshots above.

I cannot get this to work on any Mac browser. The OS or browser intercepts the Ctrl key combination with popups. Works fine on a PC. I tried alternate key combinations on the Mac with no success.

Firefox Mac:

Safari Mac or Chrome Mac (same behavior):

Interesting. I have no Mac devices to try this. I can add a Mac specific key modifier as well, I wasn't aware of a special meaning of Ctrl on a Mac. What would be the equivalent (which key to hold down when selecting multiple elements)?

edit Google told me (searched for "Mac select multiple"):

Select multiple items: Press and hold the Command key, then click the items.

There are several SE posts about that this "Command key" cannot be captured reliably. Could you please try whether it works for you in all browsers you have available on your Mac?

Nice work!
I tested it on Linux/Chrome+Firefox and everything works.

I'm nor sure if I'm total happy with decoupled filtering/searching. I't makes searching/filtering kind of complicated to understand what does what. It was intuitive before when the "filter" tag showed up in the search field and could be deleted from there as well.
I'll think about a way to improve that.

One additional thing concerns the "multiselection". From the wording used ("use Ctrl + click for multi-selections") I would expect to hold Ctrl and select multiple things and apply the filter on Ctrl release. If such behavior is impossible to code (or not desired) I suggest to change wording to "use Ctrl + click to add selection". That would make it clearer that it is a multi-step process.

Okay, I'll do this. It is neither the intended behavior nor easy to implement this other interpretation.

That's why I put the text on the button. If you find this too discreet, another idea would be to color-highlight the columns filtering is applied on.

I did look for possible ways to achieve this, however, modifying the search algorithm in a way to change the meaning of "" is not possible without modifying the vendor code directly. That is because "" already has a special meaning for Datatables as in:

  • Alice Bob matches Alice and Bob, however,
  • "Alice Bob" does not match Alice and Bob.
    (only a space is allowed to be in between Alice and Bob)

However, any modification to the vendor-provided file (this one) would likely be overwritten when someone wants to update this file by simply replacing it with a more recent version. There is no way we could get this working in a reliable fashion. Maybe with our own fork of DataTables, but that is making things way too complicated.

@jfb I added the Meta key modifier. Please test the most recent version on your Mac.


It should now be even clearer which columns causes filtering:

It works on a Mac with the command key and a click. We might want to change the wording on the Apply Filtering box from:

... (use Ctrl + click to add elements to the current selection)

to

... (use Ctrl + click [or the equivalent in your OS] to add elements to the current selection)

It is already a quite bulky text. However, users will likely not find it in this case, what do you think?

How about

(use Ctrl/ + to add elements to the current selection)

?

edit Maybe even: