# Getting error for BatchGet and FilterExpression

**URL:** <https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824>\
**Category:** Go Client\
**Tags:** error\
**Created:** [September 15, 2021, 8:49am UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824 "2021-09-15T08:49:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zserg](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/zserg/32/1734_2.png) [@zserg](https://discuss.aerospike.com/u/zserg)\
**Post date:** [September 15, 2021, 8:49am UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/1 "2021-09-15T08:49:16Z")

</div>

Hello. I am trying to use BatchGet operation with filter expression. And if at least one bin of the set does not match the conditions, I get error ““ResultCode: FILTERED\_OUT, Iteration: 0, InDoubt: false, Node: : Transaction filtered out”” The same conditions of filter work fine when used in a Query.

This is my go-code:

> var policy = as.NewBatchPolicy()
> 
> policy.FilterExpression = as.ExpGreater( as.ExpListGetByValue( as.ListReturnTypeCount, as.ExpStringVal(location), as.ExpListBin(“allowed”), ), as.ExpIntVal(1), )
> 
> recs, err := client.BatchGet(policy, keys)

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [September 15, 2021, 4:54pm UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/2 "2021-09-15T16:54:05Z")

</div>

If a key in the list you provide does not match the criteria, that key will be filtered out and the returned value will be `nil`. The error lets you know what happened.

---

<div class="post-metadata">

**Author:** ![zserg](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/zserg/32/1734_2.png) [@zserg](https://discuss.aerospike.com/u/zserg)\
**Post date:** [September 16, 2021, 6:30am UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/3 "2021-09-16T06:30:13Z")

</div>

> [@Khosrow\_Afroozeh](#):
>
> If a key in the list you provide does not match the criteria, that key will be filtered out and the returned value will be `nil` . The error lets you know what happened.

Look, for example I have a set with 2 rows:

```auto
id some_bin
1 1
2 2

```

And the condition

> policy.FilterExpression = as.ExpGreater(as.ExpIntBin(“some\_bin”), as.ExpIntVal(1))

will return error for client.BatchGet(policy, keys)

```auto
var keys []*as.Key
ids := int{1,2}
for _, id := range ids {
	key, _ := as.NewKey(Namespace, Set, id)
	keys = append(keys, key)
}
var policy = as.NewBatchPolicy()
recs, err := client.BatchGet(policy, keys)

```

and will return 1 row with some\_bin=2 for client.Query(qpolicy, stmt)

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [September 16, 2021, 5:22pm UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/4 "2021-09-16T17:22:47Z")

</div>

That’s what is supposed to happen. You get some keys back where the expression applied, and you get an error that tells you the reason some others were not was that the condition didn’t match. What did you expect to get?

---

<div class="post-metadata">

**Author:** ![zserg](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/zserg/32/1734_2.png) [@zserg](https://discuss.aerospike.com/u/zserg)\
**Post date:** [September 17, 2021, 5:13am UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/5 "2021-09-17T05:13:41Z")

</div>

I expect to return rows for the specified ids that match the condition. In the previous example, this is a line with id = 2 But instead I get FILTERED\_OUT error

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [September 29, 2021, 12:15pm UTC](https://discuss.aerospike.com/t/getting-error-for-batchget-and-filterexpression/8824/6 "2021-09-29T12:15:58Z")

</div>

Sorry for my late response, the forum didn’t send me notifications. As noted above, you get your results, in addition to an error that tells you some keys where found but filtered. Is it your expectation that the error about filtered records should not be returned?
