英文:
How to use Aerospike aeroMapper.query method without the filter argument using java client
问题
我试图通过Java客户端使用Aerospike AeroMapper的查询方法,并且记录选择逻辑是在策略中编写的,所以我不需要在方法中传递任何筛选器。
policy.filterExp = getResultPolicy();
results = aeroMapper.query(policy, ResultDto.class, null);
我正在将第3个参数传递为null,这是筛选表达式,但没有获得预期的结果。我是否遗漏了什么?
我还尝试过AerospikeClient
的方法,这些方法可能符合我的要求,但没有运气。
英文:
I am trying to use Aerospike AeroMapper's query method through java client and the record selection logic is written in the policy so I have no need to pass any filter in the method.
policy.filterExp = getResultPolicy();
results = aeroMapper.query(policy, ResultDto.class, null);
I'm passing null for the 3rd argument which is the Filter expression and not getting the expected results. Am I missing something?
I also explored AerospikeClient
methods which would match my requirement but no luck.
答案1
得分: 4
Aerospike Java Object Mapper是一个库,它封装了Aerospike Java Client,旨在在将POJO(普通的Java对象)映射到Aerospike并返回时降低所需的代码量,同时减少一些代码的脆弱性。
AeroMapper
是Java Object Mapper项目的主要接口,不是Aerospike Java Client的一部分。
你使用的query()
接口获取了一个QueryPolicy
(它可以包含一个Filter Expression)、一个class
(正如你提到的),以及一个Filter
(不是Filter Expression,Filter是基于二级索引的过滤器)。
我建议你阅读Java Object Mapper的GitHub README,特别是"Query"部分:
https://github.com/aerospike/java-object-mapper#queries
还要查看GitHub存储库测试中使用Filter Expression和Filter的查询示例(用于应用两个过滤器:一个是二级索引上的过滤器,另一个是返回结果上的过滤器):
另一个提示:在你的代码中添加你的期望结果和实际结果,这将使调试更容易。
英文:
Aerospike Java Object Mapper is a library that wraps the Aerospike Java Client which aims to lower the amount of code required when mapping POJOs (Plain Old Java Objects) to Aerospike and back as well as reducing some of the brittleness of the code.
AeroMapper
is the main interface of the Java Object Mapper project and is not part of Aerospike Java Client.
The query()
interface you used gets a QueryPolicy
(that can contain a Filter Expression), a class
(as you mentioned) and a Filter
(Not a Filter Expression, a Filter is a secondary index based filter).
I suggest you read the GitHub README of Java Object Mapper - especially "Query" section:
https://github.com/aerospike/java-object-mapper#queries
And also checkout a query example from the GitHub repository tests that uses both Filter Expression and Filter (for applying 2 filters: 1 on a secondary index and 1 on the returned results):
Another tip: add your code, your expected results and the actual results that you get, this will make debugging much easier.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论