Spring Data Elasticsearch

org.springframework.data.elasticsearch.core
Interface ElasticsearchOperations

All Known Implementing Classes:
ElasticsearchTemplate

public interface ElasticsearchOperations

ElasticsearchOperations

Author:
Rizwan Idrees, Mohsin Husen

Method Summary
 Boolean addAlias(AliasQuery query)
          adding new alias
 void bulkIndex(List<IndexQuery> queries)
          Bulk index all objects.
<T> long
count(SearchQuery query)
          return number of elements found by given query
<T> long
count(SearchQuery query, Class<T> clazz)
          return number of elements found by given query
<T> boolean
createIndex(Class<T> clazz)
          Create an index for a class
<T> boolean
createIndex(Class<T> clazz, Object settings)
          Create an index for given class and Settings
 boolean createIndex(String indexName)
          Create an index for given indexName
 boolean createIndex(String indexName, Object settings)
          Create an index for given indexName and Settings
<T> String
delete(Class<T> clazz, String id)
          Delete the one object with provided id
 void delete(DeleteQuery query)
          Delete all records matching the query
<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
<T> boolean
deleteIndex(Class<T> clazz)
          Deletes an index for given entity
 boolean deleteIndex(String indexName)
          Deletes an index for given indexName
 void deleteType(String index, String type)
          Deletes a type in an index
 ElasticsearchConverter getElasticsearchConverter()
           
<T> Map
getMapping(Class<T> clazz)
          Get mapping for a class
 Map getMapping(String indexName, String type)
          Get mapping for a given indexName and type
<T> Map
getSetting(Class<T> clazz)
          Get settings for a given class
 Map getSetting(String indexName)
          Get settings for a given indexName
 String index(IndexQuery query)
          Index an object.
<T> boolean
indexExists(Class<T> clazz)
          check if index is exists
 boolean indexExists(String indexName)
          check if index is exists for given IndexName
<T> Page<T>
moreLikeThis(MoreLikeThisQuery query, Class<T> clazz)
          more like this query to search for documents that are "like" a specific document.
<T> LinkedList<T>
multiGet(SearchQuery searchQuery, Class<T> clazz)
          Execute a multiGet against elasticsearch for the given ids
<T> LinkedList<T>
multiGet(SearchQuery searchQuery, Class<T> clazz, MultiGetResultMapper multiGetResultMapper)
          Execute a multiGet against elasticsearch for the given ids with MultiGetResultMapper
<T> boolean
putMapping(Class<T> clazz)
          Create mapping for a class
<T> boolean
putMapping(Class<T> clazz, Object mappings)
          Create mapping for a class
 boolean putMapping(String indexName, String type, Object mappings)
          Create mapping for a given indexName and type
 Set<String> queryForAlias(String indexName)
          get all the alias pointing to specified index
<T> List<String>
queryForIds(SearchQuery query)
          Execute the query against elasticsearch and return ids
<T> List<T>
queryForList(CriteriaQuery query, Class<T> clazz)
          Execute the criteria query against elasticsearch and return result as List
<T> List<T>
queryForList(SearchQuery query, Class<T> clazz)
          Execute the search query against elasticsearch and return result as List
<T> List<T>
queryForList(StringQuery query, Class<T> clazz)
          Execute the string query against elasticsearch and return result as List
<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(GetQuery query, Class<T> clazz, GetResultMapper mapper)
          Execute the query against elasticsearch and return the first returned object using custom mapper
