searchbox core
1.0.0
Searchbox ist ein leichtes Suchframework, das auf Redis basiert.

In der Wiki finden Sie vollständige Dokumentation, Beispiele, Betriebsdetails und andere Informationen.
< dependency >
< groupId >com.quebic.searchbox</ groupId >
< artifactId >searchbox-core</ artifactId >
< version >1.0.0-SNAPSHOT</ version >
</ dependency >
@ SpringBootApplication
@ EnableSearchBox
public class App
{
public static void main ( String [] args )
{
SpringApplication . run ( App . class , args );
}
} searchbox.appname = movies-search-app
searchbox.page.length = # Search result page size. Default value is 10
server.host = # Http server host. Default value is localhost
server.port = # Http server port. Default value is 1028
redis.host = # Redis server host. Default value is localhost
redis.port = # Redis server port. Default value is 6379
public class Movie {
@ Id
@ Index
private int id ;
@ Index
private String title ;
@ Index
private String director ;
private int duration ;
... @ RestController
@ RequestMapping ( "/movies" )
public class MovieController {
@ Autowired
private SearchBoxOperations searchBoxOperations ;
...
< T > void insert ( T object ) throws SearchBoxOperationsException
< T > void update ( T object ) throws SearchBoxOperationsException
< T > void save ( T object ) throws SearchBoxOperationsException< T > SearchResult < T > searchByField ( Class < T > cls , String field , Object searchValue , Page page ) throws SearchBoxOperationsException ;searchBoxOperations.searchByField(Movie.class, "id", id)< T > SearchResult < T > searchByFieldPerfix ( Class < T > cls , String field , Object searchPrefix , Page page , boolean allWords ) throws SearchBoxOperationsException ;searchBoxOperations.searchByFieldPerfix(Movie.class, "title", "av") => ["Avatar", "Avengers", ...]< T > SearchResult < T > searchByFieldPattern ( Class < T > cls , String field , String pattern , Page page ) throws SearchBoxOperationsException ;searchBoxOperations.searchByFieldPattern(Movie.class, "title", "*nic") => ["Titanic", ...] < T > SearchResult < T > search ( Class < T > cls , Query query , Page page ) throws SearchBoxOperationsException ;searchBoxOperations.search(Movie.class, new Query(Criteria.where("id").is(7))) @ QueryController
public class QueryFunctions {
@ QueryFunction ( "query1" )
public QueryHolder query1 () throws Exception {
Criteria c = Criteria
. where ( "@parm_key" ). is ( "@parm_value" );
Query query = new Query ( c );
return new QueryHolder ( Movie . class , query );
}
...Abfragen werden Platzhalter mit '@' Präfix verwendet, um Laufzeitwerte in Abfrage zu übergeben. Ex: @Parm_key, @Parm_Value
Anrufen von Queryfunktionen mithilfe von Searchboxoperationen.
< T > SearchResult < T > search ( String queryName , Map < String , Object > inputParms , Page page ) throws SearchBoxOperationsException ; String queryName = "query1" ;
Map < String , Object > parms = new HashMap <>();
parms . put ( "parm_key" , "title" );
parms . put ( "parm_value" , "Avatar" );
searchBoxOperations . search ( "query1" , parms );