diff --git a/pom.xml b/pom.xml index 8c5da14b0..6e53255b0 100644 --- a/pom.xml +++ b/pom.xml @@ -134,6 +134,10 @@ org.codehaus.mojo wagon-maven-plugin + + org.asciidoctor + asciidoctor-maven-plugin + diff --git a/src/docbkx/index.xml b/src/docbkx/index.xml deleted file mode 100644 index dc918b8ba..000000000 --- a/src/docbkx/index.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - Spring Data Elasticsearch - - - BioMed Central - Development Team - - - - - Copies of this document may be made for your own use and for - distribution to others, provided that you do not - charge any fee for - such copies and further provided that each copy - contains this - Copyright Notice, whether - distributed in print or electronically. - - - - - 2013-2014 - The original author(s) - - - - - - - - - Reference Documentation - - - - - - - - - - - Appendix - - - - - - - - - diff --git a/src/docbkx/preface.xml b/src/docbkx/preface.xml deleted file mode 100644 index a45737445..000000000 --- a/src/docbkx/preface.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - Preface - The Spring Data Elasticsearch project applies core Spring - concepts to - the - development of solutions using the Elasticsearch Search - Engine. - We have povided a "template" as a high-level abstraction for - storing,querying,sorting and faceting documents. You will notice - similarities - to the Spring data solr and - mongodb support in the Spring Framework. - -
- Project Metadata - - - - Version Control - - - git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git - - - - -
-
- Requirements - - Requires - Elasticsearch - 0.20.2 and above or optional dependency or not even that if you are - using Embedded Node Client - -
-
\ No newline at end of file diff --git a/src/docbkx/reference/data-elasticsearch.xml b/src/docbkx/reference/data-elasticsearch.xml deleted file mode 100644 index f983dd7e9..000000000 --- a/src/docbkx/reference/data-elasticsearch.xml +++ /dev/null @@ -1,508 +0,0 @@ - - - - Elasticsearch Repositories - - This chapter includes details of the Elasticsearch repository - implementation. - - -
- Introduction - -
- Spring Namespace - - - The Spring Data Elasticsearch module contains a custom namespace - allowing - definition of repository beans as well as elements for - instantiating - a - ElasticsearchServer - . - - - - Using the - repositories - element looks up Spring Data repositories as described in - - . - - - - Setting up Elasticsearch repositories using Namespace - <?xml version="1.0" encoding="UTF-8"?> - <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/data/elasticsearch - http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd"> - - <elasticsearch:repositories base-package="com.acme.repositories" /> - </beans> - - - - Using the - Transport Client - or - Node Client - element registers an instance of - Elasticsearch Server - in the context. - - - Transport Client using Namespace - <?xml version="1.0" encoding="UTF-8"?> - <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/data/elasticsearch - http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd"> - - <elasticsearch:transport-client id="client" cluster-nodes="localhost:9300,someip:9300" /> - </beans> - - - - Node Client using Namespace - <?xml version="1.0" encoding="UTF-8"?> - <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/data/elasticsearch - http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd"> - - <elasticsearch:node-client id="client" local="true"" /> - </beans> - - -
-
- Annotation based configuration - The Spring Data Elasticsearch repositories support cannot only - be - activated through an XML namespace but also using an annotation - through JavaConfig. - - - Spring Data Elasticsearch repositories using JavaConfig - - - @Configuration - @EnableElasticsearchRepositories(basePackages = - "org/springframework/data/elasticsearch/repositories") - static class Config { - - @Bean - public ElasticsearchOperations elasticsearchTemplate() { - return new ElasticsearchTemplate(nodeBuilder().local(true).node().client()); - } - } - - - The configuration above sets up an - Embedded Elasticsearch Server - which is used by the - ElasticsearchTemplate - . Spring Data Elasticsearch Repositories are activated using the - @EnableElasticsearchRepositories - annotation, which - essentially carries the same attributes as the XML - namespace does. If no - base package is configured, it will use the - one - the configuration class - resides in. - - -
-
- Elasticsearch Repositores using CDI - The Spring Data Elasticsearch repositories can also be set up - using CDI - functionality. - - - Spring Data Elasticsearch repositories using JavaConfig - - class ElasticsearchTemplateProducer { - - @Produces - @ApplicationScoped - public ElasticsearchOperations createElasticsearchTemplate() { - return new ElasticsearchTemplate(nodeBuilder().local(true).node().client()); - } - } - - class ProductService { - - private ProductRepository repository; - - public Page<Product> findAvailableBookByName(String name, Pageable pageable) { - return repository.findByAvailableTrueAndNameStartingWith(name, pageable); - } - - @Inject - public void setRepository(ProductRepository repository) { - this.repository = repository; - } - } - - -
-
-
- Query methods -
- Query lookup strategies - - The Elasticsearch module supports all basic query building - feature as String,Abstract,Criteria or - have - it being derived from the - method name. - - - - Declared queries - - Deriving the query from the method name is not always sufficient - and/or may result in unreadable method names. In this case one - might make either use of - @Query - annotation (see - - ). - - -
- -
- Query creation - - - Generally the query creation mechanism for Elasticsearch works as - described - in - - . Here's a short example - of what a Elasticsearch query method - translates into: - - Query creation from method names - public interface BookRepository extends Repository<Book, String> - { - List<Book> findByNameAndPrice(String name, Integer price); - } - - - The method name above will be translated into the following - Elasticsearch json query - - - { "bool" : - { "must" : - [ - { "field" : {"name" : "?"} }, - { "field" : {"price" : "?"} } - ] } } - - - - - A list of supported keywords for Elasticsearch is shown below. - - Supported keywords inside method names - - - - - - - Keyword - Sample - Elasticsearch Query String - - - - - - And - - - findByNameAndPrice - - - {"bool" : {"must" : [ {"field" : {"name" : "?"}}, - {"field" : {"price" : "?"}} ]}} - - - - - - Or - - - findByNameOrPrice - - - {"bool" : {"should" : [ {"field" : {"name" : "?"}}, - {"field" : {"price" : "?"}} ]}} - - - - - - Is - - - findByName - - - {"bool" : {"must" : {"field" : {"name" : "?"}}}} - - - - - Not - - - findByNameNot - - - {"bool" : {"must_not" : {"field" : {"name" : "?"}}}} - - - - - - Between - - - findByPriceBetween - - - {"bool" : {"must" : {"range" : {"price" : {"from" : - ?,"to" : ?,"include_lower" : true,"include_upper" : true}}}}} - - - - - - LessThanEqual - - - findByPriceLessThan - - - {"bool" : {"must" : {"range" : {"price" : {"from" : - null,"to" : ?,"include_lower" : true,"include_upper" : - true}}}}} - - - - - - GreaterThanEqual - - - findByPriceGreaterThan - - - {"bool" : {"must" : {"range" : {"price" : {"from" : - ?,"to" : null,"include_lower" : true,"include_upper" : - true}}}}} - - - - - - Before - - - findByPriceBefore - - - {"bool" : {"must" : {"range" : {"price" : {"from" : - null,"to" : ?,"include_lower" : true,"include_upper" : - true}}}}} - - - - - - After - - - findByPriceAfter - - - {"bool" : {"must" : {"range" : {"price" : {"from" : - ?,"to" : null,"include_lower" : true,"include_upper" : - true}}}}} - - - - - - Like - - - findByNameLike - - - {"bool" : {"must" : {"field" : {"name" : {"query" : - "?*","analyze_wildcard" : true}}}}} - - - - - - StartingWith - - - findByNameStartingWith - - - {"bool" : {"must" : {"field" : {"name" : {"query" : - "?*","analyze_wildcard" : true}}}}} - - - - - - EndingWith - - - findByNameEndingWith - - - {"bool" : {"must" : {"field" : {"name" : {"query" : - "*?","analyze_wildcard" : true}}}}} - - - - - - Contains/Containing - - - findByNameContaining - - - {"bool" : {"must" : {"field" : {"name" : {"query" : - "*?*","analyze_wildcard" : true}}}}} - - - - - - In - - - findByNameIn(Collection<String>names) - - - {"bool" : {"must" : {"bool" : {"should" : [ {"field" : - {"name" : "?"}}, {"field" : {"name" : "?"}} ]}}}} - - - - - - NotIn - - - findByNameNotIn(Collection<String>names) - - - {"bool" : {"must_not" : {"bool" : {"should" : {"field" : - {"name" : "?"}}}}}} - - - - - - Near - - - findByStoreNear - - - Not Supported Yet ! - - - - - True - - - findByAvailableTrue - - - {"bool" : {"must" : {"field" : {"available" : true}}}} - - - - - - False - - - findByAvailableFalse - - - {"bool" : {"must" : {"field" : {"available" : false}}}} - - - - - - OrderBy - - - findByAvailableTrueOrderByNameDesc - - - {"sort" : [{ "name" : {"order" : "desc"} }],"bool" : - {"must" : {"field" : {"available" : true}}}} - - - - - -
-
-
-
- Using @Query Annotation - - - Declare query at the method using the - <interfacename>@Query</interfacename> - annotation. - - - public interface BookRepository extends ElasticsearchRepository<Book, - String> { - @Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}") - Page<Book> findByName(String name,Pageable pageable); - } - - -
- -
- - -
\ No newline at end of file diff --git a/src/docbkx/reference/elasticsearch-misc.xml b/src/docbkx/reference/elasticsearch-misc.xml deleted file mode 100644 index 78096a523..000000000 --- a/src/docbkx/reference/elasticsearch-misc.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - Miscellaneous Elasticsearch Operation Support - - - This chapter covers additional support for Elasticsearch operations - that cannot be directly accessed via the repository - interface. - It is - recommended to add those operations as custom - implementation as - described in - - . - - -
- Filter Builder - - Filter Builder improves query speed. - - - - private ElasticsearchTemplate elasticsearchTemplate; - SearchQuery searchQuery = new NativeSearchQueryBuilder() - .withQuery(matchAllQuery()) - .withFilter(boolFilter().must(termFilter("id", documentId))) - .build(); - Page<SampleEntity> sampleEntities = - elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class); - - -
-
- Using Scan And Scroll For Big Result Set - - Elasticsearch has scan and scroll feature for getting big result set - in chunks. - ElasticsearchTemplate - has scan and scroll methods that can be used as below. - - - - Using Scan and Scroll - - - SearchQuery searchQuery = new NativeSearchQueryBuilder() - .withQuery(matchAllQuery()) - .withIndices("test-index") - .withTypes("test-type") - .withPageable(new PageRequest(0,1)) - .build(); - String scrollId = elasticsearchTemplate.scan(searchQuery,1000,false); - List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>(); - boolean hasRecords = true; - while (hasRecords){ - Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L , new ResultsMapper<SampleEntity>() - { - @Override - public Page<SampleEntity> mapResults(SearchResponse response) { - List<SampleEntity> chunk = new ArrayList<SampleEntity>(); - for(SearchHit searchHit : response.getHits()){ - if(response.getHits().getHits().length <= 0) { - return null; - } - SampleEntity user = new SampleEntity(); - user.setId(searchHit.getId()); - user.setMessage((String)searchHit.getSource().get("message")); - chunk.add(user); - } - return new PageImpl<SampleEntity>(chunk); - } - }); - if(page != null) { - sampleEntities.addAll(page.getContent()); - hasRecords = page.hasNextPage(); - } - else{ - hasRecords = false; - } - } - } - - -
-
\ No newline at end of file diff --git a/src/docbkx/reference/repositories.xml b/src/docbkx/reference/repositories.xml deleted file mode 100644 index 25206728d..000000000 --- a/src/docbkx/reference/repositories.xml +++ /dev/null @@ -1,1498 +0,0 @@ - - - - Repositories - -
- Introduction - - Implementing a data access layer of an application has been - cumbersome for quite a while. Too much boilerplate code had to be - written. - Domain classes were anemic and not designed in a real object oriented or - domain driven manner. - - - Using both of these technologies makes developers life a lot - easier - regarding rich domain model's persistence. Nevertheless the amount of - boilerplate code to implement repositories especially is still quite - high. - So the goal of the repository abstraction of Spring Data is to reduce - the - effort to implement data access layers for various persistence stores - significantly. - - - The following chapters will introduce the core concepts and - interfaces of Spring Data repositories in general for detailled - information on the specific features of a particular store consult - the - later chapters of this document. - - - - As this part of the documentation is pulled in from Spring Data - Commons we have to decide for a particular module to be used as - example. - The configuration and code samples in this chapter are using the JPA - module. Make sure you adapt e.g. the XML namespace declaration, - types to - be extended to the equivalents of the module you're actually - using. - - -
- -
- Core concepts - - - The central interface in Spring Data repository abstraction is - Repository - (probably not that much of a - surprise). It is typeable to the domain class to manage as well as the id - type of the domain class. This interface mainly acts as marker interface - to capture the types to deal with and help us when discovering - interfaces - that extend this one. Beyond that there's - CrudRepository - which provides some - sophisticated functionality around CRUD for the entity being - managed. - - - - - <interfacename>CrudRepository</interfacename> - interface - - - - - - - - - - - - - - - - - - public interface CrudRepository<T, ID extends Serializable> - extends Repository<T, ID> { - - T save(T entity); - - T findOne(ID primaryKey); - - Iterable<T> findAll(); - - Long count(); - - void delete(T entity); - - boolean exists(ID primaryKey); - - // … more functionality omitted. - } - - - - - Saves the given entity. - - - - Returns the entity identified by the given id. - - - - Returns all entities. - - - - Returns the number of entities. - - - - Deletes the given entity. - - - - Returns whether an entity with the given id exists. - - - - - - Usually we will have persistence technology specific - sub-interfaces - to include additional technology specific methods. We will now ship - implementations for a variety of Spring Data modules that implement - this - interface. - - - - On top of the - CrudRepository - there is - a - PagingAndSortingRepository - abstraction - that adds additional methods to ease paginated access to entities: - - - - PagingAndSortingRepository - - public interface PagingAndSortingRepository<T, ID extends Serializable> - extends CrudRepository<T, ID> { - - Iterable<T> findAll(Sort sort); - - Page<T> findAll(Pageable pageable); - } - - - - - Accessing the second page of - User - by a page - size of 20 you could simply do something like this: - - - PagingAndSortingRepository<User, Long> repository = // … get access to a - bean - Page<User> users = repository.findAll(new PageRequest(1, 20)); - -
- -
- Query methods - - Next to standard CRUD functionality repositories are usually - queries - on the underlying datastore. With Spring Data declaring those queries - becomes a four-step process: - - - - - - Declare an interface extending - Repository - or one of its sub-interfaces - and type it to the domain class it shall handle. - - - public interface PersonRepository extends Repository<User, Long> { - … } - - - - - Declare query methods on the interface. - - List<Person> findByLastname(String lastname); - - - - Setup Spring to create proxy instances for those - interfaces. - - - <?xml version="1.0" encoding="UTF-8"?> - <beans:beans xmlns:beans="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://www.springframework.org/schema/data/jpa" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/jpa - http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - <repositories base-package="com.acme.repositories" /> - - </beans> - - - - Note that we use the JPA namespace here just by example. If - you're using the repository abstraction for any other store you need - to change this to the appropriate namespace declaration of your - store module which should be exchanging - jpa - in favor of - e.g. - mongodb - . - - - - - - Get the repository instance injected and use it. - - public class SomeClient { - - @Autowired - private PersonRepository repository; - - public void doSomething() { - List<Person> persons = repository.findByLastname("Matthews"); - } - - - - - At this stage we barely scratched the surface of what's possible - with the repositories but the general approach should be clear. Let's - go - through each of these steps and figure out details and various options - that you have at each stage. - - -
- Defining repository interfaces - - - As a very first step you define a domain class specific repository - interface. It's got to extend - Repository - and be typed to the domain class and an ID type. If you want to - expose - CRUD methods for that domain type, extend - CrudRepository - instead of - Repository - . - - -
- Fine tuning repository definition - - - Usually you will have your repository interface extend - Repository - , - CrudRepository - or - PagingAndSortingRepository - . If you - don't like extending Spring Data interfaces at all you can also - annotate your repository interface with - @RepositoryDefinition - . Extending - CrudRepository - will expose a complete - set of methods to manipulate your entities. If you would rather be - selective about the methods being exposed, simply copy the ones you - want to expose from - CrudRepository - into - your domain repository. - - - - Selectively exposing CRUD methods - - interface MyBaseRepository<T, ID extends Serializable> extends - Repository<T, ID> { - T findOne(ID id); - T save(T entity); - } - - interface UserRepository extends MyBaseRepository<User, Long> { - - User findByEmailAddress(EmailAddress emailAddress); - } - - - - - In the first step we define a common base interface for all our - domain repositories and expose - findOne(…) - as - well as - save(…) - .These methods will be routed - into the base repository implementation of the store of your choice - because they are matching the method signatures in - CrudRepository - . So our - UserRepository - will now be able to save - users, find single ones by id as well as triggering a query to find - User - s by their email address. - -
-
- -
- Defining query methods - -
- Query lookup strategies - - The next thing we have to discuss is the definition of query - methods. There are two main ways that the repository proxy is able - to - come up with the store specific query from the method name. The first - option is to derive the query from the method name directly, the - second is using some kind of additionally created query. What - detailed - options are available pretty much depends on the actual store, - however, there's got to be some algorithm that decides what actual - query is created. - - - - There are three strategies available for the repository - infrastructure to resolve the query. The strategy to be used can be - configured at the namespace through the - query-lookup-strategy - attribute. However, It might be the - case that some of the strategies are not supported for specific - datastores. Here are your options: - - - - CREATE - - - This strategy will try to construct a store specific query - from the query method's name. The general approach is to remove a - given set of well-known prefixes from the method name and parse - the - rest of the method. Read more about query construction in - - . - - - - - USE_DECLARED_QUERY - - This strategy tries to find a declared query which will be - used for execution first. The query could be defined by an - annotation somewhere or declared by other means. Please consult - the - documentation of the specific store to find out what options are - available for that store. If the repository infrastructure does not - find a declared query for the method at bootstrap time it will - fail. - - - - - CREATE_IF_NOT_FOUND (default) - - - This strategy is actually a combination of - CREATE - and - USE_DECLARED_QUERY - . It will try to lookup a - declared query first but create a custom method name based query if - no declared query was found. This is the default lookup strategy and - thus will be used if you don't configure anything explicitly. It - allows quick query definition by method names but also custom - tuning - of these queries by introducing declared queries as needed. - - -
- -
- Query creation - - - The query builder mechanism built into Spring Data repository - infrastructure is useful to build constraining queries over - entities - of the repository. We will strip the prefixes - findBy - , - find - , - readBy - , - read - , - getBy - as well as - get - from the method and - start parsing the rest of it. At a very basic level you can define - conditions on entity properties and concatenate them with - AND - and - OR - . - - - - Query creation from method names - - - public interface PersonRepository extends Repository<User, - Long> { - - List<Person> findByEmailAddressAndLastname(EmailAddress emailAddress, String - lastname); - } - - - - - - The actual result of parsing that method will of course depend - on the persistence store we create the query for, however, there are - some general things to notice. The expressions are usually property - traversals combined with operators that can be concatenated. As you - can see in the example you can combine property expressions with - And - and Or. Beyond that you also get support for various operators like - Between - , - LessThan - , - GreaterThan - , - Like - for the - property expressions. As the operators supported can vary from - datastore to datastore please consult the according part of the - reference documentation. - - -
- Property expressions - - - Property expressions can just refer to a direct property of - the managed entity (as you just saw in the example above). On query - creation time we already make sure that the parsed property is at - a - property of the managed domain class. However, you can also define - constraints by traversing nested properties. Assume - Person - s have - Address - es - with - ZipCode - s. In that case a method name - of - - - List<Person> findByAddressZipCode(ZipCode zipCode); - - - - will create the property traversal - x.address.zipCode - . The resolution algorithm starts with - interpreting the entire part ( - AddressZipCode - ) as - property and checks the domain class for a property with that name - (uncapitalized). If it succeeds it just uses that. If not it - starts - splitting up the source at the camel case parts from the right side - into a head and a tail and tries to find the according property, - e.g. - AddressZip - and - Code - . If - we find a property with that head we take the tail and continue - building the tree down from there. As in our case the first split - does not match we move the split point to the left - ( - Address - , - ZipCode - ). - - - - Although this should work for most cases, there might be cases - where the algorithm could select the wrong property. Suppose our - Person - class has an - addressZip - property as well. Then our algorithm would match in the first - split - round already and essentially choose the wrong property and finally - fail (as the type of - addressZip - probably has - no code property). To resolve this ambiguity you can use - _ - inside your method name to manually define - traversal points. So our method name would end up like so: - - - List<Person> findByAddress_ZipCode(ZipCode zipCode); - -
-
- -
- Special parameter handling - - To hand parameters to your query you simply define method - parameters as already seen in the examples above. Besides that we - will - recognizes certain specific types to apply pagination and sorting to - your queries dynamically. - - - - Using Pageable and Sort in query methods - - Page<User> findByLastname(String lastname, Pageable pageable); - - List<User> findByLastname(String lastname, Sort sort); - - List<User> findByLastname(String lastname, Pageable pageable); - - - - - The first method allows you to pass a - Pageable - instance to the query method to dynamically add paging to your - statically defined query. - Sorting - options are handed via - the - Pageable - instance too. If you only - need sorting, simply add a - Sort - parameter to your method. - As you also can see, simply returning a - List - is possible as well. We will then - not retrieve the additional metadata required to build the actual - Page - instance but rather simply - restrict the query to lookup only the given range of entities. - - - - To find out how many pages you get for a query entirely we - have to trigger an additional count query. This will be derived - from - the query you actually trigger by default. - - -
-
- -
- Creating repository instances - - So now the question is how to create instances and bean - definitions for the repository interfaces defined. - - -
- XML Configuration - - The easiest way to do so is by using the Spring namespace that - is shipped with each Spring Data module that supports the - repository - mechanism. Each of those includes a repositories element that allows - you to simply define a base package that Spring will scan for - you. - - - <?xml version="1.0" encoding="UTF-8"?> - <beans:beans xmlns:beans="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://www.springframework.org/schema/data/jpa" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/jpa - http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - <repositories base-package="com.acme.repositories" /> - - </beans:beans> - - - In this case we instruct Spring to scan - com.acme.repositories - and all its sub packages for - interfaces extending - Repository - or one - of its sub-interfaces. For each interface found it will register the - persistence technology specific - FactoryBean - to create the according - proxies that handle invocations of the query methods. Each of these - beans will be registered under a bean name that is derived from the - interface name, so an interface of - UserRepository - would be registered - under - userRepository - . The - base-package - attribute allows the use of wildcards, so that you can have a - pattern - of scanned packages. - - - - Using filters - - - By default we will pick up every interface extending the - persistence technology specific - Repository - sub-interface located - underneath the configured base package and create a bean instance - for it. However, you might want finer grained control over which - interfaces bean instances get created for. To do this we support - the - use of - <include-filter /> - and - <exclude-filter /> - elements inside - <repositories /> - . The semantics are exactly - equivalent to the elements in Spring's context namespace. For - details see - Spring reference documentation - - on these - elements. - - - E.g. to exclude certain interfaces from instantiation as - repository, you could use the following configuration: - - - - Using exclude-filter element - - <repositories base-package="com.acme.repositories"> - <context:exclude-filter type="regex" expression=".*SomeRepository" /> - </repositories> - - - This would exclude all interfaces ending in - SomeRepository - from being - instantiated. - - - -
- -
- JavaConfig - - - The repository infrastructure can also be triggered using a - store-specific - @Enable${store}Repositories - annotation - on a JavaConfig class. For an introduction into Java based - configuration of the Spring container please have a look at the - reference documentation. - - - JavaConfig in the Spring reference documentation - - - - - - - A sample configuration to enable Spring Data repositories - would - look something like this. - - - - Sample annotation based repository configuration - - @Configuration - @EnableJpaRepositories("com.acme.repositories") - class ApplicationConfiguration { - - @Bean - public EntityManagerFactory entityManagerFactory() { - // … - } - } - - - - - Note that the sample uses the JPA specific annotation which - would have to be exchanged dependingon which store module you actually - use. The same applies to the definition of the - EntityManagerFactory - bean. Please - consult the sections covering the store-specific configuration. - -
- -
- Standalone usage - - - You can also use the repository infrastructure outside of a - Spring container usage. You will still need to have some of the Spring - libraries on your classpath but you can generally setup - repositories - programmatically as well. The Spring Data modules providing repository - support ship a persistence technology specific - RepositoryFactory - that can be used as - follows: - - - - Standalone usage of repository factory - - RepositoryFactorySupport factory = … // Instantiate factory here - UserRepository repository = factory.getRepository(UserRepository.class); - - -
-
-
- -
- Custom implementations - -
- Adding behaviour to single repositories - - Often it is necessary to provide a custom implementation for a - few - repository methods. Spring Data repositories easily allow you to provide - custom repository code and integrate it with generic CRUD - abstraction - and query method functionality. To enrich a repository with custom - functionality you have to define an interface and an implementation - for - that functionality first and let the repository interface you provided - so far extend that custom interface. - - - - Interface for custom repository functionality - - interface UserRepositoryCustom { - - public void someCustomMethod(User user); - } - - - - - Implementation of custom repository functionality - - - class UserRepositoryImpl implements UserRepositoryCustom { - - public void someCustomMethod(User user) { - // Your custom implementation - } - } - - Note that the implementation itself does not depend on - Spring Data and can be a regular Spring bean. So you can use standard - dependency injection behaviour to inject references to other beans, - take part in aspects and so on. - - - - - Changes to the your basic repository interface - - - public interface UserRepository extends CrudRepository<User, Long>, - UserRepositoryCustom { - - // Declare query methods here - } - - Let your standard repository interface extend the custom - one. This makes CRUD and custom functionality available to - clients. - - - - - Configuration - - - If you use namespace configuration the repository infrastructure - tries to autodetect custom implementations by looking up classes in - the package we found a repository using the naming conventions - appending the namespace element's attribute - repository-impl-postfix - to the classname. This suffix - defaults to - Impl - . - - - - Configuration example - - - <repositories base-package="com.acme.repository" /> - - <repositories base-package="com.acme.repository" repository-impl-postfix="FooBar" - /> - - - - - The first configuration example will try to lookup a class - com.acme.repository.UserRepositoryImpl - to act - as custom repository implementation, where the second example will - try - to lookup - com.acme.repository.UserRepositoryFooBar - . - - - - - Manual wiring - - The approach above works perfectly well if your custom - implementation uses annotation based configuration and autowiring - entirely as it will be treated as any other Spring bean. If your - custom implementation bean needs some special wiring you simply - declare the bean and name it after the conventions just described. - We - will then pick up the custom bean by name rather than creating an - instance. - - - - Manual wiring of custom implementations (I) - - <repositories base-package="com.acme.repository" /> - - <beans:bean id="userRepositoryImpl" class="…"> - <!-- further configuration --> - </beans:bean> - - -
- -
- Adding custom behaviour to all repositories - - In other cases you might want to add a single method to all of - your repository interfaces. So the approach just shown is not - feasible. - The first step to achieve this is adding and intermediate interface to - declare the shared behaviour - - - - An interface declaring custom shared behaviour - - - - public interface MyRepository<T, ID extends Serializable> - extends JpaRepository<T, ID> { - - void sharedCustomMethod(ID id); - } - - - - - - Now your individual repository interfaces will extend this - intermediate interface instead of the - Repository - interface to include the - functionality declared. The second step is to create an implementation - of this interface that extends the persistence technology specific - repository base class which will then act as a custom base class for - the - repository proxies. - - - - - The default behaviour of the Spring - <repositories - /> - namespace is to provide an implementation for all - interfaces that fall under the - base-package - . This means - that if left in it's current state, an implementation instance of - MyRepository - will be created by Spring. - This is of course not desired as it is just supposed to act as an - intermediary between - Repository - and the - actual repository interfaces you want to define for each entity. To - exclude an interface extending - Repository - from being instantiated as a - repository instance it can either be annotate it with - @NoRepositoryBean - or moved out side of - the configured - base-package - . - - - - - Custom repository base class - - - public class MyRepositoryImpl<T, ID extends Serializable> - extends SimpleJpaRepository<T, ID> implements MyRepository<T, ID> { - - private EntityManager entityManager; - - // There are two constructors to choose from, either can be used. - public MyRepositoryImpl(Class<T> domainClass, EntityManager entityManager) { - super(domainClass, entityManager); - - // This is the recommended method for accessing inherited class dependencies. - this.entityManager = entityManager; - } - - public void sharedCustomMethod(ID id) { - // implementation goes here - } - } - - - - - The last step is to create a custom repository factory to replace - the default - RepositoryFactoryBean - that will in - turn produce a custom - RepositoryFactory - . The new - repository factory will then provide your - MyRepositoryImpl - as the implementation of any - interfaces that extend the - Repository - interface, replacing the - SimpleJpaRepository - implementation you just extended. - - - - Custom repository factory bean - - - public class MyRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends - Serializable> - extends JpaRepositoryFactoryBean<R, T, I> { - - protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) { - - return new MyRepositoryFactory(entityManager); - } - - private static class MyRepositoryFactory<T, I extends Serializable> extends - JpaRepositoryFactory { - - private EntityManager entityManager; - - public MyRepositoryFactory(EntityManager entityManager) { - super(entityManager); - - this.entityManager = entityManager; - } - - protected Object getTargetRepository(RepositoryMetadata metadata) { - - return new MyRepositoryImpl<T, I>((Class<T>) metadata.getDomainClass(), entityManager); - } - - protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) { - - // The RepositoryMetadata can be safely ignored, it is used by the JpaRepositoryFactory - //to check for QueryDslJpaRepository's which is out of scope. - return MyRepository.class; - } - } - } - - - - - Finally you can either declare beans of the custom factory - directly or use the - factory-class - attribute of the Spring - namespace to tell the repository infrastructure to use your custom - factory implementation. - - - - Using the custom factory with the namespace - - <repositories base-package="com.acme.repository" - factory-class="com.acme.MyRepositoryFactoryBean" /> - -
-
- -
- Extensions - - This chapter documents a set of Spring Data extensions that - enable - Spring Data usage in a variety of contexts. Currently most of the - integration is targeted towards Spring MVC. - - -
- Domain class web binding for Spring MVC - - Given you are developing a Spring MVC web applications you - typically have to resolve domain class ids from URLs. By default - it's - your task to transform that request parameter or URL part into the - domain class to hand it layers below then or execute business logic - on - the entities directly. This should look something like this: - - - @Controller - @RequestMapping("/users") - public class UserController { - - private final UserRepository userRepository; - - public UserController(UserRepository userRepository) { - userRepository = userRepository; - } - - @RequestMapping("/{id}") - public String showUserForm(@PathVariable("id") Long id, Model model) { - - // Do null check for id - User user = userRepository.findOne(id); - // Do null check for user - // Populate model - return "user"; - } - } - - - - First you pretty much have to declare a repository dependency for - each controller to lookup the entity managed by the controller or - repository respectively. Beyond that looking up the entity is - boilerplate as well as it's always a - findOne(…) - call. Fortunately Spring provides means to register custom - converting - components that allow conversion between a - String - value to an arbitrary type. - - - - PropertyEditors - - - For versions up to Spring 3.0 simple Java - PropertyEditor - s had to be used. Thus, - we offer a - DomainClassPropertyEditorRegistrar - , - that will look up all Spring Data repositories registered in the - ApplicationContext - and register a - custom - PropertyEditor - for the managed - domain class - - - <bean - class="….web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> - <property name="webBindingInitializer"> - <bean class="….web.bind.support.ConfigurableWebBindingInitializer"> - <property name="propertyEditorRegistrars"> - <bean class="org.springframework.data.repository.support.DomainClassPropertyEditorRegistrar" /> - </property> - </bean> - </property> - </bean> - - If you have configured Spring MVC like this you can turn your - controller into the following that reduces a lot of the clutter and - boilerplate. - - - @Controller - @RequestMapping("/users") - public class UserController { - - @RequestMapping("/{id}") - public String showUserForm(@PathVariable("id") User user, Model model) { - - // Do null check for user - // Populate model - return "userForm"; - } - } - - - - - ConversionService - - - As of Spring 3.0 the - PropertyEditor - support is superseeded - by a new conversion infrstructure that leaves all the drawbacks of - PropertyEditor - s behind and uses a - stateless X to Y conversion approach. We now ship with a - DomainClassConverter - that pretty much mimics - the behaviour of - DomainClassPropertyEditorRegistrar - . To register - the converter you have to declare - ConversionServiceFactoryBean - , register the - converter and tell the Spring MVC namespace to use the configured - conversion service: - - - <mvc:annotation-driven conversion-service="conversionService" /> - - <bean id="conversionService" class="….context.support.ConversionServiceFactoryBean"> - <property name="converters"> - <list> - <bean class="org.springframework.data.repository.support.DomainClassConverter"> - <constructor-arg ref="conversionService" /> - </bean> - </list> - </property> - </bean> - -
- -
- Web pagination - - @Controller - @RequestMapping("/users") - public class UserController { - - // DI code omitted - - @RequestMapping - public String showUsers(Model model, HttpServletRequest request) { - - int page = Integer.parseInt(request.getParameter("page")); - int pageSize = Integer.parseInt(request.getParameter("pageSize")); - model.addAttribute("users", userService.getUsers(pageable)); - return "users"; - } - } - - - - As you can see the naive approach requires the method to contain - an - HttpServletRequest - parameter that has - to be parsed manually. We even omitted an appropriate failure handling - which would make the code even more verbose. The bottom line is that - the - controller actually shouldn't have to handle the functionality of - extracting pagination information from the request. So we include a - PageableArgumentResolver - that will do the work - for you. - - - <bean class="….web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> - <property name="customArgumentResolvers"> - <list> - <bean class="org.springframework.data.web.PageableArgumentResolver" /> - </list> - </property> - </bean> - - This configuration allows you to simplify controllers down to - something like this: - - - @Controller - @RequestMapping("/users") - public class UserController { - - @RequestMapping - public String showUsers(Model model, Pageable pageable) { - - model.addAttribute("users", userDao.readAll(pageable)); - return "users"; - } - } - - - - The - PageableArgumentResolver - will - automatically resolve request parameters to build a - PageRequest - instance. By default it will expect - the following structure for the request parameters: - - - - - Request parameters evaluated by - <classname>PageableArgumentResolver</classname> - - - - - - - - - - - page - - - The page you want to retrieve - - - - - page.size - - - The size of the page you want to retrieve - - - - - page.sort - - - The property that should be sorted by - - - - - page.sort.dir - - - The direction that should be used for sorting - - - -
- - - In case you need multiple - Pageable - s - to be resolved from the request (for multiple tables e.g.) you can use - Spring's - @Qualifier - annotation to - distinguish one from another. The request parameters then have to be - prefixed with - ${qualifier}_ - . So a method signature like - this: - - - public String showUsers(Model model, - @Qualifier("foo") Pageable first, - @Qualifier("bar") Pageable second) { … } - - - - you'd have to populate - foo_page - and - bar_page - and the according subproperties. - - - - Defaulting - - - The - PageableArgumentResolver - will use a - PageRequest - with the first page and a page size - of 10 by default and will use that in case it can't resolve a - PageRequest - from the request (because of - missing parameters e.g.). You can configure a global default on the - bean declaration directly. In case you might need controller method - specific defaults for the - Pageable - simply annotate the method parameter with - @PageableDefaults - and specify page and - page size as annotation attributes: - - - public String showUsers(Model model, - @PageableDefaults(pageNumber = 0, value = 30) Pageable pageable) { … } - - -
- -
- Repository populators - - If you have been working with the JDBC module of Spring you're - probably familiar with the support to populate a DataSource using - SQL - scripts. A similar abstraction is available on the repositories level - although we don't use SQL as data definition language as we need to - be - store independent of course. Thus the populators support XML (through - Spring's OXM abstraction) and JSON (through Jackson) to define data - for - the repositories to be populated with. - - - - Assume you have a file - data.json - with the - following content: - - - - Data defined in JSON - - [ { "_class" : "com.acme.Person", - "firstname" : "Dave", - "lastname" : "Matthews" }, - { "_class" : "com.acme.Person", - "firstname" : "Carter", - "lastname" : "Beauford" } ] - - - - - You can easily populate you repositories by using the populator - elements of the repository namespace provided in Spring Data - Commons. To - get the just shown data be populated to your - PersonRepository - all you need to do is - the following: - - - - Declaring a Jackson repository populator - - <?xml version="1.0" encoding="UTF-8"?> - <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:repository="http://www.springframework.org/schema/data/repository" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/repository - http://www.springframework.org/schema/data/repository/spring-repository.xsd"> - - <repository:jackson-populator location="classpath:data.json" /> - - </beans> - - - - This declaration causes the data.json file being read, - deserialized by a Jackson - ObjectMapper - . The type - the JSON object will be unmarshalled to will be determined by - inspecting - the - _class - attribute of the JSON document. We will - eventually select the appropriate repository being able to handle the - object just deserialized. - - - To rather use XML to define the repositories shall be populated - with you can use the unmarshaller-populator you hand one of the - marshaller options Spring OXM provides you with. - - - - Declaring an unmarshalling repository populator (using - JAXB) - - - <?xml version="1.0" encoding="UTF-8"?> - <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:repository="http://www.springframework.org/schema/data/repository" - xmlns:oxm="http://www.springframework.org/schema/oxm" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/repository - http://www.springframework.org/schema/data/repository/spring-repository.xsd - http://www.springframework.org/schema/oxm - http://www.springframework.org/schema/oxm/spring-oxm.xsd"> - - <repository:unmarshaller-populator location="classpath:data.json" unmarshaller-ref="unmarshaller" - /> - - <oxm:jaxb2-marshaller contextPath="com.acme" /> - - </beans> - -
-
-
\ No newline at end of file diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc new file mode 100644 index 000000000..df72c81f1 --- /dev/null +++ b/src/main/asciidoc/index.adoc @@ -0,0 +1,28 @@ += Spring Data Elasticsearch +BioMed Central Development Team +:toc: +:spring-data-commons-docs: https://raw.githubusercontent.com/spring-projects/spring-data-commons/issue/DATACMNS-551/src/main/asciidoc + +{version} + +(C) 2013-2014 The original author(s) + +NOTE: _Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically._ + +include::preface.adoc[] + +[[reference]] += Reference Documentation + +:leveloffset: 1 +include::{spring-data-commons-docs}/repositories.adoc[] +include::reference/data-elasticsearch.adoc[] +include::reference/elasticsearch-misc.adoc[] + +:leveloffset: 0 +:numbered!: +[[appendix]] += Appendix + +include::{spring-data-commons-docs}/repository-namespace-reference.adoc[] +include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[] diff --git a/src/main/asciidoc/preface.adoc b/src/main/asciidoc/preface.adoc new file mode 100644 index 000000000..c6f958104 --- /dev/null +++ b/src/main/asciidoc/preface.adoc @@ -0,0 +1,15 @@ +[preface] += Preface + +The Spring Data Elasticsearch project applies core Spring concepts to the development of solutions using the Elasticsearch Search Engine. We have povided a "template" as a high-level abstraction for storing,querying,sorting and faceting documents. You will notice similarities to the Spring data solr and mongodb support in the Spring Framework. + +[[project]] +== Project Metadata + +* Version Control - `git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git` + +[[requirements]] +== Requirements + +Requires http://www.elasticsearch.org/download/[Elasticsearch] 0.20.2 and above or optional dependency or not even that if you are using Embedded Node Client + diff --git a/src/main/asciidoc/reference/data-elasticsearch.adoc b/src/main/asciidoc/reference/data-elasticsearch.adoc new file mode 100644 index 000000000..c14d9b929 --- /dev/null +++ b/src/main/asciidoc/reference/data-elasticsearch.adoc @@ -0,0 +1,288 @@ +[[elasticsearch.repositories]] += Elasticsearch Repositories + +This chapter includes details of the Elasticsearch repository implementation. + +[[elasticsearch.introduction]] +== Introduction + +[[elasticsearch.namespace]] +=== Spring Namespace + +The Spring Data Elasticsearch module contains a custom namespace allowing definition of repository beans as well as elements for instantiating a `ElasticsearchServer` . + +Using the `repositories` element looks up Spring Data repositories as described in <> . + +.Setting up Elasticsearch repositories using Namespace +==== +[source,xml] +---- + + + + + + +---- +==== + +Using the `Transport Client` or `Node Client` element registers an instance of `Elasticsearch Server` in the context. + +.Transport Client using Namespace +==== +[source,xml] +---- + + + + + + +---- +==== + +.Node Client using Namespace +==== +[source,xml] +---- + + + + + + +---- +==== + +[[elasticsearch.annotation]] +=== Annotation based configuration + +The Spring Data Elasticsearch repositories support cannot only be activated through an XML namespace but also using an annotation through JavaConfig. + +.Spring Data Elasticsearch repositories using JavaConfig +==== +[source,java] +---- +@Configuration +@EnableElasticsearchRepositories(basePackages = "org/springframework/data/elasticsearch/repositories") +static class Config { + + @Bean + public ElasticsearchOperations elasticsearchTemplate() { + return new ElasticsearchTemplate(nodeBuilder().local(true).node().client()); + } +} +---- +==== + +The configuration above sets up an `Embedded Elasticsearch Server` which is used by the `ElasticsearchTemplate` . Spring Data Elasticsearch Repositories are activated using the `@EnableElasticsearchRepositories` annotation, which essentially carries the same attributes as the XML namespace does. If no base package is configured, it will use the one the configuration class resides in. + +[[elasticsearch.cdi]] +=== Elasticsearch Repositores using CDI + +The Spring Data Elasticsearch repositories can also be set up using CDI functionality. + +.Spring Data Elasticsearch repositories using JavaConfig +==== +[source,java] +---- +class ElasticsearchTemplateProducer { + + @Produces + @ApplicationScoped + public ElasticsearchOperations createElasticsearchTemplate() { + return new ElasticsearchTemplate(nodeBuilder().local(true).node().client()); + } +} + +class ProductService { + + private ProductRepository repository; + + public Page findAvailableBookByName(String name, Pageable pageable) { + return repository.findByAvailableTrueAndNameStartingWith(name, pageable); + } + + @Inject + public void setRepository(ProductRepository repository) { + this.repository = repository; + } +} +---- +==== + +[[elasticsearch.query-methods]] +== Query methods + +[[elasticsearch.query-methods.finders]] +=== Query lookup strategies + +The Elasticsearch module supports all basic query building feature as String,Abstract,Criteria or have it being derived from the method name. + +==== Declared queries + +Deriving the query from the method name is not always sufficient and/or may result in unreadable method names. In this case one might make either use of `@Query` annotation (see <> ). + +[[elasticsearch.query-methods.criterions]] +=== Query creation + +Generally the query creation mechanism for Elasticsearch works as described in <> . Here's a short example of what a Elasticsearch query method translates into: + +.Query creation from method names +==== +[source,java] +---- +public interface BookRepository extends Repository +{ + List findByNameAndPrice(String name, Integer price); +} +---- +==== + +The method name above will be translated into the following Elasticsearch json query + +[source] +---- +{ "bool" : + { "must" : + [ + { "field" : {"name" : "?"} }, + { "field" : {"price" : "?"} } + ] + } +} +---- + +A list of supported keywords for Elasticsearch is shown below. + +[cols="1,2,3", options="header"] +.Supported keywords inside method names +|=== +| Keyword +| Sample +| Elasticsearch Query String| `And` +| `findByNameAndPrice` +| `{"bool" : {"must" : [ {"field" : {"name" : "?"}}, + {"field" : {"price" : "?"}} ]}}` + +| `Or` +| `findByNameOrPrice` +| `{"bool" : {"should" : [ {"field" : {"name" : "?"}}, + {"field" : {"price" : "?"}} ]}}` + +| `Is` +| `findByName` +| `{"bool" : {"must" : {"field" : {"name" : "?"}}}}` + +| `Not` +| `findByNameNot` +| `{"bool" : {"must_not" : {"field" : {"name" : "?"}}}}` + +| `Between` +| `findByPriceBetween` +| `{"bool" : {"must" : {"range" : {"price" : {"from" : + ?,"to" : ?,"include_lower" : true,"include_upper" : true}}}}}` + +| `LessThanEqual` +| `findByPriceLessThan` +| `{"bool" : {"must" : {"range" : {"price" : {"from" : + null,"to" : ?,"include_lower" : true,"include_upper" : + true}}}}}` + +| `GreaterThanEqual` +| `findByPriceGreaterThan` +| `{"bool" : {"must" : {"range" : {"price" : {"from" : + ?,"to" : null,"include_lower" : true,"include_upper" : + true}}}}}` + +| `Before` +| `findByPriceBefore` +| `{"bool" : {"must" : {"range" : {"price" : {"from" : + null,"to" : ?,"include_lower" : true,"include_upper" : + true}}}}}` + +| `After` +| `findByPriceAfter` +| `{"bool" : {"must" : {"range" : {"price" : {"from" : + ?,"to" : null,"include_lower" : true,"include_upper" : + true}}}}}` + +| `Like` +| `findByNameLike` +| `{"bool" : {"must" : {"field" : {"name" : {"query" : + "?*","analyze_wildcard" : true}}}}}` + +| `StartingWith` +| `findByNameStartingWith` +| `{"bool" : {"must" : {"field" : {"name" : {"query" : + "?*","analyze_wildcard" : true}}}}}` + +| `EndingWith` +| `findByNameEndingWith` +| `{"bool" : {"must" : {"field" : {"name" : {"query" : + "*?","analyze_wildcard" : true}}}}}` + +| `Contains/Containing` +| `findByNameContaining` +| `{"bool" : {"must" : {"field" : {"name" : {"query" : + "*?*","analyze_wildcard" : true}}}}}` + +| `In` +| `findByNameIn(Collectionnames)` +| `{"bool" : {"must" : {"bool" : {"should" : [ {"field" : + {"name" : "?"}}, {"field" : {"name" : "?"}} ]}}}}` + +| `NotIn` +| `findByNameNotIn(Collectionnames)` +| `{"bool" : {"must_not" : {"bool" : {"should" : {"field" : + {"name" : "?"}}}}}}` + +| `Near` +| `findByStoreNear` +| `Not Supported Yet !` + +| `True` +| `findByAvailableTrue` +| `{"bool" : {"must" : {"field" : {"available" : true}}}}` + +| `False` +| `findByAvailableFalse` +| `{"bool" : {"must" : {"field" : {"available" : false}}}}` + +| `OrderBy` +| `findByAvailableTrueOrderByNameDesc` +| `{"sort" : [{ "name" : {"order" : "desc"} }],"bool" : + {"must" : {"field" : {"available" : true}}}}` +|=== + +[[elasticsearch.query-methods.at-query]] +=== Using @Query Annotation + +.Declare query at the method using the `@Query` annotation. +==== +[source,java] +---- +public interface BookRepository extends ElasticsearchRepository { + @Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}") + Page findByName(String name,Pageable pageable); +} +---- +==== diff --git a/src/main/asciidoc/reference/elasticsearch-misc.adoc b/src/main/asciidoc/reference/elasticsearch-misc.adoc new file mode 100644 index 000000000..49d4c8c26 --- /dev/null +++ b/src/main/asciidoc/reference/elasticsearch-misc.adoc @@ -0,0 +1,72 @@ +[[elasticsearch.misc]] += Miscellaneous Elasticsearch Operation Support + +This chapter covers additional support for Elasticsearch operations that cannot be directly accessed via the repository interface. It is recommended to add those operations as custom implementation as described in <> . + +[[elasticsearch.misc.filter]] +== Filter Builder + +Filter Builder improves query speed. + +==== +[source,java] +---- +private ElasticsearchTemplate elasticsearchTemplate; + +SearchQuery searchQuery = new NativeSearchQueryBuilder() + .withQuery(matchAllQuery()) + .withFilter(boolFilter().must(termFilter("id", documentId))) + .build(); + +Page sampleEntities = + elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class); +---- +==== + +[[elasticsearch.scan.and.scroll]] +== Using Scan And Scroll For Big Result Set + +Elasticsearch has scan and scroll feature for getting big result set in chunks. `ElasticsearchTemplate` has scan and scroll methods that can be used as below. + +.Using Scan and Scroll +==== +[source,java] +---- +SearchQuery searchQuery = new NativeSearchQueryBuilder() + .withQuery(matchAllQuery()) + .withIndices("test-index") + .withTypes("test-type") + .withPageable(new PageRequest(0,1)) + .build(); +String scrollId = elasticsearchTemplate.scan(searchQuery,1000,false); +List sampleEntities = new ArrayList(); +boolean hasRecords = true; +while (hasRecords){ + Page page = elasticsearchTemplate.scroll(scrollId, 5000L , new ResultsMapper() + { + @Override + public Page mapResults(SearchResponse response) { + List chunk = new ArrayList(); + for(SearchHit searchHit : response.getHits()){ + if(response.getHits().getHits().length <= 0) { + return null; + } + SampleEntity user = new SampleEntity(); + user.setId(searchHit.getId()); + user.setMessage((String)searchHit.getSource().get("message")); + chunk.add(user); + } + return new PageImpl(chunk); + } + }); + if(page != null) { + sampleEntities.addAll(page.getContent()); + hasRecords = page.hasNextPage(); + } + else{ + hasRecords = false; + } + } +} +---- +==== diff --git a/src/main/resources/asciidoc/spring.css b/src/main/resources/asciidoc/spring.css new file mode 100644 index 000000000..149836248 --- /dev/null +++ b/src/main/resources/asciidoc/spring.css @@ -0,0 +1,356 @@ +/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */ +article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; } +audio, canvas, video { display: inline-block; } +audio:not([controls]) { display: none; height: 0; } +[hidden] { display: none; } +html { background: #fff; color: #000; font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; } +body { margin: 0; } +a:focus { outline: thin dotted; } +a:active, a:hover { outline: 0; } +h1 { font-size: 2em; margin: 0.67em 0; } +abbr[title] { border-bottom: 1px dotted; } +b, strong { font-weight: bold; } +dfn { font-style: italic; } +hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; } +mark { background: #ff0; color: #000; } +code, kbd, pre, samp { font-family: monospace, serif; font-size: 1em; } +pre { white-space: pre-wrap; } +q { quotes: "\201C" "\201D" "\2018" "\2019"; } +small { font-size: 80%; } +sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } +sup { top: -0.5em; } +sub { bottom: -0.25em; } +img { border: 0; } +svg:not(:root) { overflow: hidden; } +figure { margin: 0; } +fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } +legend { border: 0; padding: 0; } +button, input, select, textarea { font-family: inherit; font-size: 100%; margin: 0; } +button, input { line-height: normal; } +button, select { text-transform: none; } +button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; } +button[disabled], html input[disabled] { cursor: default; } +input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; } +input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } +input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } +button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } +textarea { overflow: auto; vertical-align: top; } +table { border-collapse: collapse; border-spacing: 0; } +*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } +html, body { font-size: 100%; } +body { background: white; color: #222222; padding: 0; margin: 0; font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; font-weight: normal; font-style: normal; line-height: 1; position: relative; cursor: auto; } +a:hover { cursor: pointer; } +a:focus { outline: none; } +img, object, embed { max-width: 100%; height: auto; } +object, embed { height: 100%; } +img { -ms-interpolation-mode: bicubic; } +#map_canvas img, #map_canvas embed, #map_canvas object, .map_canvas img, .map_canvas embed, .map_canvas object { max-width: none !important; } +.left { float: left !important; } +.right { float: right !important; } +.text-left { text-align: left !important; } +.text-right { text-align: right !important; } +.text-center { text-align: center !important; } +.text-justify { text-align: justify !important; } +.hide { display: none; } +.antialiased, body { -webkit-font-smoothing: antialiased; } +img { display: inline-block; vertical-align: middle; } +textarea { height: auto; min-height: 50px; } +select { width: 100%; } +p.lead, .paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { font-size: 1.21875em; line-height: 1.6; } +.subheader, #content #toctitle, .admonitionblock td.content > .title, .exampleblock > .title, .imageblock > .title, .videoblock > .title, .listingblock > .title, .literalblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, .sidebarblock > .title, .tableblock > .title, .verseblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title, .tableblock > caption { line-height: 1.4; color: #7a2518; font-weight: 300; margin-top: 0.2em; margin-bottom: 0.5em; } +div, dl, dt, dd, ul, ol, li, h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6, pre, form, p, blockquote, th, td { margin: 0; padding: 0; direction: ltr; } +a { color: #060; text-decoration: underline; line-height: inherit; } +a:hover, a:focus { color: #040; } +a img { border: none; } +p { font-family: inherit; font-weight: normal; font-size: 1em; line-height: 1.6; margin-bottom: 1.25em; text-rendering: optimizeLegibility; } +p aside { font-size: 0.875em; line-height: 1.35; font-style: italic; } +h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { font-family: Georgia, "URW Bookman L", Helvetica, Arial, sans-serif; font-weight: normal; font-style: normal; color: #ba3925; text-rendering: optimizeLegibility; margin-top: 1em; margin-bottom: 0.5em; line-height: 1.2125em; } +h1 small, h2 small, h3 small, #toctitle small, .sidebarblock > .content > .title small, h4 small, h5 small, h6 small { font-size: 60%; color: #e99b8f; line-height: 0; } +h1 { font-size: 2.125em; } +h2 { font-size: 1.6875em; } +h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.375em; } +h4 { font-size: 1.125em; } +h5 { font-size: 1.125em; } +h6 { font-size: 1em; } +hr { border: solid #dddddd; border-width: 1px 0 0; clear: both; margin: 1.25em 0 1.1875em; height: 0; } +em, i { font-style: italic; line-height: inherit; } +strong, b { font-weight: bold; line-height: inherit; } +small { font-size: 60%; line-height: inherit; } +code { font-family: Consolas, "Liberation Mono", Courier, monospace; font-weight: normal; color: #060; } +ul, ol, dl { font-size: 1em; line-height: 1.6; margin-bottom: 1.25em; list-style-position: outside; font-family: inherit; } +ul, ol { margin-left: 1.5em; } +ul li ul, ul li ol { margin-left: 1.25em; margin-bottom: 0; font-size: 1em; } +ul.square li ul, ul.circle li ul, ul.disc li ul { list-style: inherit; } +ul.square { list-style-type: square; } +ul.circle { list-style-type: circle; } +ul.disc { list-style-type: disc; } +ul.no-bullet { list-style: none; } +ol li ul, ol li ol { margin-left: 1.25em; margin-bottom: 0; } +dl dt { margin-bottom: 0.3125em; font-weight: bold; } +dl dd { margin-bottom: 1.25em; } +abbr, acronym { text-transform: uppercase; font-size: 90%; color: #222222; border-bottom: 1px dotted #dddddd; cursor: help; } +abbr { text-transform: none; } +blockquote { margin: 0 0 1.25em; padding: 0.5625em 1.25em 0 1.1875em; border-left: 1px solid #dddddd; } +blockquote cite { display: block; font-size: inherit; color: #555555; } +blockquote cite:before { content: "\2014 \0020"; } +blockquote cite a, blockquote cite a:visited { color: #555555; } +blockquote, blockquote p { line-height: 1.6; color: #6f6f6f; } +.vcard { display: inline-block; margin: 0 0 1.25em 0; border: 1px solid #dddddd; padding: 0.625em 0.75em; } +.vcard li { margin: 0; display: block; } +.vcard .fn { font-weight: bold; font-size: 0.9375em; } +.vevent .summary { font-weight: bold; } +.vevent abbr { cursor: auto; text-decoration: none; font-weight: bold; border: none; padding: 0 0.0625em; } +@media only screen and (min-width: 768px) { h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { line-height: 1.4; } + h1 { font-size: 2.75em; } + h2 { font-size: 2.3125em; } + h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.6875em; } + h4 { font-size: 1.4375em; } } +.print-only { display: none !important; } +@media print { * { background: transparent !important; color: #000 !important; box-shadow: none !important; text-shadow: none !important; } + a, a:visited { text-decoration: underline; } + a[href]:after { content: " (" attr(href) ")"; } + abbr[title]:after { content: " (" attr(title) ")"; } + .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } + pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } + thead { display: table-header-group; } + tr, img { page-break-inside: avoid; } + img { max-width: 100% !important; } + @page { margin: 0.5cm; } + p, h2, h3, #toctitle, .sidebarblock > .content > .title { orphans: 3; widows: 3; } + h2, h3, #toctitle, .sidebarblock > .content > .title { page-break-after: avoid; } + .hide-on-print { display: none !important; } + .print-only { display: block !important; } + .hide-for-print { display: none !important; } + .show-for-print { display: inherit !important; } } +table { background: white; margin-bottom: 1.25em; border: solid 1px #dddddd; } +table thead, table tfoot { background: whitesmoke; font-weight: bold; } +table thead tr th, table thead tr td, table tfoot tr th, table tfoot tr td { padding: 0.5em 0.625em 0.625em; font-size: inherit; color: #222222; text-align: left; } +table tr th, table tr td { padding: 0.5625em 0.625em; font-size: inherit; color: #222222; } +table tr.even, table tr.alt, table tr:nth-of-type(even) { background: #f9f9f9; } +table thead tr th, table tfoot tr th, table tbody tr td, table tr td, table tfoot tr td { display: table-cell; line-height: 1.6; } +.clearfix:before, .clearfix:after, .float-group:before, .float-group:after { content: " "; display: table; } +.clearfix:after, .float-group:after { clear: both; } +*:not(pre) > code { font-size: 0.9375em; padding: 1px 3px 0; white-space: nowrap; background-color: #f2f2f2; border: 1px solid #cccccc; -webkit-border-radius: 4px; border-radius: 4px; text-shadow: none; } +pre, pre > code { line-height: 1.4; color: inherit; font-family: Consolas, "Liberation Mono", Courier, monospace; font-weight: normal; } +kbd.keyseq { color: #555555; } +kbd:not(.keyseq) { display: inline-block; color: #222222; font-size: 0.75em; line-height: 1.4; background-color: #F7F7F7; border: 1px solid #ccc; -webkit-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px white inset; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px white inset; margin: -0.15em 0.15em 0 0.15em; padding: 0.2em 0.6em 0.2em 0.5em; vertical-align: middle; white-space: nowrap; } +kbd kbd:first-child { margin-left: 0; } +kbd kbd:last-child { margin-right: 0; } +.menuseq, .menu { color: #090909; } +p a > code:hover { color: #561309; } +#header, #content, #footnotes, #footer { width: 100%; margin-left: auto; margin-right: auto; margin-top: 0; margin-bottom: 0; max-width: 62.5em; *zoom: 1; position: relative; padding-left: 0.9375em; padding-right: 0.9375em; } +#header:before, #header:after, #content:before, #content:after, #footnotes:before, #footnotes:after, #footer:before, #footer:after { content: " "; display: table; } +#header:after, #content:after, #footnotes:after, #footer:after { clear: both; } +#header { margin-bottom: 2.5em; } +#header > h1 { color: black; font-weight: normal; border-bottom: 1px solid #dddddd; margin-bottom: -28px; padding-bottom: 32px; } +#header span { color: #6f6f6f; } +#header #revnumber { text-transform: capitalize; } +#header br { display: none; } +#header br + span { padding-left: 3px; } +#header br + span:before { content: "\2013 \0020"; } +#header br + span.author { padding-left: 0; } +#header br + span.author:before { content: ", "; } +#toc { border-bottom: 3px double #ebebeb; padding-bottom: 1.25em; } +#toc > ul { margin-left: 0.25em; } +#toc ul.sectlevel0 > li > a { font-style: italic; } +#toc ul.sectlevel0 ul.sectlevel1 { margin-left: 0; margin-top: 0.5em; margin-bottom: 0.5em; } +#toc ul { list-style-type: none; } +#toctitle { color: #7a2518; } +@media only screen and (min-width: 1280px) { body.toc2 { padding-left: 20em; } + #toc.toc2 { position: fixed; width: 20em; left: 0; top: 0; border-right: 1px solid #ebebeb; border-bottom: 0; z-index: 1000; padding: 1em; height: 100%; overflow: auto; } + #toc.toc2 #toctitle { margin-top: 0; } + #toc.toc2 > ul { font-size: .95em; } + #toc.toc2 ul ul { margin-left: 0; padding-left: 1.25em; } + #toc.toc2 ul.sectlevel0 ul.sectlevel1 { padding-left: 0; margin-top: 0.5em; margin-bottom: 0.5em; } + body.toc2.toc-right { padding-left: 0; padding-right: 20em; } + body.toc2.toc-right #toc.toc2 { border-right: 0; border-left: 1px solid #ebebeb; left: auto; right: 0; } } +#content #toc { border-style: solid; border-width: 1px; border-color: #d9d9d9; margin-bottom: 1.25em; padding: 1.25em; background: #f2f2f2; border-width: 0; -webkit-border-radius: 4px; border-radius: 4px; } +#content #toc > :first-child { margin-top: 0; } +#content #toc > :last-child { margin-bottom: 0; } +#content #toc a { text-decoration: none; } +#content #toctitle { font-weight: bold; font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; font-size: 1em; padding-left: 0.125em; } +#footer { max-width: 100%; background-color: #222222; padding: 1.25em; } +#footer-text { color: #dddddd; line-height: 1.44; } +.sect1 { padding-bottom: 1.25em; } +.sect1 + .sect1 { border-top: 3px double #ebebeb; } +#content h1 > a.anchor, h2 > a.anchor, h3 > a.anchor, #toctitle > a.anchor, .sidebarblock > .content > .title > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor { position: absolute; width: 1em; margin-left: -1em; display: block; text-decoration: none; visibility: hidden; text-align: center; font-weight: normal; } +#content h1 > a.anchor:before, h2 > a.anchor:before, h3 > a.anchor:before, #toctitle > a.anchor:before, .sidebarblock > .content > .title > a.anchor:before, h4 > a.anchor:before, h5 > a.anchor:before, h6 > a.anchor:before { content: '\00A7'; font-size: .85em; vertical-align: text-top; display: block; margin-top: 0.05em; } +#content h1:hover > a.anchor, #content h1 > a.anchor:hover, h2:hover > a.anchor, h2 > a.anchor:hover, h3:hover > a.anchor, #toctitle:hover > a.anchor, .sidebarblock > .content > .title:hover > a.anchor, h3 > a.anchor:hover, #toctitle > a.anchor:hover, .sidebarblock > .content > .title > a.anchor:hover, h4:hover > a.anchor, h4 > a.anchor:hover, h5:hover > a.anchor, h5 > a.anchor:hover, h6:hover > a.anchor, h6 > a.anchor:hover { visibility: visible; } +#content h1 > a.link, h2 > a.link, h3 > a.link, #toctitle > a.link, .sidebarblock > .content > .title > a.link, h4 > a.link, h5 > a.link, h6 > a.link { color: #ba3925; text-decoration: none; } +#content h1 > a.link:hover, h2 > a.link:hover, h3 > a.link:hover, #toctitle > a.link:hover, .sidebarblock > .content > .title > a.link:hover, h4 > a.link:hover, h5 > a.link:hover, h6 > a.link:hover { color: #a53221; } +.imageblock, .literalblock, .listingblock, .verseblock, .videoblock { margin-bottom: 1.25em; } +.admonitionblock td.content > .title, .exampleblock > .title, .imageblock > .title, .videoblock > .title, .listingblock > .title, .literalblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, .sidebarblock > .title, .tableblock > .title, .verseblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { text-align: left; font-weight: bold; } +.tableblock > caption { text-align: left; font-weight: bold; white-space: nowrap; overflow: visible; max-width: 0; } +table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { font-size: inherit; } +.admonitionblock > table { border: 0; background: none; width: 100%; } +.admonitionblock > table td.icon { text-align: center; width: 80px; } +.admonitionblock > table td.icon img { max-width: none; } +.admonitionblock > table td.icon .title { font-weight: bold; text-transform: uppercase; } +.admonitionblock > table td.content { padding-left: 1.125em; padding-right: 1.25em; border-left: 1px solid #dddddd; color: #6f6f6f; } +.admonitionblock > table td.content > :last-child > :last-child { margin-bottom: 0; } +.exampleblock > .content { border-style: solid; border-width: 1px; border-color: #e6e6e6; margin-bottom: 1.25em; padding: 1.25em; background: white; -webkit-border-radius: 4px; border-radius: 4px; } +.exampleblock > .content > :first-child { margin-top: 0; } +.exampleblock > .content > :last-child { margin-bottom: 0; } +.exampleblock > .content h1, .exampleblock > .content h2, .exampleblock > .content h3, .exampleblock > .content #toctitle, .sidebarblock.exampleblock > .content > .title, .exampleblock > .content h4, .exampleblock > .content h5, .exampleblock > .content h6, .exampleblock > .content p { color: #333333; } +.exampleblock > .content h1, .exampleblock > .content h2, .exampleblock > .content h3, .exampleblock > .content #toctitle, .sidebarblock.exampleblock > .content > .title, .exampleblock > .content h4, .exampleblock > .content h5, .exampleblock > .content h6 { line-height: 1; margin-bottom: 0.625em; } +.exampleblock > .content h1.subheader, .exampleblock > .content h2.subheader, .exampleblock > .content h3.subheader, .exampleblock > .content .subheader#toctitle, .sidebarblock.exampleblock > .content > .subheader.title, .exampleblock > .content h4.subheader, .exampleblock > .content h5.subheader, .exampleblock > .content h6.subheader { line-height: 1.4; } +.exampleblock.result > .content { -webkit-box-shadow: 0 1px 8px #d9d9d9; box-shadow: 0 1px 8px #d9d9d9; } +.sidebarblock { border-style: solid; border-width: 1px; border-color: #d9d9d9; margin-bottom: 1.25em; padding: 1.25em; background: #f2f2f2; -webkit-border-radius: 4px; border-radius: 4px; } +.sidebarblock > :first-child { margin-top: 0; } +.sidebarblock > :last-child { margin-bottom: 0; } +.sidebarblock h1, .sidebarblock h2, .sidebarblock h3, .sidebarblock #toctitle, .sidebarblock > .content > .title, .sidebarblock h4, .sidebarblock h5, .sidebarblock h6, .sidebarblock p { color: #333333; } +.sidebarblock h1, .sidebarblock h2, .sidebarblock h3, .sidebarblock #toctitle, .sidebarblock > .content > .title, .sidebarblock h4, .sidebarblock h5, .sidebarblock h6 { line-height: 1; margin-bottom: 0.625em; } +.sidebarblock h1.subheader, .sidebarblock h2.subheader, .sidebarblock h3.subheader, .sidebarblock .subheader#toctitle, .sidebarblock > .content > .subheader.title, .sidebarblock h4.subheader, .sidebarblock h5.subheader, .sidebarblock h6.subheader { line-height: 1.4; } +.sidebarblock > .content > .title { color: #7a2518; margin-top: 0; line-height: 1.6; } +.exampleblock > .content > :last-child > :last-child, .exampleblock > .content .olist > ol > li:last-child > :last-child, .exampleblock > .content .ulist > ul > li:last-child > :last-child, .exampleblock > .content .qlist > ol > li:last-child > :last-child, .sidebarblock > .content > :last-child > :last-child, .sidebarblock > .content .olist > ol > li:last-child > :last-child, .sidebarblock > .content .ulist > ul > li:last-child > :last-child, .sidebarblock > .content .qlist > ol > li:last-child > :last-child { margin-bottom: 0; } +.literalblock > .content pre, .listingblock > .content pre { background: none; border-width: 1px 0; border-style: dotted; border-color: #bfbfbf; -webkit-border-radius: 4px; border-radius: 4px; padding: 0.75em 0.75em 0.5em 0.75em; word-wrap: break-word; } +.literalblock > .content pre.nowrap, .listingblock > .content pre.nowrap { overflow-x: auto; white-space: pre; word-wrap: normal; } +.literalblock > .content pre > code, .listingblock > .content pre > code { display: block; } +@media only screen { .literalblock > .content pre, .listingblock > .content pre { font-size: 0.8em; } } +@media only screen and (min-width: 768px) { .literalblock > .content pre, .listingblock > .content pre { font-size: 0.9em; } } +@media only screen and (min-width: 1280px) { .literalblock > .content pre, .listingblock > .content pre { font-size: 1em; } } +.listingblock > .content { position: relative; } +.listingblock:hover code[class*=" language-"]:before { text-transform: uppercase; font-size: 0.9em; color: #999; position: absolute; top: 0.375em; right: 0.375em; } +.listingblock:hover code.asciidoc:before { content: "asciidoc"; } +.listingblock:hover code.clojure:before { content: "clojure"; } +.listingblock:hover code.css:before { content: "css"; } +.listingblock:hover code.groovy:before { content: "groovy"; } +.listingblock:hover code.html:before { content: "html"; } +.listingblock:hover code.java:before { content: "java"; } +.listingblock:hover code.javascript:before { content: "javascript"; } +.listingblock:hover code.python:before { content: "python"; } +.listingblock:hover code.ruby:before { content: "ruby"; } +.listingblock:hover code.scss:before { content: "scss"; } +.listingblock:hover code.xml:before { content: "xml"; } +.listingblock:hover code.yaml:before { content: "yaml"; } +.listingblock.terminal pre .command:before { content: attr(data-prompt); padding-right: 0.5em; color: #999; } +.listingblock.terminal pre .command:not([data-prompt]):before { content: '$'; } +table.pyhltable { border: 0; margin-bottom: 0; } +table.pyhltable td { vertical-align: top; padding-top: 0; padding-bottom: 0; } +table.pyhltable td.code { padding-left: .75em; padding-right: 0; } +.highlight.pygments .lineno, table.pyhltable td:not(.code) { color: #999; padding-left: 0; padding-right: .5em; border-right: 1px solid #dddddd; } +.highlight.pygments .lineno { display: inline-block; margin-right: .25em; } +table.pyhltable .linenodiv { background-color: transparent !important; padding-right: 0 !important; } +.quoteblock { margin: 0 0 1.25em; padding: 0.5625em 1.25em 0 1.1875em; border-left: 1px solid #dddddd; } +.quoteblock blockquote { margin: 0 0 1.25em 0; padding: 0 0 0.5625em 0; border: 0; } +.quoteblock blockquote > .paragraph:last-child p { margin-bottom: 0; } +.quoteblock .attribution { margin-top: -.25em; padding-bottom: 0.5625em; font-size: inherit; color: #555555; } +.quoteblock .attribution br { display: none; } +.quoteblock .attribution cite { display: block; margin-bottom: 0.625em; } +table thead th, table tfoot th { font-weight: bold; } +table.tableblock.grid-all { border-collapse: separate; border-spacing: 1px; -webkit-border-radius: 4px; border-radius: 4px; border-top: 1px solid #dddddd; border-bottom: 1px solid #dddddd; } +table.tableblock.frame-topbot, table.tableblock.frame-none { border-left: 0; border-right: 0; } +table.tableblock.frame-sides, table.tableblock.frame-none { border-top: 0; border-bottom: 0; } +table.tableblock td .paragraph:last-child p, table.tableblock td > p:last-child { margin-bottom: 0; } +th.tableblock.halign-left, td.tableblock.halign-left { text-align: left; } +th.tableblock.halign-right, td.tableblock.halign-right { text-align: right; } +th.tableblock.halign-center, td.tableblock.halign-center { text-align: center; } +th.tableblock.valign-top, td.tableblock.valign-top { vertical-align: top; } +th.tableblock.valign-bottom, td.tableblock.valign-bottom { vertical-align: bottom; } +th.tableblock.valign-middle, td.tableblock.valign-middle { vertical-align: middle; } +p.tableblock.header { color: #222222; font-weight: bold; } +td > div.verse { white-space: pre; } +ol { margin-left: 1.75em; } +ul li ol { margin-left: 1.5em; } +dl dd { margin-left: 1.125em; } +dl dd:last-child, dl dd:last-child > :last-child { margin-bottom: 0; } +ol > li p, ul > li p, ul dd, ol dd, .olist .olist, .ulist .ulist, .ulist .olist, .olist .ulist { margin-bottom: 0.625em; } +ul.unstyled, ol.unnumbered, ul.checklist, ul.none { list-style-type: none; } +ul.unstyled, ol.unnumbered, ul.checklist { margin-left: 0.625em; } +ul.checklist li > p:first-child > i[class^="icon-check"]:first-child, ul.checklist li > p:first-child > input[type="checkbox"]:first-child { margin-right: 0.25em; } +ul.checklist li > p:first-child > input[type="checkbox"]:first-child { position: relative; top: 1px; } +ul.inline { margin: 0 auto 0.625em auto; margin-left: -1.375em; margin-right: 0; padding: 0; list-style: none; overflow: hidden; } +ul.inline > li { list-style: none; float: left; margin-left: 1.375em; display: block; } +ul.inline > li > * { display: block; } +.unstyled dl dt { font-weight: normal; font-style: normal; } +ol.arabic { list-style-type: decimal; } +ol.decimal { list-style-type: decimal-leading-zero; } +ol.loweralpha { list-style-type: lower-alpha; } +ol.upperalpha { list-style-type: upper-alpha; } +ol.lowerroman { list-style-type: lower-roman; } +ol.upperroman { list-style-type: upper-roman; } +ol.lowergreek { list-style-type: lower-greek; } +.hdlist > table, .colist > table { border: 0; background: none; } +.hdlist > table > tbody > tr, .colist > table > tbody > tr { background: none; } +td.hdlist1 { padding-right: .8em; font-weight: bold; } +td.hdlist1, td.hdlist2 { vertical-align: top; } +.literalblock + .colist, .listingblock + .colist { margin-top: -0.5em; } +.colist > table tr > td:first-of-type { padding: 0 .8em; line-height: 1; } +.colist > table tr > td:last-of-type { padding: 0.25em 0; } +.qanda > ol > li > p > em:only-child { color: #00467f; } +.thumb, .th { line-height: 0; display: inline-block; border: solid 4px white; -webkit-box-shadow: 0 0 0 1px #dddddd; box-shadow: 0 0 0 1px #dddddd; } +.imageblock.left, .imageblock[style*="float: left"] { margin: 0.25em 0.625em 1.25em 0; } +.imageblock.right, .imageblock[style*="float: right"] { margin: 0.25em 0 1.25em 0.625em; } +.imageblock > .title { margin-bottom: 0; } +.imageblock.thumb, .imageblock.th { border-width: 6px; } +.imageblock.thumb > .title, .imageblock.th > .title { padding: 0 0.125em; } +.image.left, .image.right { margin-top: 0.25em; margin-bottom: 0.25em; display: inline-block; line-height: 0; } +.image.left { margin-right: 0.625em; } +.image.right { margin-left: 0.625em; } +a.image { text-decoration: none; } +span.footnote, span.footnoteref { vertical-align: super; font-size: 0.875em; } +span.footnote a, span.footnoteref a { text-decoration: none; } +#footnotes { padding-top: 0.75em; padding-bottom: 0.75em; margin-bottom: 0.625em; } +#footnotes hr { width: 20%; min-width: 6.25em; margin: -.25em 0 .75em 0; border-width: 1px 0 0 0; } +#footnotes .footnote { padding: 0 0.375em; line-height: 1.3; font-size: 0.875em; margin-left: 1.2em; text-indent: -1.2em; margin-bottom: .2em; } +#footnotes .footnote a:first-of-type { font-weight: bold; text-decoration: none; } +#footnotes .footnote:last-of-type { margin-bottom: 0; } +#content #footnotes { margin-top: -0.625em; margin-bottom: 0; padding: 0.75em 0; } +.gist .file-data > table { border: none; background: #fff; width: 100%; margin-bottom: 0; } +.gist .file-data > table td.line-data { width: 99%; } +div.unbreakable { page-break-inside: avoid; } +.big { font-size: larger; } +.small { font-size: smaller; } +.underline { text-decoration: underline; } +.overline { text-decoration: overline; } +.line-through { text-decoration: line-through; } +.aqua { color: #00bfbf; } +.aqua-background { background-color: #00fafa; } +.black { color: black; } +.black-background { background-color: black; } +.blue { color: #0000bf; } +.blue-background { background-color: #0000fa; } +.fuchsia { color: #bf00bf; } +.fuchsia-background { background-color: #fa00fa; } +.gray { color: #606060; } +.gray-background { background-color: #7d7d7d; } +.green { color: #006000; } +.green-background { background-color: #007d00; } +.lime { color: #00bf00; } +.lime-background { background-color: #00fa00; } +.maroon { color: #600000; } +.maroon-background { background-color: #7d0000; } +.navy { color: #000060; } +.navy-background { background-color: #00007d; } +.olive { color: #606000; } +.olive-background { background-color: #7d7d00; } +.purple { color: #600060; } +.purple-background { background-color: #7d007d; } +.red { color: #bf0000; } +.red-background { background-color: #fa0000; } +.silver { color: #909090; } +.silver-background { background-color: #bcbcbc; } +.teal { color: #006060; } +.teal-background { background-color: #007d7d; } +.white { color: #bfbfbf; } +.white-background { background-color: #fafafa; } +.yellow { color: #bfbf00; } +.yellow-background { background-color: #fafa00; } +span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } +.admonitionblock td.icon [class^="icon-"]:before { font-size: 2.5em; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); cursor: default; } +.admonitionblock td.icon .icon-note:before { content: "\f05a"; color: #005498; color: #003f72; } +.admonitionblock td.icon .icon-tip:before { content: "\f0eb"; text-shadow: 1px 1px 2px rgba(155, 155, 0, 0.8); color: #111; } +.admonitionblock td.icon .icon-warning:before { content: "\f071"; color: #bf6900; } +.admonitionblock td.icon .icon-caution:before { content: "\f06d"; color: #bf3400; } +.admonitionblock td.icon .icon-important:before { content: "\f06a"; color: #bf0000; } +.conum { display: inline-block; color: white !important; background-color: #222222; -webkit-border-radius: 100px; border-radius: 100px; text-align: center; width: 20px; height: 20px; font-size: 12px; font-weight: bold; line-height: 20px; font-family: Arial, sans-serif; font-style: normal; position: relative; top: -2px; letter-spacing: -1px; } +.conum * { color: white !important; } +.conum + b { display: none; } +.conum:after { content: attr(data-value); } +.conum:not([data-value]):empty { display: none; } +.literalblock > .content > pre, .listingblock > .content > pre { -webkit-border-radius: 0; border-radius: 0; } + +/** Spring IO customizations **/ + +h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { color: #060; } +.subheader, #content #toctitle, .admonitionblock td.content > .title, .exampleblock > .title, .imageblock > .title, .videoblock > .title, .listingblock > .title, .literalblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, .sidebarblock > .title, .tableblock > .title, .verseblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title, .tableblock > caption { color: #080; } \ No newline at end of file