-
Notifications
You must be signed in to change notification settings - Fork 108
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
param --subject
should support wildcard matching for subject
#1270
Comments
This already works:
Maybe you need to quote your patterns |
This does not work in my case. I'm using the nats v0.1.1 (also tried with the 0.1.6) on Windows 10. nats stream ls --subject=.C2 => the expected result are streams: nats stream ls --subject=.C4 => expected for no stream as the result. but for all of these tries, all streams are listed. if i used Thanks for reading. |
show stream info for a stream that would match |
well, I just want to have the result as same as from 'nats stream ls' but now use the |
I understand what you want, I am trying to see why it is not working for you, hence asking for more information. |
Would also help to see what your command does when run with --trace |
well, this is our internal server and by the company policy I can not send out any information like that. |
Without seeing information of what is happening or what configuration you have, I am afraid I can't help you. This works with both nats-0.1.6 and nats-0.1.4 even nats-0.0.35 |
The thing to look for in --trace is this:
Note it sends a request with the subject listed there and correctly shown. If that is working correctly and you do not see results, well then you probably dont actually have a stream that match. Or your nats server is ancient. |
In my case, the first lines of trace look like as following: **> nats -s 192.168.20.52:4222 stream ls --subject ".MV" --trace > d:\trace.txt 17:24:20 <<< $JS.API.STREAM.LIST I will have my server admin to get the nats server version. |
Well, my nats-server version is v2.10.7. |
Here the search string is “.MV” which is not valid, it only matches using nats patterns like *.MV which means 1 token before MV. Token s are separated by dot. |
well, I don't know why the '*' is hidden by this github comment editor. Sorry for not taking a preview before commit my comment. |
Ah ok. You should surround quotes text with 3 backticks and it won’t interpret as formatting. Well then given that query. What subject are you trying to match in the stream? |
As mentioned in my first comment, I used an example to describe my issue. But this does not work as expected. Because my application has the subject in format of |
The match is against the configuration of the stream not the contents of the stream. |
Sorry, I don't get what you mean. Which stream configuration should I take a review? |
Do “nats stream info” see the subjects there in the configuration? That’s what it’s matching on. It will even match empty streams. |
If you want to filter out empty streams - I dont think we have a tool/api that can match on the subjects of messages actually stored in the streams, its aimed at finding streams that could potentially store a certain subject. |
I used
So, I should develop a tool myself to scan all possible streams and match the search SUBJECT (wildcard supported) against their subjects. Thank you a ton for so patient with me. |
No worries, yeah getting the stream subjects using the info api and matching on that is probably your best bet - assuming its not just a case of empty or not streams. |
Proposed change
Ex.
nats stream ls --subject=*.tokenX
Use case
on a nats-server used day by day, the subject is constructed by day rule but all available categories of subjects may NOT appear for everyday.
Ex:
available subjects,
YYYY-MM-DD.C1
YYYY-MM-DD.C2
YYYY-MM-DD.C3
for day 1: stream STR-2025-02-10
2025-02-10.C1
2025-02-10.C2
for day 2: stream STR-2025-02-11
2025-02-11.C1
2025-02-11.C3
for day 3: stream STR-2025-02-12
2025-02-12.C2
2025-02-12.C3
then this command
nats stream ls --subject=*.C2
should list streams:
STR-2025-02-10
STR-2025-02-12
Contribution
No response
The text was updated successfully, but these errors were encountered: