Skip to content

Commit

Permalink
Copy multivalued fields (#850)
Browse files Browse the repository at this point in the history
* Rebuild gem file lock

* Moved inversing the ark id logic to ursus solr-comfig.xml and removed deep copy from update-script.js
  • Loading branch information
pghorpade authored Sep 16, 2020
1 parent e5a020b commit 4cda04e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
13 changes: 7 additions & 6 deletions solr/config/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
<updateLog>
<str name="dir">${solr.ulog.dir:}</str>
</updateLog>

<!-- this is commented in production
<autoCommit>
<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
<openSearcher>false</openSearcher>
</autoCommit>

-->
<autoSoftCommit>
<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
</autoSoftCommit>
Expand Down Expand Up @@ -346,7 +346,7 @@
</lst>
-->
</searchComponent>

<!--
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
Expand All @@ -358,6 +358,7 @@
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
Expand All @@ -368,7 +369,7 @@
<str>suggest</str>
</arr>
</requestHandler>

-->
<requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler">
<lst name="defaults">
<str name="fmap.Last-Modified">last_modified</str>
Expand All @@ -384,7 +385,7 @@
</requestHandler>

<!-- For master replicaiton see https://lucene.apache.org/solr/guide/7_5/index-replication.html -->
<requestHandler name="/replication" class="solr.ReplicationHandler">
<!--<requestHandler name="/replication" class="solr.ReplicationHandler">
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="backupAfter">commit</str>
Expand All @@ -395,5 +396,5 @@
<lst name="invariants">
<str name="maxWriteMBPerSec">16</str>
</lst>
</requestHandler>
</requestHandler> -->
</config>
16 changes: 9 additions & 7 deletions solr/config/update-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ function processAdd(cmd) {
var SolrInputDocument = Java.type(
'org.apache.solr.common.SolrInputDocument'
);
solrDocUrsus = new SolrInputDocument();
/*solrDocUrsus = new SolrInputDocument();
solrDocUrsus.addField('id', doc.getFieldValue('ark_ssi'));
logger.info('update-script#processAdd: solrDocUrsus start=' + solrDocUrsus);
logger.info('update-script#processAdd: Set=' + doc.entrySet());
field_names = doc.getFieldNames().toArray();
for (i = 0; i < field_names.length; i++) {
field_name = field_names[i];
if (field_name != 'id') {
solrDocUrsus.addField(
field_names[i],
doc.getFieldValue(field_names[i])
);
Field1 = doc.getFieldValues(field_names[i]);
logger.info('Size : ' + Field1.size());
logger.info('field name: ' + field_names[i]);
for (j = 0; j < Field1.size(); j++) {
doc.addField(field_names[i], Field1.get(j));
}
}
}
logger.info(
'update-script#processAdd: solrDocUrsus finish=' + solrDocUrsus
);
);*/
var SolrClient = Java.type('org.apache.solr.client.solrj.SolrClient');
var HttpSolrClient = Java.type(
'org.apache.solr.client.solrj.impl.HttpSolrClient'
Expand All @@ -60,7 +62,7 @@ function processAdd(cmd) {
solrclient = new HttpSolrClient.Builder(urlString).build();
solrclient.setParser(new XMLResponseParser());
logger.info('update-script#processAdd: solrclient=' + solrclient);
solrclient.add(solrDocUrsus);
solrclient.add(doc);
solrclient.commit();
}

Expand Down
19 changes: 13 additions & 6 deletions solr/ursus/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
<updateLog>
<str name="dir">${solr.ulog.dir:}</str>
</updateLog>

<!--
<autoCommit>
<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
<openSearcher>false</openSearcher>
</autoCommit>

-->
<autoSoftCommit>
<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
</autoSoftCommit>
Expand Down Expand Up @@ -200,6 +200,13 @@
</requestHandler>

<updateRequestProcessorChain name="add_modify_fields" default="${update.autoCreateFields:true}">
<processor class="solr.CloneFieldUpdateProcessorFactory">
<str name="source">ark_ssi</str>
<str name="dest">id</str>
</processor>
<processor class="solr.LastFieldValueUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.ParseDateFieldUpdateProcessorFactory">
<arr name="format">
<str>yyyy-MM-dd'T'HH:mm:ss.SSSZ</str>
Expand Down Expand Up @@ -320,7 +327,7 @@
</lst>
-->
</searchComponent>

<!--
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
Expand All @@ -341,7 +348,7 @@
<str>suggest</str>
</arr>
</requestHandler>

-->
<requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler">
<lst name="defaults">
<str name="fmap.Last-Modified">last_modified</str>
Expand All @@ -357,7 +364,7 @@
</requestHandler>

<!-- For master replicaiton see https://lucene.apache.org/solr/guide/7_5/index-replication.html -->
<requestHandler name="/replication" class="solr.ReplicationHandler">
<!--<requestHandler name="/replication" class="solr.ReplicationHandler">
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="backupAfter">commit</str>
Expand All @@ -368,5 +375,5 @@
<lst name="invariants">
<str name="maxWriteMBPerSec">16</str>
</lst>
</requestHandler>
</requestHandler> -->
</config>

0 comments on commit 4cda04e

Please sign in to comment.