Spring Data Elasticsearch

org.springframework.data.elasticsearch.core
Class ElasticsearchTemplate

java.lang.Object
  extended by org.springframework.data.elasticsearch.core.ElasticsearchTemplate
All Implemented Interfaces:
ElasticsearchOperations

public class ElasticsearchTemplate
extends Object
implements ElasticsearchOperations

ElasticsearchTemplate

Author:
Rizwan Idrees, Mohsin Husen

Constructor Summary
ElasticsearchTemplate(org.elasticsearch.client.Client client)
           
ElasticsearchTemplate(org.elasticsearch.client.Client client, ElasticsearchConverter elasticsearchConverter)
           
 
Method Summary
 void bulkIndex(List<IndexQuery> queries)
          Bulk index all objects.
<T> long
count(SearchQuery query, Class<T> clazz)
          return number of elements found by for given query
<T> boolean
createIndex(Class<T> clazz)
          Create an index
<T> String
delete(Class<T> clazz, String id)
          Delete the one object with provided id
<T> void
delete(DeleteQuery query, Class<T> clazz)
          Delete all records matching the query
 String delete(String indexName, String type, String id)
          Delete the one object with provided id
 ElasticsearchConverter getElasticsearchConverter()
           
 String index(IndexQuery query)
          Index an object.
<T> List<String>
queryForIds(SearchQuery query)
          Execute the query against elasticsearch and return ids
<T> T
queryForObject(CriteriaQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return the first returned object
<T> T
queryForObject(GetQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return the first returned object
<T> T
queryForObject(StringQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return the first returned object
<T> Page<T>
queryForPage(CriteriaQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return result as Page
<T> Page<T>
queryForPage(SearchQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return result as Page
<T> Page<T>
queryForPage(SearchQuery query, ResultsMapper<T> resultsMapper)
          Execute the query against elasticsearch and return result as Page
<T> Page<T>
queryForPage(StringQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return result as Page
<T> void
refresh(Class<T> clazz, boolean waitForOperation)
          refresh the index
 void refresh(String indexName, boolean waitForOperation)
          refresh the index
 String scan(SearchQuery query, long scrollTimeInMillis, boolean noFields)
          Returns scroll id for scan query
<T> Page<T>
scroll(String scrollId, long scrollTimeInMillis, ResultsMapper<T> resultsMapper)
          Scrolls the results for give scroll id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElasticsearchTemplate

public ElasticsearchTemplate(org.elasticsearch.client.Client client)

ElasticsearchTemplate

public ElasticsearchTemplate(org.elasticsearch.client.Client client,
                             ElasticsearchConverter elasticsearchConverter)
Method Detail

createIndex

public <T> boolean createIndex(Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Create an index

Specified by:
createIndex in interface ElasticsearchOperations

getElasticsearchConverter

public ElasticsearchConverter getElasticsearchConverter()
Specified by:
getElasticsearchConverter in interface ElasticsearchOperations
Returns:
Converter in use

queryForObject

public <T> T queryForObject(GetQuery query,
                            Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return the first returned object

Specified by:
queryForObject in interface ElasticsearchOperations
Returns:
the first matching object

queryForObject

public <T> T queryForObject(CriteriaQuery query,
                            Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return the first returned object

Specified by:
queryForObject in interface ElasticsearchOperations
Returns:
the first matching object

queryForObject

public <T> T queryForObject(StringQuery query,
                            Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return the first returned object

Specified by:
queryForObject in interface ElasticsearchOperations
Returns:
the first matching object

queryForPage

public <T> Page<T> queryForPage(SearchQuery query,
                                Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return result as Page

Specified by:
queryForPage in interface ElasticsearchOperations
Returns:

queryForPage

public <T> Page<T> queryForPage(SearchQuery query,
                                ResultsMapper<T> resultsMapper)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return result as Page

Specified by:
queryForPage in interface ElasticsearchOperations
Returns:

queryForIds

public <T> List<String> queryForIds(SearchQuery query)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return ids

Specified by:
queryForIds in interface ElasticsearchOperations
Returns:

queryForPage

public <T> Page<T> queryForPage(CriteriaQuery query,
                                Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return result as Page

Specified by:
queryForPage in interface ElasticsearchOperations
Returns:

queryForPage

public <T> Page<T> queryForPage(StringQuery query,
                                Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Execute the query against elasticsearch and return result as Page

Specified by:
queryForPage in interface ElasticsearchOperations
Returns:

count

public <T> long count(SearchQuery query,
                      Class<T> clazz)
Description copied from interface: ElasticsearchOperations
return number of elements found by for given query

Specified by:
count in interface ElasticsearchOperations
Returns:

index

public String index(IndexQuery query)
Description copied from interface: ElasticsearchOperations
Index an object. Will do save or update

Specified by:
index in interface ElasticsearchOperations
Returns:
returns the document id

bulkIndex

public void bulkIndex(List<IndexQuery> queries)
Description copied from interface: ElasticsearchOperations
Bulk index all objects. Will do save or update

Specified by:
bulkIndex in interface ElasticsearchOperations

delete

public String delete(String indexName,
                     String type,
                     String id)
Description copied from interface: ElasticsearchOperations
Delete the one object with provided id

Specified by:
delete in interface ElasticsearchOperations
Returns:
documentId of the document deleted

delete

public <T> String delete(Class<T> clazz,
                         String id)
Description copied from interface: ElasticsearchOperations
Delete the one object with provided id

Specified by:
delete in interface ElasticsearchOperations
Returns:
documentId of the document deleted

delete

public <T> void delete(DeleteQuery query,
                       Class<T> clazz)
Description copied from interface: ElasticsearchOperations
Delete all records matching the query

Specified by:
delete in interface ElasticsearchOperations

refresh

public void refresh(String indexName,
                    boolean waitForOperation)
Description copied from interface: ElasticsearchOperations
refresh the index

Specified by:
refresh in interface ElasticsearchOperations

refresh

public <T> void refresh(Class<T> clazz,
                        boolean waitForOperation)
Description copied from interface: ElasticsearchOperations
refresh the index

Specified by:
refresh in interface ElasticsearchOperations

scan

public String scan(SearchQuery query,
                   long scrollTimeInMillis,
                   boolean noFields)
Description copied from interface: ElasticsearchOperations
Returns scroll id for scan query

Specified by:
scan in interface ElasticsearchOperations
Returns:

scroll

public <T> Page<T> scroll(String scrollId,
                          long scrollTimeInMillis,
                          ResultsMapper<T> resultsMapper)
Description copied from interface: ElasticsearchOperations
Scrolls the results for give scroll id

Specified by:
scroll in interface ElasticsearchOperations
Returns:

Spring Data Elasticsearch

Copyright © 2013 BioMed Central. All Rights Reserved.