mirror of https://github.com/apache/lucene.git
SOLR-14090: fix delete-copy-field when source is dynamic field
This commit is contained in:
parent
5a3a05d953
commit
358043d1f3
|
@ -179,6 +179,8 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-14239: Fix the behavior of CaffeineCache.computeIfAbsent on branch_8x. (ab)
|
* SOLR-14239: Fix the behavior of CaffeineCache.computeIfAbsent on branch_8x. (ab)
|
||||||
|
|
||||||
|
* SOLR-14090: Handle the case in `delete-copy-field` when source is a dynamic field (Frank Iversen, Munendra S N)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -860,7 +860,11 @@ public final class ManagedIndexSchema extends IndexSchema {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // non-dynamic copy field directive
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
// non-dynamic copy field directive.
|
||||||
|
// Here, source field could either exists in schema or match a dynamic rule
|
||||||
List<CopyField> copyFieldList = copyFieldsMap.get(source);
|
List<CopyField> copyFieldList = copyFieldsMap.get(source);
|
||||||
if (copyFieldList != null) {
|
if (copyFieldList != null) {
|
||||||
for (Iterator<CopyField> iter = copyFieldList.iterator() ; iter.hasNext() ; ) {
|
for (Iterator<CopyField> iter = copyFieldList.iterator() ; iter.hasNext() ; ) {
|
||||||
|
|
|
@ -619,7 +619,77 @@ public class TestBulkSchemaAPI extends RestTestBase {
|
||||||
assertNotNull("'attr_*' dynamic field does not exist in the schema", m);
|
assertNotNull("'attr_*' dynamic field does not exist in the schema", m);
|
||||||
assertEquals("string", m.get("type"));
|
assertEquals("string", m.get("type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCopyFieldRules() throws Exception {
|
||||||
|
RestTestHarness harness = restTestHarness;
|
||||||
|
|
||||||
|
Map m = getObj(harness, "name", "fields");
|
||||||
|
assertNotNull("'name' field does not exist in the schema", m);
|
||||||
|
|
||||||
|
m = getObj(harness, "bind", "fields");
|
||||||
|
assertNotNull("'bind' field does not exist in the schema", m);
|
||||||
|
|
||||||
|
List l = getSourceCopyFields(harness, "bleh_s");
|
||||||
|
assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty());
|
||||||
|
|
||||||
|
String payload = "{\n" +
|
||||||
|
" 'add-copy-field' : {\n" +
|
||||||
|
" 'source' :'bleh_s',\n" +
|
||||||
|
" 'dest':'name'\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n";
|
||||||
|
String response = harness.post("/schema", json(payload));
|
||||||
|
|
||||||
|
Map map = (Map) fromJSONString(response);
|
||||||
|
assertNull(response, map.get("error"));
|
||||||
|
|
||||||
|
l = getSourceCopyFields(harness, "bleh_s");
|
||||||
|
assertFalse("'bleh_s' copyField rule doesn't exist", l.isEmpty());
|
||||||
|
assertEquals("bleh_s", ((Map)l.get(0)).get("source"));
|
||||||
|
assertEquals("name", ((Map)l.get(0)).get("dest"));
|
||||||
|
|
||||||
|
// delete copy field rule
|
||||||
|
payload = "{\n" +
|
||||||
|
" 'delete-copy-field' : {\n" +
|
||||||
|
" 'source' :'bleh_s',\n" +
|
||||||
|
" 'dest':'name'\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n";
|
||||||
|
|
||||||
|
response = harness.post("/schema", json(payload));
|
||||||
|
map = (Map) fromJSONString(response);
|
||||||
|
assertNull(response, map.get("error"));
|
||||||
|
l = getSourceCopyFields(harness, "bleh_s");
|
||||||
|
assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty());
|
||||||
|
|
||||||
|
// copy and delete with multiple destination
|
||||||
|
payload = "{\n" +
|
||||||
|
" 'add-copy-field' : {\n" +
|
||||||
|
" 'source' :'bleh_s',\n" +
|
||||||
|
" 'dest':['name','bind']\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n";
|
||||||
|
response = harness.post("/schema", json(payload));
|
||||||
|
map = (Map) fromJSONString(response);
|
||||||
|
assertNull(response, map.get("error"));
|
||||||
|
|
||||||
|
l = getSourceCopyFields(harness, "bleh_s");
|
||||||
|
assertEquals(2, l.size());
|
||||||
|
|
||||||
|
payload = "{\n" +
|
||||||
|
" 'delete-copy-field' : {\n" +
|
||||||
|
" 'source' :'bleh_s',\n" +
|
||||||
|
" 'dest':['name','bind']\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n";
|
||||||
|
|
||||||
|
response = harness.post("/schema", json(payload));
|
||||||
|
map = (Map) fromJSONString(response);
|
||||||
|
assertNull(response, map.get("error"));
|
||||||
|
l = getSourceCopyFields(harness, "bleh_s");
|
||||||
|
assertTrue("'bleh_s' copyField rule exists in the schema", l.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeleteAndReplace() throws Exception {
|
public void testDeleteAndReplace() throws Exception {
|
||||||
RestTestHarness harness = restTestHarness;
|
RestTestHarness harness = restTestHarness;
|
||||||
|
|
||||||
|
@ -848,6 +918,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
|
||||||
map = (Map) fromJSONString(response);
|
map = (Map) fromJSONString(response);
|
||||||
assertNull(map.get("error"));
|
assertNull(map.get("error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSortableTextFieldWithAnalyzer() throws Exception {
|
public void testSortableTextFieldWithAnalyzer() throws Exception {
|
||||||
String fieldTypeName = "sort_text_type";
|
String fieldTypeName = "sort_text_type";
|
||||||
String fieldName = "sort_text";
|
String fieldName = "sort_text";
|
||||||
|
@ -902,7 +973,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddNewFieldAndQuery() throws Exception {
|
public void testAddNewFieldAndQuery() throws Exception {
|
||||||
getSolrClient().add(Arrays.asList(
|
getSolrClient().add(Arrays.asList(
|
||||||
|
@ -920,7 +991,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
|
||||||
int size = getSolrClient().query(query).getResults().size();
|
int size = getSolrClient().query(query).getResults().size();
|
||||||
assertEquals(1, size);
|
assertEquals(1, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimilarityParser() throws Exception {
|
public void testSimilarityParser() throws Exception {
|
||||||
RestTestHarness harness = restTestHarness;
|
RestTestHarness harness = restTestHarness;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue