Class DataSourceService
- java.lang.Object
-
- fr.paris.lutece.plugins.elasticdata.service.DataSourceService
-
public final class DataSourceService extends java.lang.ObjectDataSourceService
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcompleteDataObjectWithFullData(DataSource dataSource, DataObject dataObject)Complete the data source with the external attributes and set elastic docuement idstatic voidcompleteDataObjectWithFullData(DataSource dataSource, java.util.List<DataObject> dataObjectList)Complete the data source with the external attributes and set elastic docuement idstatic voiddeleteById(DataSource dataSource, java.lang.String strId)Delete a document based on its id in the indexstatic voiddeleteByQuery(DataSource dataSource, java.lang.String strQuery)Delete a documents by Querystatic DataSourcegetDataSource(java.lang.String strId)Get a Data Source from its IDstatic java.util.Collection<DataSource>getDataSources()Gets all data sources found into Spring context filesstatic fr.paris.lutece.plugins.libraryelastic.util.ElasticgetElastic()Return elastic connectionstatic java.lang.StringgetIdDocument(java.lang.String strIdDataSource, java.lang.String strIdDataObject)Return the unique id of the elastic documentstatic java.lang.StringinsertDataAllDatasources(boolean bReset)Insert All data sourcesstatic java.lang.StringinsertDataAllDatasources(boolean bReset, boolean bDaemon)Insert All data sourcesstatic intinsertObjects(fr.paris.lutece.plugins.libraryelastic.util.Elastic elastic, DataSource dataSource, java.util.Iterator<DataObject> iterateDataObjects)Insert a list of object in bulk modestatic voidpartialUpdate(DataSource dataSource, java.lang.String strId, java.lang.Object object)Partial Updates to Documentsstatic voidprocessFullIndexing(DataSource dataSource, boolean bReset)Insert data from a DataSource into Elastic Searchstatic voidprocessIncrementalIndexing(DataSource dataSource, DataObject dataObject)Insert one dataObject from a DataSource into Elastic Searchstatic voidprocessIncrementalIndexing(java.lang.StringBuilder sbLogs, DataSource dataSource, java.util.Collection<DataObject> dataObject)Insert a dataObject from a DataSource into Elastic Searchstatic voidupdateIndexingStatus(DataSource dataSource, int nCount)Update indexing status of the datasource
-
-
-
Method Detail
-
getDataSources
public static java.util.Collection<DataSource> getDataSources()
Gets all data sources found into Spring context files- Returns:
- The list
-
getDataSource
public static DataSource getDataSource(java.lang.String strId)
Get a Data Source from its ID- Parameters:
strId- The ID- Returns:
- The Data Source
-
processFullIndexing
public static void processFullIndexing(DataSource dataSource, boolean bReset)
Insert data from a DataSource into Elastic Search- Parameters:
sbLogs- A log bufferdataSource- The data sourcebReset- if the index should be reset before inserting- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- If an error occurs accessing to ElasticSearch
-
processIncrementalIndexing
public static void processIncrementalIndexing(DataSource dataSource, DataObject dataObject) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
Insert one dataObject from a DataSource into Elastic Search- Parameters:
dataSource- The data sourcedataObject- The data object- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- If an error occurs accessing to ElasticSearch
-
processIncrementalIndexing
public static void processIncrementalIndexing(java.lang.StringBuilder sbLogs, DataSource dataSource, java.util.Collection<DataObject> dataObject) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientExceptionInsert a dataObject from a DataSource into Elastic Search- Parameters:
sbLogs- A log bufferdataSource- The data sourcedataObject- The collection of data object- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
-
partialUpdate
public static void partialUpdate(DataSource dataSource, java.lang.String strId, java.lang.Object object) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
Partial Updates to Documents- Parameters:
dataSource- The data sourcestrId- The document idobject- The object- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- Exception If an error occurs accessing to ElasticSearch
-
deleteByQuery
public static void deleteByQuery(DataSource dataSource, java.lang.String strQuery) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
Delete a documents by Query- Parameters:
dataSource- the data sourcestrQuery- the query- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- Exception If an error occurs accessing to ElasticSearch
-
deleteById
public static void deleteById(DataSource dataSource, java.lang.String strId) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException
Delete a document based on its id in the index- Parameters:
dataSource- The data sourcestrId- The id- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- Exception If an error occurs accessing to ElasticSearch
-
insertDataAllDatasources
public static java.lang.String insertDataAllDatasources(boolean bReset)
Insert All data sources- Parameters:
bReset- Reset the index before inserting- Returns:
- The logs of the process
- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- If an error occurs accessing to ElasticSearch
-
insertDataAllDatasources
public static java.lang.String insertDataAllDatasources(boolean bReset, boolean bDaemon)Insert All data sources- Parameters:
bReset- Reset the index before insertingbDaemon- If called by a daemon- Returns:
- The logs of the process
-
getElastic
public static fr.paris.lutece.plugins.libraryelastic.util.Elastic getElastic()
Return elastic connection
-
completeDataObjectWithFullData
public static void completeDataObjectWithFullData(DataSource dataSource, DataObject dataObject)
Complete the data source with the external attributes and set elastic docuement id- Parameters:
dataSource- the data sourcedataObject- the data object
-
completeDataObjectWithFullData
public static void completeDataObjectWithFullData(DataSource dataSource, java.util.List<DataObject> dataObjectList)
Complete the data source with the external attributes and set elastic docuement id- Parameters:
dataSource- the data sourcedataObject- the data object
-
getIdDocument
public static java.lang.String getIdDocument(java.lang.String strIdDataSource, java.lang.String strIdDataObject)Return the unique id of the elastic document- Parameters:
strIdDataSource- the data source idstrIdDataObject- the data object id
-
insertObjects
public static int insertObjects(fr.paris.lutece.plugins.libraryelastic.util.Elastic elastic, DataSource dataSource, java.util.Iterator<DataObject> iterateDataObjects) throws fr.paris.lutece.plugins.libraryelastic.util.ElasticClientExceptionInsert a list of object in bulk mode- Parameters:
elastic- The Elastic ServerdataSource- The data sourceiterateDataObjects- The iterator of objects- Returns:
- the number of documents posted
- Throws:
fr.paris.lutece.plugins.libraryelastic.util.ElasticClientException- If a problem occurs connecting the server
-
updateIndexingStatus
public static void updateIndexingStatus(DataSource dataSource, int nCount)
Update indexing status of the datasource- Parameters:
dataSource- the data sourcenCount- the count of objects processed
-
-