<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> FacetedPage<T>
queryForPage(SearchQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return result as Page
<T> FacetedPage<T>
queryForPage(SearchQuery query, Class<T> clazz, SearchResultMapper mapper)
          Execute the query against elasticsearch and return result as Page using custom mapper
<T> FacetedPage<T>
queryForPage(StringQuery query, Class<T> clazz)
          Execute the query against elasticsearch and return result as Page
<T> FacetedPage<T>
queryForPage(StringQuery query, Class<T> clazz, SearchResultMapper mapper)
          Execute the query against elasticsearch and return result as Page using custom mapper
<T> void
refresh(Class<T> clazz, boolean waitForOperation)
          refresh the index
 void refresh(String indexName, boolean waitForOperation)
          refresh the index
 Boolean removeAlias(AliasQuery query)
          removing previously created alias
 String scan(SearchQuery query, long scrollTimeInMillis, boolean noFields)
          Returns scroll id for scan query
<T> Page<T>
scroll(String scrollId, long scrollTimeInMillis, Class<T> clazz)
          Scrolls the results for give scroll id
<T> Page<T>
scroll(String scrollId, long scrollTimeInMillis, SearchResultMapper mapper)
          Scrolls the results for give scroll id using custom result mapper
 boolean typeExists(String index, String type)
          check if type is exists in an index
 org.elasticsearch.action.update.UpdateResponse update(UpdateQuery updateQuery)
          Partial update of the document
 

Method Detail

getElasticsearchConverter

ElasticsearchConverter getElasticsearchConverter()
Returns:
Converter in use

createIndex

<T> boolean createIndex(Class<T> clazz)
Create an index for a class

Type Parameters:
T -
Parameters:
clazz -

createIndex

boolean createIndex(String indexName)
Create an index for given indexName

Parameters:
indexName -

createIndex

boolean createIndex(String indexName,
                    Object settings)
Create an index for given indexName and Settings

Parameters:
indexName -
settings -

createIndex

<T> boolean createIndex(Class<T> clazz,
                        Object settings)
Create an index for given class and Settings

Parameters:
clazz -
settings -

putMapping

<T> boolean putMapping(Class<T> clazz)
Create mapping for a class

Type Parameters:
T -
Parameters:
clazz -

putMapping

boolean putMapping(String indexName,
                   String type,
                   Object mappings)
Create mapping for a given indexName and type

Parameters:
indexName -
type -
mappings -

putMapping

<T> boolean putMapping(Class<T> clazz,
                       Object mappings)
Create mapping for a class

Parameters:
clazz -
mappings -

getMapping

<T> Map getMapping(Class<T> clazz)
Get mapping for a class

Type Parameters:
T -
Parameters:
clazz -

getMapping

Map getMapping(String indexName,
               String type)
Get mapping for a given indexName and type

Parameters:
indexName -
type -

getSetting

Map getSetting(String indexName)
Get settings for a given indexName

Parameters:
indexName -

getSetting

<T> Map getSetting(Class<T> clazz)
Get settings for a given class

Parameters:
clazz -

queryForObject

<T> T queryForObject(GetQuery query,
                     Class<T> clazz)
Execute the query against elasticsearch and return the first returned object

Parameters:
query -
clazz -
Returns:
the first matching object

queryForObject

<T> T queryForObject(GetQuery query,
                     Class<T> clazz,
                     GetResultMapper mapper)
Execute the query against elasticsearch and return the first returned object using custom mapper

Parameters:
query -
clazz -
mapper -
Returns:
the first matching object

queryForObject

<T> T queryForObject(CriteriaQuery query,
                     Class<T> clazz)
Execute the query against elasticsearch and return the first returned object

Parameters:
query -
clazz -
Returns:
the first matching object

queryForObject

<T> T queryForObject(StringQuery query,
                     Class<T> clazz)
Execute the query against elasticsearch and return the first returned object

Parameters:
query -
clazz -
Returns:
the first matching object

queryForPage

<T> FacetedPage<T> queryForPage(SearchQuery query,
                                Class<T> clazz)
Execute the query against elasticsearch and return result as Page

Parameters:
query -
clazz -
Returns:

queryForPage

<T> FacetedPage<T> queryForPage(SearchQuery query,
                                Class<T> clazz,
                                SearchResultMapper mapper)
Execute the query against elasticsearch and return result as Page using custom mapper

Parameters:
query -
clazz -
Returns:

queryForPage

<T> Page<T> queryForPage(CriteriaQuery query,
                         Class<T> clazz)
Execute the query against elasticsearch and return result as Page

Parameters:
query -
clazz -
Returns:

queryForPage

<T> FacetedPage<T> queryForPage(StringQuery query,
                                Class<T> clazz)
Execute the query against elasticsearch and return result as Page

Parameters:
query -
clazz -
Returns:

queryForPage

<T> FacetedPage<T> queryForPage(StringQuery query,
                                Class<T> clazz,
                                SearchResultMapper mapper)
Execute the query against elasticsearch and return result as Page using custom mapper

Parameters:
query -
clazz -
Returns:

queryForList

<T> List<T> queryForList(CriteriaQuery query,
                         Class<T> clazz)
Execute the criteria query against elasticsearch and return result as List

Type Parameters:
T -
Parameters:
query -
clazz -
Returns:

queryForList

<T> List<T> queryForList(StringQuery query,
                         Class<T> clazz)
Execute the string query against elasticsearch and return result as List

Type Parameters:
T -
Parameters:
query -
clazz -
Returns:

queryForList

<T> List<T> queryForList(SearchQuery query,
                         Class<T> clazz)
Execute the search query against elasticsearch and return result as List

Type Parameters:
T -
Parameters:
query -
clazz -
Returns:

queryForIds

<T> List<String> queryForIds(SearchQuery query)
Execute the query against elasticsearch and return ids

Parameters:
query -
Returns:

count

<T> long count(SearchQuery query,
               Class<T> clazz)
return number of elements found by given query

Parameters:
query -
clazz -
Returns:

count

<T> long count(SearchQuery query)
return number of elements found by given query

Parameters:
query -
Returns:

multiGet

<T> LinkedList<T> multiGet(SearchQuery searchQuery,
                           Class<T> clazz)
Execute a multiGet against elasticsearch for the given ids

Parameters:
searchQuery -
clazz -
Returns:

multiGet

<T> LinkedList<T> multiGet(SearchQuery searchQuery,
                           Class<T> clazz,
                           MultiGetResultMapper multiGetResultMapper)
Execute a multiGet against elasticsearch for the given ids with MultiGetResultMapper

Parameters:
searchQuery -
clazz -
multiGetResultMapper -
Returns:

index

String index(IndexQuery query)
Index an object. Will do save or update

Parameters:
query -
Returns:
returns the document id

update

org.elasticsearch.action.update.UpdateResponse update(UpdateQuery updateQuery)
Partial update of the document

Parameters:
updateQuery -
Returns:

bulkIndex

void bulkIndex(List<IndexQuery> queries)
Bulk index all objects. Will do save or update

Parameters:
queries -

delete

String delete(String indexName,
              String type,
              String id)
Delete the one object with provided id

Parameters:
indexName -
type -
id -
Returns:
documentId of the document deleted

delete

<T> String delete(Class<T> clazz,
                  String id)
Delete the one object with provided id

Parameters:
clazz -
id -
Returns:
documentId of the document deleted

delete

<T> void delete(DeleteQuery query,
                Class<T> clazz)
Delete all records matching the query

Parameters:
clazz -
query -

delete

void delete(DeleteQuery query)
Delete all records matching the query

Parameters:
query -

deleteIndex

<T> boolean deleteIndex(Class<T> clazz)
Deletes an index for given entity

Type Parameters:
T -
Parameters:
clazz -
Returns:

deleteIndex

boolean deleteIndex(String indexName)
Deletes an index for given indexName

Parameters:
indexName -
Returns:

deleteType

void deleteType(String index,
                String type)
Deletes a type in an index

Parameters:
index -
type -

indexExists

<T> boolean indexExists(Class<T> clazz)
check if index is exists

Type Parameters:
T -
Parameters:
clazz -
Returns:

indexExists

boolean indexExists(String indexName)
check if index is exists for given IndexName

Parameters:
indexName -
Returns:

typeExists

boolean typeExists(String index,
                   String type)
check if type is exists in an index

Parameters:
index -
type -
Returns:

refresh

void refresh(String indexName,
             boolean waitForOperation)
refresh the index

Parameters:
indexName -
waitForOperation -

refresh

<T> void refresh(Class<T> clazz,
                 boolean waitForOperation)
refresh the index

Parameters:
clazz -
waitForOperation -

scan

String scan(SearchQuery query,
            long scrollTimeInMillis,
            boolean noFields)
Returns scroll id for scan query

Parameters:
query -
scrollTimeInMillis -
noFields -
Returns:

scroll

<T> Page<T> scroll(String scrollId,
                   long scrollTimeInMillis,
                   Class<T> clazz)
Scrolls the results for give scroll id

Type Parameters:
T -
Parameters:
scrollId -
scrollTimeInMillis -
clazz -
Returns:

scroll

<T> Page<T> scroll(String scrollId,
                   long scrollTimeInMillis,
                   SearchResultMapper mapper)
Scrolls the results for give scroll id using custom result mapper

Type Parameters:
T -
Parameters:
scrollId -
scrollTimeInMillis -
mapper -
Returns:

moreLikeThis

<T> Page<T> moreLikeThis(MoreLikeThisQuery query,
                         Class<T> clazz)
more like this query to search for documents that are "like" a specific document.

Type Parameters:
T -
Parameters:
query -
clazz -
Returns:

addAlias

Boolean addAlias(AliasQuery query)
adding new alias

Parameters:
query -
Returns:

removeAlias

Boolean removeAlias(AliasQuery query)
removing previously created alias

Parameters:
query -
Returns:

queryForAlias

Set<String> queryForAlias(String indexName)
get all the alias pointing to specified index

Parameters:
indexName -
Returns:

Spring Data Elasticsearch

Copyright © 2011-2014-2014 Pivotal Software, Inc.. All Rights Reserved.