Skip to content

Commit

Permalink
122485: write solr docs to file, only index items
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Vannerum committed Dec 30, 2024
1 parent c74855e commit 22c6fcd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import static org.dspace.discovery.indexobject.ItemIndexFactoryImpl.STATUS_FIELD;
import static org.dspace.discovery.indexobject.ItemIndexFactoryImpl.STATUS_FIELD_PREDB;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
Expand All @@ -32,6 +34,7 @@
import java.util.UUID;
import javax.mail.MessagingException;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.collections4.Transformer;
Expand Down Expand Up @@ -120,8 +123,14 @@ public class SolrServiceImpl implements SearchService, IndexingService {
@Autowired
protected ConfigurationService configurationService;

protected SolrServiceImpl() {
FileOutputStream out;

protected SolrServiceImpl() {
try {
out = new FileOutputStream("/Users/jensvannerum/Desktop/solr.json");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down Expand Up @@ -167,7 +176,8 @@ public void indexContent(Context context, IndexableObject indexableObject,
protected void update(Context context, IndexFactory indexableObjectService,
IndexableObject indexableObject) throws IOException, SQLException, SolrServerException {
final SolrInputDocument solrInputDocument = indexableObjectService.buildDocument(context, indexableObject);
indexableObjectService.writeDocument(context, indexableObject, solrInputDocument);
out.write(new ObjectMapper().writeValueAsBytes(solrInputDocument.toMap(new HashMap<>())));
out.write("\n".getBytes());
}

/**
Expand Down Expand Up @@ -333,7 +343,7 @@ public void updateIndex(Context context) {
*/
@Override
public void updateIndex(Context context, boolean force) {
updateIndex(context, force, null);
updateIndex(context, force, IndexableItem.TYPE);
}

@Override
Expand Down

0 comments on commit 22c6fcd

Please sign in to comment.