mirror of https://github.com/apache/lucene.git
SOLR-12015: Add support "add-distinct" in AtomicURP so that we can use the 'add-distict' as a request parameter e.g: atomic.add-distict=<multival-field-name>
This commit is contained in:
parent
ea12b5fd22
commit
e340cef68d
|
@ -58,6 +58,9 @@ New Features
|
|||
* SOLR-11670: Implement a periodic house-keeping task. This uses a scheduled autoscaling trigger and
|
||||
currently performs cleanup of old inactive shards. (ab, shalin)
|
||||
|
||||
* SOLR-12015: Add support "add-distinct" in AtomicURP so that we can use the 'add-distict' as a request parameter e.g:
|
||||
atomic.add-distict=<multival-field-name> (Amrit Sarkar via noble)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.update.processor;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
|
@ -40,6 +37,9 @@ import org.apache.solr.util.plugin.SolrCoreAware;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
|
||||
|
||||
/**
|
||||
* An update processor that will convert conventional field-value document to atomic update document
|
||||
* <p>
|
||||
|
@ -59,7 +59,8 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactory
|
|||
private final static String REMOVE = "remove";
|
||||
private final static String SET = "set";
|
||||
private final static String REMOVEREGEX = "removeregex";
|
||||
private final static Set<String> VALID_OPS = new HashSet<>(Arrays.asList(ADD, INC, REMOVE, SET, REMOVEREGEX));
|
||||
private final static String ADDDISTINCT = "add-distinct";
|
||||
private final static Set<String> VALID_OPS = new HashSet<>(Arrays.asList(ADD, INC, REMOVE, SET, REMOVEREGEX, ADDDISTINCT));
|
||||
|
||||
private final static String VERSION = "_version_";
|
||||
public static final String NAME = "atomic";
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.update.processor;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
|
@ -136,7 +137,7 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
|
|||
|
||||
params = new ModifiableSolrParams()
|
||||
.add("processor", "atomic")
|
||||
.add("atomic.cat", "add")
|
||||
.add("atomic.cat", "add-distinct")
|
||||
.add("atomic.title", "set")
|
||||
.add("atomic.count_i", "inc")
|
||||
.add("atomic.name_s", "remove")
|
||||
|
@ -146,7 +147,7 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
|
|||
|
||||
cmd.solrDoc = new SolrInputDocument();
|
||||
cmd.solrDoc.addField("id", 1);
|
||||
cmd.solrDoc.addField("cat", "animal");
|
||||
cmd.solrDoc.addField("cat", Arrays.asList(new String[] {"human","human","animal","animal"}));
|
||||
cmd.solrDoc.addField("title", "Dr");
|
||||
cmd.solrDoc.addField("count_i", 20);
|
||||
cmd.solrDoc.addField("name_s", "Virat");
|
||||
|
@ -168,6 +169,9 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
|
|||
req("q", "cat:animal")
|
||||
, "//result[@numFound=1]");
|
||||
|
||||
assertQ(req("q", "id:1", "indent", "true"),
|
||||
"//doc/arr[@name='cat'][count(str)=2]");
|
||||
|
||||
assertQ("Check the total number of docs",
|
||||
req("q", "title:Mr")
|
||||
, "//result[@numFound=0]");
|
||||
|
|
Loading…
Reference in New Issue