diff --git a/src/java/fr/paris/lutece/plugins/search/solr/indexer/SolrIndexerService.java b/src/java/fr/paris/lutece/plugins/search/solr/indexer/SolrIndexerService.java index d498bdb..3b43e3a 100644 --- a/src/java/fr/paris/lutece/plugins/search/solr/indexer/SolrIndexerService.java +++ b/src/java/fr/paris/lutece/plugins/search/solr/indexer/SolrIndexerService.java @@ -121,6 +121,26 @@ private static void writeNoCommit( SolrItem solrItem, StringBuffer sbLogs ) thro } } + private static void updateNoCommit (SolrItem solrItem, StringBuffer sbLogs ) + { + try + { + sbLogs.append( "Indexing " ); + sbLogs.append( solrItem.getType( ) ); + sbLogs.append( " #" ); + sbLogs.append( solrItem.getUid( ) ); + sbLogs.append( " - " ); + sbLogs.append( solrItem.getTitle( ) ); + SolrInputDocument solrInputDocument = solrItem2SolrInputDocumentUpdate( solrItem ); + SOLR_SERVER.add( solrInputDocument ); + sbLogs.append( "\r\n" ); + } + catch (Exception e) + { + printIndexMessage( e, sbLogs ); + } + } + /** * Index one document, called by plugin indexers * @param solrItem The item @@ -132,6 +152,11 @@ public static void write( SolrItem solrItem ) throws CorruptIndexException, IOEx write( solrItem, _sbLogs ); } + public static void update( SolrItem solrItem ) throws CorruptIndexException, IOException + { + update( solrItem, _sbLogs ); + } + /** * Index one document, called by external code * @param solrItem The item @@ -152,6 +177,19 @@ public static void write( SolrItem solrItem, StringBuffer sbLogs ) throws Corrup } } + public static void update( SolrItem solrItem, StringBuffer sbLogs ) throws CorruptIndexException, IOException + { + try + { + updateNoCommit( solrItem, sbLogs ); + SOLR_SERVER.commit( ); + } + catch ( Exception e ) + { + printIndexMessage( e, sbLogs ); + } + } + /** * Index a collection of documents, called by plugin indexers * @param solrItems The item @@ -163,6 +201,11 @@ public static void write( Collection solrItems ) throws CorruptIndexEx write( solrItems, _sbLogs ); } + public static void update( Collection solrItems ) throws CorruptIndexException, IOException + { + update( solrItems, _sbLogs ); + } + /** * Index a collection of documents, called by external code * @param solrItems The item @@ -185,6 +228,20 @@ public static void write( Collection solrItems, StringBuffer sbLogs ) } } + public static void update(Collection solrItems, StringBuffer sbLogs ) + { + try { + for ( SolrItem solrItem: solrItems ) { + updateNoCommit( solrItem, sbLogs ); + } + SOLR_SERVER.commit( ); + } + catch (Exception e) + { + printIndexMessage(e, sbLogs); + } + } + /** * Process the indexing * @param bCreate tell if it's total indexing or total (total = true) @@ -500,6 +557,25 @@ private static SolrInputDocument solrItem2SolrInputDocument( SolrItem solrItem ) return solrInputDocument; } + private static SolrInputDocument solrItem2SolrInputDocumentUpdate (SolrItem solrItem) { + SolrInputDocument solrInputDocument = new SolrInputDocument( ); + String strWebappName = getWebAppName( ); + + solrInputDocument.addField( SearchItem.FIELD_UID, + strWebappName + SolrConstants.CONSTANT_UNDERSCORE + solrItem.getUid( ) ); + + Map mapDynamicFields = solrItem.getDynamicFields( ); + + for ( String strDynamicField : mapDynamicFields.keySet( ) ) + { + Map map = new HashMap<>(); + map.put("set", mapDynamicFields.get( strDynamicField )); + solrInputDocument.addField(strDynamicField, map); + } + + return solrInputDocument; + } + /** * Initialize the indexers List. * @return the indexers List diff --git a/webapp/WEB-INF/plugins/solr/conf/schema.xml b/webapp/WEB-INF/plugins/solr/conf/schema.xml index f9a123d..976641b 100644 --- a/webapp/WEB-INF/plugins/solr/conf/schema.xml +++ b/webapp/WEB-INF/plugins/solr/conf/schema.xml @@ -51,6 +51,7 @@ + diff --git a/webapp/WEB-INF/plugins/solr/conf/solrconfig.xml b/webapp/WEB-INF/plugins/solr/conf/solrconfig.xml index f5c72e6..c10628d 100644 --- a/webapp/WEB-INF/plugins/solr/conf/solrconfig.xml +++ b/webapp/WEB-INF/plugins/solr/conf/solrconfig.xml @@ -46,6 +46,12 @@ text + + + ${solr.ulog.dir:} + + + true