Issue with processing order of rate-limits: base, path, then query

I’m likely missing something obvious, but I’m confused why these lines aren’t producing the results I expected:

http-request set-var(req.rate_limit) base,map_beg(/etc/haproxy/maps/rates.map) if { base,map_beg(/etc/haproxy/maps/rates.map) -m found }
http-request set-var(req.rate_limit) path,map_reg(/etc/haproxy/maps/rates.map,10) unless { base,map_beg(/etc/haproxy/maps/rates.map) -m found }
http-request set-var(req.rate_limit) query,map_reg(/etc/haproxy/maps/rates.map) unless { base,map_beg(/etc/haproxy/maps/rates.map) -m found } { path,map_reg(/etc/haproxy/maps/rates.map) -m found }

Suppose, for the sake of argument, that my rates.map file has the following three lines:

domain1.com/account/ 10
^/account/ 5
search= 2

My problem is that the rules don’t process in the order I expect, which is: (1) base, (2) path, and (3) query. Instead, base takes precedence over path, but query takes precedence over both of those. I can’t see why.

If, for example, I request domain1.com/account/, the rate that attaches is 10. But if I request domain2.com/account/, the rate that attaches is 5. This tells me that the logic is working correctly between base and path. HAProxy looks to see if there’s a base entry that matches the pattern, and applies it if so, and moves to the path variables if not. So far so good. I have tested every base entry in my rates.map file and every path entry, and they all work—and interact with one another—exactly as expected.

But the query variable applies irrespective of the base or the path. If I request domain2.com/account/?search=, the rate that attaches is 2, rather than the 5 I’d have expected HAProxy to inherit from the ^/account/ line. Perhaps I’m wrong, but I’d have thought HAProxy would have found a match in the path line, and therefore triggered the unless clause in the query line. Ideally, I’d like to be able to set exceptions to my query rules either on a per-domain or per-base basis.

What am I getting wrong?

Thanks!