# Equal filter not working on secondary index

**URL:** <https://discuss.aerospike.com/t/equal-filter-not-working-on-secondary-index/2931>\
**Category:** General Discussion\
**Created:** [May 10, 2016, 12:45pm UTC](https://discuss.aerospike.com/t/equal-filter-not-working-on-secondary-index/2931 "2016-05-10T12:45:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mahesh/32/1164_2.png) [@Mahesh](https://discuss.aerospike.com/u/Mahesh)\
**Post date:** [May 10, 2016, 12:45pm UTC](https://discuss.aerospike.com/t/equal-filter-not-working-on-secondary-index/2931/1 "2016-05-10T12:45:00Z")

</div>

```
NameSpace - person
Set - personData
PersonId (Key) | name (bin name)| birthDate (bin name)

NameSpace - person
Set - cityVisitedData
PersonId+CityVisited (Key)| cityName (bin name) | personId (bin name and secondary index)

```

Use case: get all cityVisitedData set record using person id.

```
		Statement stmt = new Statement();
		stmt.setNamespace("person");
		stmt.setSetName("cityVisitedData");
		stmt.setBinNames("personId");
		stmt.setFilters(Filter.equal("personId", personId));

```

I tried using filter as above but strange part is when i use filter no record is fetch and if i remove filter all records are fetch and then i have to manually do the checks for personid i am interested in.

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [May 10, 2016, 2:15pm UTC](https://discuss.aerospike.com/t/equal-filter-not-working-on-secondary-index/2931/2 "2016-05-10T14:15:02Z")

</div>

Can you use [AQL](http://www.aerospike.com/docs/tools/aql/querying_records.html) to show the indexes you have, and the results of an equivalent `SELECT person FROM person.cityVisitedData WHERE personId=123`?

---

<div class="post-metadata">

**Author:** ![Mahesh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mahesh/32/1164_2.png) [@Mahesh](https://discuss.aerospike.com/u/Mahesh)\
**Post date:** [May 11, 2016, 6:37am UTC](https://discuss.aerospike.com/t/equal-filter-not-working-on-secondary-index/2931/3 "2016-05-11T06:37:26Z")

</div>

Thanks Roben, this seems to be working when I wrote simple test case with creating and querying with an index. I still need to figure out why it is not working on my product code.
