Hazelcast-地图值的查询集合

Hazelcast-地图值的查询集合,hazelcast,distributed-cache,hazelcast-imap,Hazelcast,Distributed Cache,Hazelcast Imap,假设在IMap中有以下值: public class Employee{ public int empId; public List<String> categories; public List<String> getCategories(){ return this.categories; } } 公共类员工{ 公共内部管理; 公开名单类别; 公共列表getCategories(){ 返回此项。类别; } } 我想找到属于“销售”类别的所

假设在IMap中有以下值:

public class Employee{
  public int empId;
  public List<String> categories;

  public List<String> getCategories(){
    return this.categories;
  }
}
公共类员工{
公共内部管理;
公开名单类别;
公共列表getCategories(){
返回此项。类别;
}
}

我想找到属于“销售”类别的所有员工。另外,我想在getCategories()上创建一个索引,以便查询快速返回。似乎没有谓词可用于执行此操作。我该如何实现这一目标?看起来我必须写一个谓词来做这个。是否有示例代码可以向我展示如何构建使用索引的谓词?

我目前看到这种情况的唯一方法是对数据模型进行非规范化,并使用类似IMap的内容和以下值:

类EmployeeCategory{int employeeId,String category}

并在类别上添加索引


它在待办事项列表中的某个地方提供了更多的高级索引,这些索引应该能够做到这一点。

我尝试将列表迭代到一个单独的Imap,然后在客户机中查询它

IMap<String,ArrayList< categories >> cache=hazelcastInstance.getMap("cache");                   
        IMap<String, categories> cachemodified = hazelcastInstance.getMap("cachemodified") ;        
        int[] idx = { 0 };
        xref.get("urkey").forEach(cachefelement ->{
            cachemodified.put(String.valueOf(idx[0]++),cachefelement);
        });
        Predicate p = Predicates.equal("categoryId", "SearchValue");
        Collection<categories> result = cachemodified.values(p);
IMap>cache=hazelcastInstance.getMap(“缓存”);
IMap cachemodified=hazelcastInstance.getMap(“cachemodified”);
int[]idx={0};
xref.get(“urkey”).forEach(cachefelement->{
cachemodified.put(String.valueOf(idx[0]++),cachefelement);
});
谓词p=谓词.equal(“categoryId”、“SearchValue”);
采集结果=缓存修改值(p);

@pveentjer,你能回答这个问题吗?谢谢你的回答。是否有任何待办事项要添加索引到multimaps?我认为在这种情况下这会有很大的帮助。好吧,没有这样的问题。请随意制作github票证或自行实现:)将密码发送给我,我会完成实现;)