Skip to content

Jetstream kv store - Prefix search / Wildcard search #957

Answered by derekcollison
codeKrowe asked this question in Q&A
Discussion options

You must be logged in to vote

If you use '.' instead in your key name that would present as different tokens to NATS and you can use wildcards to filter there.

So if I add the following to a simple KV..

> nats kv add dkv
> nats kv put dkv foo.bar HELLO
> nats kv put dkv foo.baz HELLO
> nats kv put dkv bar.bar HELLO
> nats kv put dkv bar.baz HELLO

I can then attach a consumer and use wildcards.

> nats consumer add KV_dkv
? Consumer name d
? Delivery target (empty for Pull Consumers)
? Start policy (all, new, last, subject, 1h, msg sequence) all
? Acknowledgement policy explicit
? Replay policy instant
? Filter Stream by subject (blank for all) $KV.dkv.foo.*
? Maximum Allowed Deliveries -1
? Maximum Acknowledgements Pe…

Replies: 6 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@ripienaar
Comment options

@codeKrowe
Comment options

Answer selected by derekcollison
Comment options

You must be logged in to vote
2 replies
@derekcollison
Comment options

@HeavyHorst
Comment options

Comment options

You must be logged in to vote
1 reply
@HeavyHorst
Comment options

Comment options

You must be logged in to vote
5 replies
@HeavyHorst
Comment options

@HeavyHorst
Comment options

@derekcollison
Comment options

@HeavyHorst
Comment options

@gabel
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants