You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by joseheitor <jo...@heitorprojects.com> on 2018/11/24 08:38:09 UTC
BinaryObject nested fields syntax?
Given the following model data structure for a given document record:
{
"trans": {
"cust": {
"firstname": "Bone",
"lastname": "Klebes",
"email": "bklebes0@usgs.gov",
"gender": "Male"
},
"ipaddress": "104.89.149.184",
"date": "2017-12-01",
"amount": 1217,
"currency": "NOK"
}
}
...modelled in Java by a Transaction class and a Customer class,
And the following code to perform a ScanQuery:
String date = "2017-12-01";
int amount = 1000;
String lastname = "Klebes";
IgniteCache<Integer, BinaryObject> cache =
database.getCache().withKeepBinary();
ScanQuery<Integer, BinaryObject> filter = new ScanQuery<>(
new IgniteBiPredicate<Integer, BinaryObject>() {
@Override
public boolean apply(Integer key, BinaryObject trans)
{
if (!trans.<String>field("date").equals(date))
return false;
if (trans.<Integer>field("amount") <= amount)
return false;
*(???) if
(!trans.<String>field("customer.lastname").equals(lastname))*
return false;
return true;
}
}
);
List result = cache.query(filter).getAll();
What is the correct syntax for accessing the nested 'Customer.lastname'
field?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: BinaryObject nested fields syntax?
Posted by Evgenii Zhuravlev <e....@gmail.com>.
Hi,
In this case, customer should be also a BinaryObject, so, you have to
access it at first and only after get a certain field.
Evgenii
сб, 24 нояб. 2018 г. в 00:38, joseheitor <jo...@heitorprojects.com>:
> Given the following model data structure for a given document record:
>
> {
> "trans": {
> "cust": {
> "firstname": "Bone",
> "lastname": "Klebes",
> "email": "bklebes0@usgs.gov",
> "gender": "Male"
> },
> "ipaddress": "104.89.149.184",
> "date": "2017-12-01",
> "amount": 1217,
> "currency": "NOK"
> }
> }
>
> ...modelled in Java by a Transaction class and a Customer class,
>
> And the following code to perform a ScanQuery:
>
> String date = "2017-12-01";
> int amount = 1000;
> String lastname = "Klebes";
>
> IgniteCache<Integer, BinaryObject> cache =
> database.getCache().withKeepBinary();
> ScanQuery<Integer, BinaryObject> filter = new ScanQuery<>(
> new IgniteBiPredicate<Integer, BinaryObject>() {
> @Override
> public boolean apply(Integer key, BinaryObject trans)
> {
> if (!trans.<String>field("date").equals(date))
> return false;
> if (trans.<Integer>field("amount") <= amount)
> return false;
> *(???) if
> (!trans.<String>field("customer.lastname").equals(lastname))*
> return false;
> return true;
> }
> }
> );
> List result = cache.query(filter).getAll();
>
> What is the correct syntax for accessing the nested 'Customer.lastname'
> field?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>