23 |
23 |
import java.io.FileNotFoundException;
|
24 |
24 |
import java.io.IOException;
|
25 |
25 |
import java.io.InputStream;
|
|
26 |
import java.net.MalformedURLException;
|
26 |
27 |
import java.util.ArrayList;
|
27 |
28 |
import java.util.Calendar;
|
|
29 |
import java.util.Collection;
|
28 |
30 |
import java.util.Date;
|
29 |
31 |
import java.util.HashMap;
|
30 |
32 |
import java.util.Iterator;
|
... | ... | |
40 |
42 |
import javax.xml.xpath.XPathFactory;
|
41 |
43 |
|
42 |
44 |
import org.apache.commons.codec.EncoderException;
|
|
45 |
import org.apache.commons.collections.CollectionUtils;
|
43 |
46 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
44 |
47 |
import org.apache.commons.lang.StringUtils;
|
45 |
48 |
import org.apache.commons.logging.Log;
|
... | ... | |
513 |
516 |
* index for the doc.
|
514 |
517 |
*/
|
515 |
518 |
public void update(Identifier pid, SystemMetadata systemMetadata) {
|
|
519 |
if(systemMetadata==null || pid==null) {
|
|
520 |
log.error("SolrIndex.update - the systemMetadata or pid is null. So nothing will be indexed.");
|
|
521 |
return;
|
|
522 |
}
|
516 |
523 |
String objectPath = null;
|
517 |
524 |
try {
|
518 |
|
objectPath = DistributedMapsFactory.getObjectPathMap().get(pid);
|
|
525 |
if(!systemMetadata.getArchived()) {
|
|
526 |
objectPath = DistributedMapsFactory.getObjectPathMap().get(pid);
|
|
527 |
}
|
519 |
528 |
update(pid, systemMetadata, objectPath);
|
520 |
529 |
EventlogFactory.createIndexEventLog().remove(pid);
|
521 |
530 |
} catch (Exception e) {
|
... | ... | |
524 |
533 |
log.error(error, e);
|
525 |
534 |
}
|
526 |
535 |
}
|
527 |
|
/**
|
528 |
|
* This method is used to delete solr index for a resourceMap. The file of resource map
|
529 |
|
* probably was deleted. But the byte array is the content.
|
530 |
|
* @param pid
|
531 |
|
* @param systemMetadata
|
532 |
|
* @param resourceMapData
|
533 |
|
*/
|
534 |
|
public void updateResourceMap(Identifier pid, SystemMetadata systemMetadata, byte[] resourceMapData) {
|
535 |
|
if(systemMetadata != null && pid !=null && pid.getValue()!= null) {
|
536 |
|
try {
|
537 |
|
boolean archived = systemMetadata.getArchived() != null && systemMetadata.getArchived();
|
538 |
|
if(archived && isDataPackage(pid.getValue(), systemMetadata)) {
|
539 |
|
removeDataPackage(pid.getValue(), resourceMapData);
|
540 |
|
}
|
541 |
|
}catch (Exception e) {
|
542 |
|
String error = "SolrIndex.updateResourceMap - could not update the solr index since " + e.getMessage();
|
543 |
|
writeEventLog(systemMetadata, pid, error);
|
544 |
|
log.error(error, e);
|
545 |
|
}
|
546 |
|
|
547 |
|
}
|
548 |
|
}
|
|
536 |
|
549 |
537 |
|
550 |
538 |
/**
|
551 |
539 |
* Update the solr index. This method handles the three scenarios:
|
... | ... | |
572 |
560 |
void update(Identifier pid, SystemMetadata systemMetadata, String objectPath) throws SolrServerException,
|
573 |
561 |
ServiceFailure, XPathExpressionException, NotImplemented, NotFound, UnsupportedType,
|
574 |
562 |
IOException, SAXException, ParserConfigurationException, OREParserException, JiBXException, EncoderException {
|
575 |
|
checkParams(pid, systemMetadata, objectPath);
|
|
563 |
//checkParams(pid, systemMetadata, objectPath);
|
|
564 |
if(systemMetadata==null || pid==null) {
|
|
565 |
log.error("SolrIndex.update - the systemMetadata or pid is null. So nothing will be indexed.");
|
|
566 |
return;
|
|
567 |
}
|
576 |
568 |
boolean isArchive = systemMetadata.getArchived() != null && systemMetadata.getArchived();
|
577 |
569 |
if(isArchive ) {
|
578 |
570 |
//delete the index for the archived objects
|
... | ... | |
634 |
626 |
}
|
635 |
627 |
|
636 |
628 |
/*
|
637 |
|
* Remove a data package for given pid. The content of package will be obtained from a file.
|
|
629 |
* Remove the resource map from the solr index. It doesn't only remove the index for itself and also
|
|
630 |
* remove the relationship for the related metadata and data objects.
|
638 |
631 |
*/
|
639 |
|
private void removeDataPackage(String pid) throws ServiceFailure, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SolrServerException, IOException, ParserConfigurationException, OREParserException {
|
640 |
|
Document resourceMapDoc = generateXmlDocument(DistributedMapsFactory.getDataObject(pid));
|
641 |
|
removeDataPackage(pid, resourceMapDoc);
|
|
632 |
private void removeDataPackage(String pid) throws XPathExpressionException, IOException,
|
|
633 |
SolrServerException, UnsupportedType, NotFound, ParserConfigurationException, SAXException {
|
|
634 |
removeFromIndex(pid);
|
|
635 |
List<SolrDoc> docsToUpdate = getUpdatedSolrDocsByRemovingResourceMap(pid);
|
|
636 |
if (docsToUpdate != null && !docsToUpdate.isEmpty()) {
|
|
637 |
//SolrElementAdd addCommand = new SolrElementAdd(docsToUpdate);
|
|
638 |
//httpService.sendUpdate(solrIndexUri, addCommand);
|
|
639 |
for(SolrDoc doc : docsToUpdate) {
|
|
640 |
removeFromIndex(doc.getIdentifier());
|
|
641 |
insertToIndex(doc);
|
|
642 |
}
|
|
643 |
}
|
|
644 |
|
642 |
645 |
}
|
643 |
|
|
|
646 |
|
644 |
647 |
/*
|
645 |
|
* Remove a data package for given pid. The content of package will be the byte array.
|
|
648 |
* Get the list of the solr doc which need to be updated because the removal of the resource map
|
646 |
649 |
*/
|
647 |
|
private void removeDataPackage(String pid, byte[] resourceMap) throws ServiceFailure, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SolrServerException, IOException, ParserConfigurationException, OREParserException{
|
648 |
|
Document resourceMapDoc = generateXmlDocument(new ByteArrayInputStream(resourceMap));
|
649 |
|
removeDataPackage(pid, resourceMapDoc);
|
|
650 |
private List<SolrDoc> getUpdatedSolrDocsByRemovingResourceMap(String resourceMapId)
|
|
651 |
throws UnsupportedType, NotFound, SolrServerException, ParserConfigurationException, SAXException, MalformedURLException, IOException, XPathExpressionException {
|
|
652 |
List<SolrDoc> updatedSolrDocs = null;
|
|
653 |
if (resourceMapId != null && !resourceMapId.trim().equals("")) {
|
|
654 |
/*List<SolrDoc> docsContainResourceMap = httpService.getDocumentsByResourceMap(
|
|
655 |
solrQueryUri, resourceMapId);*/
|
|
656 |
List<SolrDoc> docsContainResourceMap = ResourceMapSubprocessor.getDocumentsByResourceMap(resourceMapId);
|
|
657 |
updatedSolrDocs = removeResourceMapRelationship(docsContainResourceMap,
|
|
658 |
resourceMapId);
|
|
659 |
}
|
|
660 |
return updatedSolrDocs;
|
650 |
661 |
}
|
|
662 |
|
|
663 |
/*
|
|
664 |
* Get the list of the solr doc which need to be updated because the removal of the resource map
|
|
665 |
*/
|
|
666 |
private List<SolrDoc> removeResourceMapRelationship(List<SolrDoc> docsContainResourceMap,
|
|
667 |
String resourceMapId) throws XPathExpressionException, IOException {
|
|
668 |
List<SolrDoc> totalUpdatedSolrDocs = new ArrayList<SolrDoc>();
|
|
669 |
if (docsContainResourceMap != null && !docsContainResourceMap.isEmpty()) {
|
|
670 |
for (SolrDoc doc : docsContainResourceMap) {
|
|
671 |
List<SolrDoc> updatedSolrDocs = new ArrayList<SolrDoc>();
|
|
672 |
List<String> resourceMapIdStrs = doc
|
|
673 |
.getAllFieldValues(SolrElementField.FIELD_RESOURCEMAP);
|
|
674 |
List<String> dataIdStrs = doc
|
|
675 |
.getAllFieldValues(SolrElementField.FIELD_DOCUMENTS);
|
|
676 |
List<String> metadataIdStrs = doc
|
|
677 |
.getAllFieldValues(SolrElementField.FIELD_ISDOCUMENTEDBY);
|
|
678 |
if ((dataIdStrs == null || dataIdStrs.isEmpty())
|
|
679 |
&& (metadataIdStrs == null || metadataIdStrs.isEmpty())) {
|
|
680 |
// only has resourceMap field, doesn't have either documentBy or documents fields.
|
|
681 |
// so we only remove the resource map field.
|
|
682 |
doc.removeFieldsWithValue(SolrElementField.FIELD_RESOURCEMAP, resourceMapId);
|
|
683 |
updatedSolrDocs.add(doc);
|
|
684 |
} else if ((dataIdStrs != null && !dataIdStrs.isEmpty())
|
|
685 |
&& (metadataIdStrs == null || metadataIdStrs.isEmpty())) {
|
|
686 |
//The solr doc is for a metadata object since the solr doc documents data files
|
|
687 |
updatedSolrDocs = removeAggregatedItems(resourceMapId, doc, resourceMapIdStrs,
|
|
688 |
dataIdStrs, SolrElementField.FIELD_DOCUMENTS);
|
|
689 |
} else if ((dataIdStrs == null || dataIdStrs.isEmpty())
|
|
690 |
&& (metadataIdStrs != null && !metadataIdStrs.isEmpty())) {
|
|
691 |
//The solr doc is for a data object since it documentedBy elements.
|
|
692 |
updatedSolrDocs = removeAggregatedItems(resourceMapId, doc, resourceMapIdStrs,
|
|
693 |
metadataIdStrs, SolrElementField.FIELD_ISDOCUMENTEDBY);
|
|
694 |
} else if ((dataIdStrs != null && !dataIdStrs.isEmpty())
|
|
695 |
&& (metadataIdStrs != null && !metadataIdStrs.isEmpty())){
|
|
696 |
// both metadata and data for one object
|
|
697 |
List<SolrDoc> solrDocsRemovedDocuments = removeAggregatedItems(resourceMapId, doc, resourceMapIdStrs,
|
|
698 |
dataIdStrs, SolrElementField.FIELD_DOCUMENTS);
|
|
699 |
List<SolrDoc> solrDocsRemovedDocumentBy = removeAggregatedItems(resourceMapId, doc, resourceMapIdStrs,
|
|
700 |
metadataIdStrs, SolrElementField.FIELD_ISDOCUMENTEDBY);
|
|
701 |
updatedSolrDocs = mergeUpdatedSolrDocs(solrDocsRemovedDocumentBy, solrDocsRemovedDocuments);
|
|
702 |
}
|
|
703 |
//move them to the final result
|
|
704 |
if(updatedSolrDocs != null) {
|
|
705 |
for(SolrDoc updatedDoc: updatedSolrDocs) {
|
|
706 |
totalUpdatedSolrDocs.add(updatedDoc);
|
|
707 |
}
|
|
708 |
}
|
|
709 |
|
|
710 |
}
|
|
711 |
|
|
712 |
}
|
|
713 |
return totalUpdatedSolrDocs;
|
|
714 |
}
|
651 |
715 |
|
652 |
716 |
/*
|
653 |
|
* Remove a resource map pid
|
|
717 |
* Process the list of ids of the documentBy/documents in a slor doc.
|
654 |
718 |
*/
|
655 |
|
private void removeDataPackage(String pid,Document resourceMapDoc) throws ServiceFailure, SAXException, XPathExpressionException, NotImplemented, NotFound, UnsupportedType, SolrServerException, IOException, ParserConfigurationException, OREParserException {
|
656 |
|
|
657 |
|
//ResourceMap resourceMap = new ResourceMap(resourceMapDoc);
|
658 |
|
ResourceMap resourceMap = ResourceMapFactory.buildResourceMap(resourceMapDoc);
|
659 |
|
List<String> documentIds = resourceMap.getAllDocumentIDs();
|
660 |
|
List<SolrDoc> indexDocuments =ResourceMapSubprocessor.getSolrDocs(documentIds);
|
661 |
|
removeFromIndex(pid);
|
662 |
|
//List<SolrDoc> docsToUpdate = new ArrayList<SolrDoc>();
|
663 |
|
// for each document in data package:
|
664 |
|
for (SolrDoc indexDoc : indexDocuments) {
|
|
719 |
private List<SolrDoc> removeAggregatedItems(String targetResourceMapId, SolrDoc doc,
|
|
720 |
List<String> resourceMapIdsInDoc, List<String> aggregatedItemsInDoc, String fieldNameRemoved) {
|
|
721 |
List<SolrDoc> updatedSolrDocs = new ArrayList<SolrDoc>();
|
|
722 |
if (doc != null && resourceMapIdsInDoc != null && aggregatedItemsInDoc != null
|
|
723 |
&& fieldNameRemoved != null) {
|
|
724 |
if (resourceMapIdsInDoc.size() == 1) {
|
|
725 |
//only has one resource map. remove the resource map. also remove the documentBy
|
|
726 |
doc.removeFieldsWithValue(SolrElementField.FIELD_RESOURCEMAP, targetResourceMapId);
|
|
727 |
doc.removeAllFields(fieldNameRemoved);
|
|
728 |
updatedSolrDocs.add(doc);
|
|
729 |
} else if (resourceMapIdsInDoc.size() > 1) {
|
|
730 |
//we have multiple resource maps. We should match them.
|
|
731 |
Map<String, String> ids = matchResourceMapsAndItems(doc.getIdentifier(),
|
|
732 |
targetResourceMapId, resourceMapIdsInDoc, aggregatedItemsInDoc, fieldNameRemoved);
|
|
733 |
if (ids != null) {
|
|
734 |
for (String id : ids.keySet()) {
|
|
735 |
doc.removeFieldsWithValue(fieldNameRemoved, id);
|
|
736 |
}
|
|
737 |
}
|
|
738 |
doc.removeFieldsWithValue(SolrElementField.FIELD_RESOURCEMAP,
|
|
739 |
targetResourceMapId);
|
|
740 |
updatedSolrDocs.add(doc);
|
|
741 |
/*if (aggregatedItemsInDoc.size() > 1) {
|
|
742 |
|
665 |
743 |
|
666 |
|
if (indexDoc.getIdentifier().equals(pid)) {
|
667 |
|
continue; // skipping the resource map, no need update
|
668 |
|
// it.
|
669 |
|
// will
|
670 |
|
// be removed.
|
|
744 |
} else {
|
|
745 |
//multiple resource map aggregate same metadata and data. Just remove the resource map
|
|
746 |
doc.removeFieldsWithValue(SolrElementField.FIELD_RESOURCEMAP,
|
|
747 |
targetResourceMapId);
|
|
748 |
updatedSolrDocs.add(doc);
|
|
749 |
}*/
|
671 |
750 |
}
|
|
751 |
}
|
|
752 |
return updatedSolrDocs;
|
|
753 |
}
|
672 |
754 |
|
673 |
|
// Remove resourceMap reference
|
674 |
|
indexDoc.removeFieldsWithValue(SolrElementField.FIELD_RESOURCEMAP,
|
675 |
|
resourceMap.getIdentifier());
|
|
755 |
/*
|
|
756 |
* Return a map of mapping aggregation id map the target resourceMapId.
|
|
757 |
* This will look the aggregation information in another side - If the targetId
|
|
758 |
* is a metadata object, we will look the data objects which it describes; If
|
|
759 |
* the targetId is a data object, we will look the metadata object which documents it.
|
|
760 |
*/
|
|
761 |
private Map<String, String> matchResourceMapsAndItems(String targetId,
|
|
762 |
String targetResourceMapId, List<String> originalResourceMaps, List<String> aggregatedItems, String fieldName) {
|
|
763 |
Map<String, String> map = new HashMap<String, String>();
|
|
764 |
if (targetId != null && targetResourceMapId != null && aggregatedItems != null
|
|
765 |
&& fieldName != null) {
|
|
766 |
String newFieldName = null;
|
|
767 |
if (fieldName.equals(SolrElementField.FIELD_ISDOCUMENTEDBY)) {
|
|
768 |
newFieldName = SolrElementField.FIELD_DOCUMENTS;
|
|
769 |
} else if (fieldName.equals(SolrElementField.FIELD_DOCUMENTS)) {
|
|
770 |
newFieldName = SolrElementField.FIELD_ISDOCUMENTEDBY;
|
|
771 |
}
|
|
772 |
if (newFieldName != null) {
|
|
773 |
for (String item : aggregatedItems) {
|
|
774 |
SolrDoc doc = null;
|
|
775 |
try {
|
|
776 |
doc = getDocumentById(item);
|
|
777 |
List<String> fieldValues = doc.getAllFieldValues(newFieldName);
|
|
778 |
List<String> resourceMapIds = doc
|
|
779 |
.getAllFieldValues(SolrElementField.FIELD_RESOURCEMAP);
|
|
780 |
if ((fieldValues != null && fieldValues.contains(targetId))
|
|
781 |
&& (resourceMapIds != null && resourceMapIds
|
|
782 |
.contains(targetResourceMapId))) {
|
|
783 |
//okay, we found the target aggregation item id and the resource map id
|
|
784 |
//in this solr doc. However, we need check if another resource map with different
|
|
785 |
//id but specify the same relationship. If we have the id(s), we should not
|
|
786 |
// remove the documents( or documentBy) element since we need to preserve the
|
|
787 |
// relationship for the remain resource map.
|
|
788 |
boolean hasDuplicateIds = false;
|
|
789 |
if(originalResourceMaps != null) {
|
|
790 |
for(String id :resourceMapIds) {
|
|
791 |
if (originalResourceMaps.contains(id) && !id.equals(targetResourceMapId)) {
|
|
792 |
hasDuplicateIds = true;
|
|
793 |
break;
|
|
794 |
}
|
|
795 |
}
|
|
796 |
}
|
|
797 |
if(!hasDuplicateIds) {
|
|
798 |
map.put(item, targetResourceMapId);
|
|
799 |
}
|
|
800 |
|
|
801 |
}
|
|
802 |
} catch (Exception e) {
|
|
803 |
log.warn("SolrIndex.matchResourceMapsAndItems - can't get the solrdoc for the id "
|
|
804 |
+ item + " since " + e.getMessage());
|
|
805 |
}
|
|
806 |
}
|
|
807 |
}
|
|
808 |
}
|
|
809 |
return map;
|
|
810 |
}
|
676 |
811 |
|
677 |
|
// // Remove documents/documentedby values for this resource
|
678 |
|
// map
|
679 |
|
for (ResourceEntry entry : resourceMap.getMappedReferences()) {
|
680 |
|
if (indexDoc.getIdentifier().equals(entry.getIdentifier())) {
|
681 |
|
for (String documentedBy : entry.getDocumentedBy()) {
|
682 |
|
// Using removeOneFieldWithValue in-case same
|
683 |
|
// documents
|
684 |
|
// are in more than one data package. just
|
685 |
|
// remove
|
686 |
|
// one
|
687 |
|
// instance of data package info.
|
688 |
|
indexDoc.removeOneFieldWithValue(SolrElementField.FIELD_ISDOCUMENTEDBY,
|
689 |
|
documentedBy);
|
|
812 |
/*
|
|
813 |
* Get the solr index doc from the index server for the given id.
|
|
814 |
*/
|
|
815 |
private SolrDoc getDocumentById(String id) throws NotImplemented, NotFound, UnsupportedType,
|
|
816 |
SolrServerException, ParserConfigurationException, SAXException, XPathExpressionException, IOException {
|
|
817 |
SolrDoc doc = ResourceMapSubprocessor.getSolrDoc(id);
|
|
818 |
return doc;
|
|
819 |
}
|
|
820 |
|
|
821 |
/*
|
|
822 |
* Merge two list of updated solr docs. removedDocumentBy has the correct information about documentBy element.
|
|
823 |
* removedDocuments has the correct information about the documents element.
|
|
824 |
* So we go through the two list and found the two docs having the same identifier.
|
|
825 |
* Get the list of the documents value from the one in the removedDoucments (1).
|
|
826 |
* Remove all values of documents from the one in the removedDocumentBy.
|
|
827 |
* Then copy the list of documents value from (1) to to the one in the removedDocumentBy.
|
|
828 |
*/
|
|
829 |
private List<SolrDoc> mergeUpdatedSolrDocs(List<SolrDoc>removedDocumentBy, List<SolrDoc>removedDocuments) {
|
|
830 |
List<SolrDoc> mergedDocuments = new ArrayList<SolrDoc>();
|
|
831 |
if(removedDocumentBy == null || removedDocumentBy.isEmpty()) {
|
|
832 |
mergedDocuments = removedDocuments;
|
|
833 |
} else if (removedDocuments == null || removedDocuments.isEmpty()) {
|
|
834 |
mergedDocuments = removedDocumentBy;
|
|
835 |
} else {
|
|
836 |
int sizeOfDocBy = removedDocumentBy.size();
|
|
837 |
int sizeOfDocs = removedDocuments.size();
|
|
838 |
for(int i=sizeOfDocBy-1; i>= 0; i--) {
|
|
839 |
SolrDoc docInRemovedDocBy = removedDocumentBy.get(i);
|
|
840 |
for(int j= sizeOfDocs-1; j>=0; j--) {
|
|
841 |
SolrDoc docInRemovedDocs = removedDocuments.get(j);
|
|
842 |
if(docInRemovedDocBy.getIdentifier().equals(docInRemovedDocs.getIdentifier())) {
|
|
843 |
//find the same doc in both list. let's merge them.
|
|
844 |
//first get all the documents element from the docWithDocs(it has the correct information about the documents element)
|
|
845 |
List<String> idsInDocuments = docInRemovedDocs.getAllFieldValues(SolrElementField.FIELD_DOCUMENTS);
|
|
846 |
docInRemovedDocBy.removeAllFields(SolrElementField.FIELD_DOCUMENTS);//clear out any documents element in docInRemovedDocBy
|
|
847 |
//add the Documents element from the docInRemovedDocs if it has any.
|
|
848 |
// The docInRemovedDocs has the correct information about the documentBy. Now it copied the correct information of the documents element.
|
|
849 |
// So docInRemovedDocs has both correct information about the documentBy and documents elements.
|
|
850 |
if(idsInDocuments != null) {
|
|
851 |
for(String id : idsInDocuments) {
|
|
852 |
if(id != null && !id.trim().equals("")) {
|
|
853 |
docInRemovedDocBy.addField(new SolrElementField(SolrElementField.FIELD_DOCUMENTS, id));
|
|
854 |
}
|
|
855 |
|
|
856 |
}
|
|
857 |
}
|
|
858 |
//intersect the resource map ids.
|
|
859 |
List<String> resourceMapIdsInWithDocs = docInRemovedDocs.getAllFieldValues(SolrElementField.FIELD_RESOURCEMAP);
|
|
860 |
List<String> resourceMapIdsInWithDocBy = docInRemovedDocBy.getAllFieldValues(SolrElementField.FIELD_RESOURCEMAP);
|
|
861 |
docInRemovedDocBy.removeAllFields(SolrElementField.FIELD_RESOURCEMAP);
|
|
862 |
Collection resourceMapIds = CollectionUtils.union(resourceMapIdsInWithDocs, resourceMapIdsInWithDocBy);
|
|
863 |
if(resourceMapIds != null) {
|
|
864 |
for(Object idObj : resourceMapIds) {
|
|
865 |
String id = (String)idObj;
|
|
866 |
docInRemovedDocBy.addField(new SolrElementField(SolrElementField.FIELD_RESOURCEMAP, id));
|
|
867 |
}
|
|
868 |
}
|
|
869 |
//we don't need do anything about the documentBy elements since the docInRemovedDocBy has the correct information.
|
|
870 |
mergedDocuments.add(docInRemovedDocBy);
|
|
871 |
//delete the two documents from the list
|
|
872 |
removedDocumentBy.remove(i);
|
|
873 |
removedDocuments.remove(j);
|
|
874 |
break;
|
690 |
875 |
}
|
691 |
|
for (String documents : entry.getDocuments()) {
|
692 |
|
indexDoc.removeOneFieldWithValue(SolrElementField.FIELD_DOCUMENTS,
|
693 |
|
documents);
|
694 |
|
}
|
695 |
|
break;
|
|
876 |
|
696 |
877 |
}
|
697 |
878 |
}
|
698 |
|
removeFromIndex(indexDoc.getIdentifier());
|
699 |
|
insertToIndex(indexDoc);
|
700 |
|
//docsToUpdate.add(indexDoc);
|
|
879 |
// when we get there, if the two lists are empty, this will be a perfect merge. However, if something are left. we
|
|
880 |
//just put them in.
|
|
881 |
for(SolrDoc doc: removedDocumentBy) {
|
|
882 |
mergedDocuments.add(doc);
|
|
883 |
}
|
|
884 |
for(SolrDoc doc: removedDocuments) {
|
|
885 |
mergedDocuments.add(doc);
|
|
886 |
}
|
701 |
887 |
}
|
702 |
|
//SolrElementAdd addCommand = new SolrElementAdd(docsToUpdate);
|
703 |
|
//httpService.sendUpdate(solrIndexUri, addCommand);
|
|
888 |
return mergedDocuments;
|
704 |
889 |
}
|
|
890 |
|
705 |
891 |
|
706 |
892 |
/*
|
707 |
893 |
* Remove a pid which is part of resource map.
|
when we remove a slor index of a resource map, we don't need to know the content of the resource map. Instead, we will search the solr index to get information.