Does filter expression benifit from secondary index

Hi, I need to query data from a set with two bins, one is string type, the other is boolean type. Because of only one bin can be used as filter when query, I use the string-typed bin as filter, and make a filter expression to filter the boolean-typed bin.

The string typed bin has been set as secondary index. The boolean-typed is not set as secondary index now.

  1. Could query be faster, if I set a secondary index on the boolean-typed bin?

  2. Another question is if bin type of a sindex can be boolean-type? I check the doc said the bin type should be numeric, string or geo2dsphere.

Hi @dzhhh, welcome to the forum!

To answer your second question first, there isn’t a way to create a secondary index on a boolean-typed bin. To do something like this, your best bet would be storing the boolean as a number, like 1 | 0 and creating an index on that.

If you were able to create an index on the bin you are trying to filter, that would be faster than a filter and filter expression like you’re working with now. Hope that helps!

Does the filter expression benefit from a secondary index? If a filter uses a bin, will creating a secondary index on that bin make the filter query faster than before?

Currently, no - but this is planned.

1 Like

This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.