Gomathi priya
Gomathi priya

Reputation: 11

how to query corda vault and retrieve states based on a field that contains a string pattern

I have a state with customer id and customer name as a field. The requirement is to query vault and fetch customer id for customer names that contain a certain string pattern like 'ash'. Like in sql query we search for a pattern in the format '%ash%'. is this possible in vault querying? if yes , then what should the syntax be? Thanks.

Upvotes: 0

Views: 245

Answers (1)

davidawad
davidawad

Reputation: 1043

I believe this was answered on our slack instance (slack.corda.net for anyone using corda)

Try setting up a query that looks like this:

new QueryCriteria.VaultCustomQueryCriteria(Builder.like("%"+inputCustomerName+"%",customerName));

note: thanks to Corda user Amol Pednekar for his help on this question from slack.

Upvotes: 1

Related Questions