You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by M Singh <ma...@yahoo.com> on 2016/07/27 01:20:55 UTC

Ignite - Using - complex object with nested attributes and search

Hi:
Can we insert a complex object into ignite cache and search it ?
Eg ( psuedocode ):public class Person {    int age,
    String name,
    List<Address> address,
    Tuple2<Person,Person> parents,
}
If it is possible, how can we annotated them ?  Also, can these nested attributes be used in SQL joins ?
Thanks    

Re: Ignite - Using - complex object with nested attributes and search

Posted by vkulichenko <va...@gmail.com>.
Can you show the exact query that you're running?

In any case, such search can't be indexed, so on large data sets it will be
very slow.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-Using-complex-object-with-nested-attributes-and-search-tp6556p6602.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite - Using - complex object with nested attributes and search

Posted by begineer <re...@gmail.com>.
vkulichenko, I have an example where I store Employee object in cache. 

public class Employee {
	@QuerySqlField(index=true)
	private String name;
	@QuerySqlField(index=true)
	private List<Address> addresses;
}

public class Address {
	private String street;
	private String city;
}

H2 console contains these fields in columns as below: I can even search
addresses using LIKE %txt%

_KEY : 1  	  	  
_VAL :	com.test.ignite.markit.Employee [idHash=878529620, hash=1730337646,
name=John, addresses=[com.test.ignite.markit.Address [idHash=1265060964,
hash=883380345, city=NY, street=street1], com.test.ignite.markit.Address
[idHash=1274742681, hash=54960993, city=UT, street=street1]]]	
NAME : John	
ADDRESSES : [com.test.ignite.markit.Address [idHash=1777853918,
hash=883380345, city=NY, street=street1], com.test.ignite.markit.Address
[idHash=932592472, hash=54960993, city=UT, street=street1]]




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-Using-complex-object-with-nested-attributes-and-search-tp6556p6583.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite - Using - complex object with nested attributes and search

Posted by vkulichenko <va...@gmail.com>.
You can't search inside a collection with SQL. Instead, you should store
Person and Address separately and link them using foreign keys, similar to
relational database. You can then join these two table in your SQL query.
Refer to the query example [1] for more details.

[1]
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-Using-complex-object-with-nested-attributes-and-search-tp6556p6573.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite - Using - complex object with nested attributes and search

Posted by Surinder Mehra <re...@gmail.com>.
You can do this using ScanQuery by passing predicate to it. Predicate will
have all conditions you want to check like
person.name.contains(searchparameter) For JOINS, you have to use SqlQuery
but I havent tried that.

On Wed, Jul 27, 2016 at 6:50 AM, M Singh <ma...@yahoo.com> wrote:

> Hi:
>
> Can we insert a complex object into ignite cache and search it ?
>
> Eg ( psuedocode ):
> public class Person {
>     int age,
>     String name,
>     List<Address> address,
>     Tuple2<Person,Person> parents,
> }
>
> If it is possible, how can we annotated them ?  Also, can these nested
> attributes be used in SQL joins ?
>
> Thanks
>
>