在redis-om-spring中,我只需向存储库添加一个搜索方法就可以搜索所有字段。
public interface ProductRepository extends RedisDocumentRepository<Product, String> {
Page<Product> search(String text, Pageable pageable);
}
使用EntityStream时,我可以搜索特定字段,但不能搜索所有字段。
var result = entityStream.of(Product.class)
.anyMatch(new StartsWithPredicate<>(Product$.UNIQUE_ID.getField(),"100790"))
@AllArgsConstructor
public class Product{
@Id
String uniqueId;
@Searchable
String field1;
@Searchable
String field2;
@Searchable
String fieldN;
}
repo.save(new Product("UA","searchForA1","searchForA2","searchForAN");
repo.save(new Product("UB","searchForB1","searchForB2","searchForBN");
repo.save(new Product("UC","searchForC1","searchForC2","searchForCN");
我需要在所有字段中搜索。我在EntityStream API中遗漏了什么还是这是不可能的?
产生的东西:
FT.SEARCH my-idx "thesearchTerm"
1条答案
按热度按时间4xy9mtcn1#
是的,
SearchStream
接口中有一个filter
方法,它接受自由格式的文本String:请参见www.example.comhttps://github.com/redis/redis-om-spring/blob/main/redis-om-spring/src/main/java/com/redis/om/spring/search/stream/SearchStream.java#L20