How to do "hdk::query" with a condition(s)?

Say, I need to retrieve all Entities “Article” by a certain condition(s). All articles with the status = “A” and the title which contains “bb”, for instance.

hdk::query() doesn’t support that, does it? If not, how to do that properly? Retrieve all articles by hdk::query("article", 0, 0) – to the memory – and filter them by the means of Rust – via filter(...)? Is this the only way? What if there’re millions of them?

Hi @alx — I moved your post to #technical:app-development.

Right now hdk::query() has pretty limited filtering capabilities, as you say. In order to do the sort of querying you talk about, the underlying storage layer would have to understand something about the structure of the data. But presently the storage layer only understands data as strings.

I suspect that in the future we’ll need to take a look at making it easier to query data in a way that doesn’t require moving all entries into memory. My hunch is that this will look like having the storage layer understand whether the data being handed to it is JSON or a string, and indexing it accordingly. But there aren’t any plans yet.

So for now, you’re doing it exactly the way you should. In these early stages it makes the most sense for our core team to build functionality to a usable state, then focus on efficiency later.

1 Like

Hi @pauldaoust . i just wanted to add another comment on this… to cut down on the amount of post query data parsing… i am hoping that we might have a filter by entry type… eg if i only want capTokenClaim entries along with a specific key search in the entry data … I could do

hdk::query_result(
FilterByEntryType::Filter (“CapTokenClaim”.into()
QueryArgsNames::QueryName(“Id”.into()),
QueryArgsOptions {
start: 0,
limit: 1000,
headers: true,
entries: true,
})

@nphias that should be what the entry_type_names parameter is for; are you finding it to be inappropriate for what you’re trying to do? Or am I misunderstanding?