You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Andrey Kornev <an...@hotmail.com> on 2017/09/14 19:28:19 UTC
Indexing collection fields
Hello,
My POJO has a collection field (e.g. a list of strings). Is indexing such fields supported? If not, what are my options in terms of being able to look up data by any element in the collection?
Thanks
Andrey
Re: Indexing collection fields
Posted by vkulichenko <va...@gmail.com>.
Andrey,
I think it's possible in theory, but I doubt it will appear in the product
any time soon. Unless you want to contribute, of course :)
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexing collection fields
Posted by Andrey Kornev <an...@hotmail.com>.
Got it! Thanks, Val.
What would it take to add support for indexing/querying of primitive collection fields out of the box? It's less cumbersome, more user-friendly, would consume less memory and hopefully run faster (e.g. no need for transactions on the write side, no need for joins on the read side, etc.).
Has the community considered adding this feature?
Thanks
Andrey
________________________________
From: vkulichenko <va...@gmail.com>
Sent: Friday, September 15, 2017 10:43 AM
To: user@ignite.apache.org
Subject: Re: Indexing collection fields
Andrey,
You should remove collections from the POJO and create two new types (e.g.
StringValue and IntValue) that reference the parent POJO by ID. Something
like this:
StringValue {
String val;
int pojoid;
}
This way you will be able to index StringValue#val and join it with Pojo.
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexing collection fields
Posted by vkulichenko <va...@gmail.com>.
Andrey,
You should remove collections from the POJO and create two new types (e.g.
StringValue and IntValue) that reference the parent POJO by ID. Something
like this:
StringValue {
String val;
int pojoid;
}
This way you will be able to index StringValue#val and join it with Pojo.
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexing collection fields
Posted by Andrey Kornev <an...@hotmail.com>.
Hey Val! Thanks for your reply!
Unfortunately, I didn't quite get it what you're suggesting. Could you please explain how it can be done given this cache value class?
class Pojo {
long id;
Collection<String> stringCollection;
Collection<Integer> intCollection;
}
Thanks again!
Andrey
________________________________
From: vkulichenko <va...@gmail.com>
Sent: Thursday, September 14, 2017 4:45 PM
To: user@ignite.apache.org
Subject: Re: Indexing collection fields
Hi Andrey,
No, you can't index data that is inside a collection. To achieve that, you
should create a separate entry for each element of this transaction and save
them in a cache separately.
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Indexing collection fields
Posted by vkulichenko <va...@gmail.com>.
Hi Andrey,
No, you can't index data that is inside a collection. To achieve that, you
should create a separate entry for each element of this transaction and save
them in a cache separately.
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/