Package org.opencms.search.solr
Class CmsSolrIndexWriter
- java.lang.Object
-
- org.opencms.search.solr.CmsSolrIndexWriter
-
- All Implemented Interfaces:
I_CmsIndexWriter
,I_CmsSolrIndexWriter
public class CmsSolrIndexWriter extends java.lang.Object implements I_CmsSolrIndexWriter
Implements the index writer for the Solr server used by OpenCms.- Since:
- 8.5.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.Log
LOG
The log object for this class.
-
Constructor Summary
Constructors Constructor Description CmsSolrIndexWriter(org.apache.solr.client.solrj.SolrClient client)
Constructor to create a Solr index writer.CmsSolrIndexWriter(org.apache.solr.client.solrj.SolrClient client, CmsSolrIndex index)
Creates a new index writer based on the provided standard Lucene IndexWriter for the provided OpenCms search index instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this IndexWriter.void
commit()
Commit all previous operations.void
deleteAllDocuments()
Deletes all documents of the index belonging to this index writer.void
deleteDocument(CmsPublishedResource resource)
Delete a document from the index.void
optimize()
Optimizes the index.void
updateDocument(java.lang.String rootPath, I_CmsSearchDocument document)
Update a document in the index.void
updateDocument(I_CmsSearchDocument searchDocument)
Updates a search document without removing it beforehand.
-
-
-
Field Detail
-
LOG
protected static final org.apache.commons.logging.Log LOG
The log object for this class.
-
-
Constructor Detail
-
CmsSolrIndexWriter
public CmsSolrIndexWriter(org.apache.solr.client.solrj.SolrClient client)
Constructor to create a Solr index writer.- Parameters:
client
- the client to use
-
CmsSolrIndexWriter
public CmsSolrIndexWriter(org.apache.solr.client.solrj.SolrClient client, CmsSolrIndex index)
Creates a new index writer based on the provided standard Lucene IndexWriter for the provided OpenCms search index instance.The OpenCms search instance is currently used only for improved logging of the index operations.
- Parameters:
client
- the standard Lucene IndexWriter to use as delegateindex
- the OpenCms search index instance this writer to supposed to write to
-
-
Method Detail
-
close
public void close()
Description copied from interface:I_CmsIndexWriter
Close this IndexWriter.- Specified by:
close
in interfaceI_CmsIndexWriter
- See Also:
I_CmsIndexWriter.close()
-
commit
public void commit() throws java.io.IOException
Description copied from interface:I_CmsIndexWriter
Commit all previous operations.- Specified by:
commit
in interfaceI_CmsIndexWriter
- Throws:
java.io.IOException
- thrown if the commit action fails.- See Also:
I_CmsIndexWriter.commit()
-
deleteAllDocuments
public void deleteAllDocuments() throws java.io.IOException
Description copied from interface:I_CmsSolrIndexWriter
Deletes all documents of the index belonging to this index writer.- Specified by:
deleteAllDocuments
in interfaceI_CmsSolrIndexWriter
- Throws:
java.io.IOException
- if something goes wrong- See Also:
I_CmsSolrIndexWriter.deleteAllDocuments()
-
deleteDocument
public void deleteDocument(CmsPublishedResource resource) throws java.io.IOException
Description copied from interface:I_CmsIndexWriter
Delete a document from the index.- Specified by:
deleteDocument
in interfaceI_CmsIndexWriter
- Parameters:
resource
- the resource to delete- Throws:
java.io.IOException
- in case something goes wrong- See Also:
I_CmsIndexWriter.deleteDocument(org.opencms.db.CmsPublishedResource)
-
optimize
public void optimize()
Description copied from interface:I_CmsIndexWriter
Optimizes the index.Please note that as of Lucene 3.5, the direct use of optimize is discouraged as Lucene apparently is now able to manage the file structure so efficiently that frequent optimizations are not longer required.
- Specified by:
optimize
in interfaceI_CmsIndexWriter
- See Also:
I_CmsIndexWriter.optimize()
-
updateDocument
public void updateDocument(I_CmsSearchDocument searchDocument) throws java.io.IOException
Updates a search document without removing it beforehand. Use for migration purposes only.- Parameters:
searchDocument
- the search document.- Throws:
java.io.IOException
- if the update fails
-
updateDocument
public void updateDocument(java.lang.String rootPath, I_CmsSearchDocument document) throws java.io.IOException
Description copied from interface:I_CmsIndexWriter
Update a document in the index.- Specified by:
updateDocument
in interfaceI_CmsIndexWriter
- Parameters:
rootPath
- the root path of the document to updatedocument
- the document to update- Throws:
java.io.IOException
- in case something goes wrong- See Also:
I_CmsIndexWriter.updateDocument(java.lang.String, org.opencms.search.I_CmsSearchDocument)
-
-