redis-om-spring icon indicating copy to clipboard operation
redis-om-spring copied to clipboard

Query by Example does not work properly with 0.8.9 version

Open shireeshshelke opened this issue 11 months ago • 1 comments

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);

shireeshshelke avatar Mar 21 '24 05:03 shireeshshelke

Good catch! Working on a fix. Thanks

bsbodden avatar Mar 21 '24 10:03 bsbodden

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

bsbodden avatar Apr 05 '24 14:04 bsbodden