redis-om-spring
redis-om-spring copied to clipboard
Query by Example does not work properly with 0.8.9 version
Querying by org.springframework.data.domain.Example<T> creates a query without any filter.
"FT.SEARCH" "com.example.demo.PersonEntityIdx" "*" "LIMIT" "0" "10000" "DIALECT" "1"
@Data
@AllArgsConstructor
@Document("person")
public class PersonEntity {
@Id
private String seqId;
@Searchable
private Long mobileNo;
}
On first deployment, where the indexes are getting created, the query gets created correctly
"FT.SEARCH" "com.example.demo.PersonEntityIdx" "( @mobileNo:1010101010)" "LIMIT" "0" "10000" "DIALECT" "1"
But starting from the second deployment (when the index creations are skipped because they already exists), it generates query without any filter.
The potential cause might be following line which returns null if the index creations are skipped for that particular entity class
final List<SchemaField> schema = indexer.getSchemaFor(entityClass);
Good catch! Working on a fix. Thanks
Notes:
- The issue here is that we have in-memory definition of an index schema that is created when the index is created
- On application restart, if the index is already in Redis, the code for the index creation was skipped (along with the in-memory definition instantiation)
- The fix is to skip the index creation but rehydrate the in-memory definition