You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by daniels <ra...@gmail.com> on 2017/11/27 07:15:46 UTC
Indexes on custom objects
"Indexes for nested collections and in particular for maps are not
supported.".
Is it true for complex(custom) objects
Namely ,can I make my custom type indexable ?
class Model {
//index=true
private CustomObject obj;
}
class CustomObject{
//index=true
private String objName;
}
can I do filter on cache(of Models) with "objName" ?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexes on custom objects
Posted by daniels <ra...@gmail.com>.
Thank you dear ALexey,it wors for me. )
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexes on custom objects
Posted by Alexey Popov <ta...@gmail.com>.
Hi Daniels,
Actually, you can have & use indexes for single (1 to 1 relation) nested
objects. You can't have indexes for nested collections.
"Indexes for nested *collections* and in particular for *maps* are not
supported.".
I wonder why Examples does not have that. Please see how it could be used:
public class Model implements Serializable {
@QuerySqlField
private CustomObject obj;
public Model(String sortField) {
this.obj = new CustomObject(sortField);
}
}
public class CustomObject {
@QuerySqlField(index = true)
private String objName;
public CustomObject(String objName) {
this.objName = objName;
}
}
Sample queries:
List res = cache.query(new SqlQuery<>(Model.class, "ORDER BY
objName")).getAll();
res = cache.query(new SqlQuery<>(Model.class,
"objName=?").setArgs(1)).getAll();
Thank you,
Alexey
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/