Skip to content

Instantly share code, notes, and snippets.

@Hkazanci93
Created December 8, 2021 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hkazanci93/2e64ad8a48f3cf1659b7ddffc6d2a596 to your computer and use it in GitHub Desktop.
Save Hkazanci93/2e64ad8a48f3cf1659b7ddffc6d2a596 to your computer and use it in GitHub Desktop.
package com.yourcompany.repositories;
import java.util.*;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.repository.query.Param;
import com.yourcompany.domain.Company;
import com.redis.om.spring.annotations.Query;
import com.redis.om.spring.repository.RedisDocumentRepository;
public interface CompanyRepository extends RedisDocumentRepository<Company, String> {
// find one by property
Optional<Company> findOneByName(String name);
// geospatial query
Iterable<Company> findByLocationNear(Point point, Distance distance);
// find by tag field, using JRediSearch "native" annotation
@Query("@tags:{$tags}")
Iterable<Company> findByTags(@Param("tags") Set<String> tags);
// find by numeric property
Iterable<Company> findByNumberOfEmployees(int noe);
// find by numeric property range
Iterable<Company> findByNumberOfEmployeesBetween(int noeGT, int noeLT);
// starting with/ending with
Iterable<Company> findByNameStartingWith(String prefix);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment