mirror of https://github.com/apache/lucene.git
SOLR-9979: Macro expansion should not be done in shard requests
This commit is contained in:
parent
57626c9a99
commit
68d246df00
|
@ -98,6 +98,8 @@ Bug Fixes
|
||||||
* SOLR-9977: Fix config bug in DistribDocExpirationUpdateProcessorTest that allowed false assumptions
|
* SOLR-9977: Fix config bug in DistribDocExpirationUpdateProcessorTest that allowed false assumptions
|
||||||
about when index version changes (hossman)
|
about when index version changes (hossman)
|
||||||
|
|
||||||
|
* SOLR-9979: Macro expansion should not be done in shard requests (Tomás Fernández Löbbe)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ public class RequestUtil {
|
||||||
newMap.putAll( MultiMapSolrParams.asMultiMap(invariants) );
|
newMap.putAll( MultiMapSolrParams.asMultiMap(invariants) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isShard) { // Don't expand macros in shard requests
|
||||||
String[] doMacrosStr = newMap.get("expandMacros");
|
String[] doMacrosStr = newMap.get("expandMacros");
|
||||||
boolean doMacros = true;
|
boolean doMacros = true;
|
||||||
if (doMacrosStr != null) {
|
if (doMacrosStr != null) {
|
||||||
|
@ -156,6 +157,7 @@ public class RequestUtil {
|
||||||
if (doMacros) {
|
if (doMacros) {
|
||||||
newMap = MacroExpander.expand(newMap);
|
newMap = MacroExpander.expand(newMap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Set these params as soon as possible so if there is an error processing later, things like
|
// Set these params as soon as possible so if there is an error processing later, things like
|
||||||
// "wt=json" will take effect from the defaults.
|
// "wt=json" will take effect from the defaults.
|
||||||
SolrParams newParams = new MultiMapSolrParams(newMap); // newMap may still change below, but that should be OK
|
SolrParams newParams = new MultiMapSolrParams(newMap); // newMap may still change below, but that should be OK
|
||||||
|
|
|
@ -84,6 +84,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
||||||
String tdate_b = "b_n_tdt";
|
String tdate_b = "b_n_tdt";
|
||||||
|
|
||||||
String oddField="oddField_s";
|
String oddField="oddField_s";
|
||||||
|
String s1="a_s";
|
||||||
String missingField="ignore_exception__missing_but_valid_field_t";
|
String missingField="ignore_exception__missing_but_valid_field_t";
|
||||||
String invalidField="ignore_exception__invalid_field_not_in_schema";
|
String invalidField="ignore_exception__invalid_field_not_in_schema";
|
||||||
|
|
||||||
|
@ -111,44 +112,49 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
||||||
"foo_sev_enum", "Medium",
|
"foo_sev_enum", "Medium",
|
||||||
tdate_a, "2010-04-20T11:00:00Z",
|
tdate_a, "2010-04-20T11:00:00Z",
|
||||||
tdate_b, "2009-08-20T11:00:00Z",
|
tdate_b, "2009-08-20T11:00:00Z",
|
||||||
"foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d);
|
"foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d,
|
||||||
|
s1, "z${foo}");
|
||||||
indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country.",
|
indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country.",
|
||||||
"foo_sev_enum", "Medium",
|
"foo_sev_enum", "Medium",
|
||||||
"foo_sev_enum", "High",
|
"foo_sev_enum", "High",
|
||||||
tdate_a, "2010-05-02T11:00:00Z",
|
tdate_a, "2010-05-02T11:00:00Z",
|
||||||
tdate_b, "2009-11-02T11:00:00Z");
|
tdate_b, "2009-11-02T11:00:00Z",
|
||||||
|
s1, "z${foo}");
|
||||||
indexr(id,3, i1, 2, tlong, 2,t1,"how now brown cow",
|
indexr(id,3, i1, 2, tlong, 2,t1,"how now brown cow",
|
||||||
tdate_a, "2010-05-03T11:00:00Z");
|
tdate_a, "2010-05-03T11:00:00Z",
|
||||||
|
s1, "z${foo}");
|
||||||
indexr(id,4, i1, -100 ,tlong, 101,
|
indexr(id,4, i1, -100 ,tlong, 101,
|
||||||
t1,"the quick fox jumped over the lazy dog",
|
t1,"the quick fox jumped over the lazy dog",
|
||||||
tdate_a, "2010-05-03T11:00:00Z",
|
tdate_a, "2010-05-03T11:00:00Z",
|
||||||
tdate_b, "2010-05-03T11:00:00Z");
|
tdate_b, "2010-05-03T11:00:00Z",
|
||||||
|
s1, "a");
|
||||||
indexr(id,5, i1, 500, tlong, 500 ,
|
indexr(id,5, i1, 500, tlong, 500 ,
|
||||||
t1,"the quick fox jumped way over the lazy dog",
|
t1,"the quick fox jumped way over the lazy dog",
|
||||||
tdate_a, "2010-05-05T11:00:00Z");
|
tdate_a, "2010-05-05T11:00:00Z",
|
||||||
indexr(id,6, i1, -600, tlong, 600 ,t1,"humpty dumpy sat on a wall");
|
s1, "b");
|
||||||
indexr(id,7, i1, 123, tlong, 123 ,t1,"humpty dumpy had a great fall");
|
indexr(id,6, i1, -600, tlong, 600 ,t1,"humpty dumpy sat on a wall", s1, "c");
|
||||||
|
indexr(id,7, i1, 123, tlong, 123 ,t1,"humpty dumpy had a great fall", s1, "d");
|
||||||
indexr(id,8, i1, 876, tlong, 876,
|
indexr(id,8, i1, 876, tlong, 876,
|
||||||
tdate_b, "2010-01-05T11:00:00Z",
|
tdate_b, "2010-01-05T11:00:00Z",
|
||||||
"foo_sev_enum", "High",
|
"foo_sev_enum", "High",
|
||||||
t1,"all the kings horses and all the kings men");
|
t1,"all the kings horses and all the kings men", s1, "e");
|
||||||
indexr(id,9, i1, 7, tlong, 7,t1,"couldn't put humpty together again");
|
indexr(id,9, i1, 7, tlong, 7,t1,"couldn't put humpty together again", s1, "f");
|
||||||
|
|
||||||
commit(); // try to ensure there's more than one segment
|
commit(); // try to ensure there's more than one segment
|
||||||
|
|
||||||
indexr(id,10, i1, 4321, tlong, 4321,t1,"this too shall pass");
|
indexr(id,10, i1, 4321, tlong, 4321,t1,"this too shall pass", s1, "g");
|
||||||
indexr(id,11, i1, -987, tlong, 987,
|
indexr(id,11, i1, -987, tlong, 987,
|
||||||
"foo_sev_enum", "Medium",
|
"foo_sev_enum", "Medium",
|
||||||
t1,"An eye for eye only ends up making the whole world blind.");
|
t1,"An eye for eye only ends up making the whole world blind.", s1, "h");
|
||||||
indexr(id,12, i1, 379, tlong, 379,
|
indexr(id,12, i1, 379, tlong, 379,
|
||||||
t1,"Great works are performed, not by strength, but by perseverance.");
|
t1,"Great works are performed, not by strength, but by perseverance.", s1, "i");
|
||||||
indexr(id,13, i1, 232, tlong, 232,
|
indexr(id,13, i1, 232, tlong, 232,
|
||||||
t1,"no eggs on wall, lesson learned",
|
t1,"no eggs on wall, lesson learned",
|
||||||
oddField, "odd man out");
|
oddField, "odd man out", s1, "j");
|
||||||
|
|
||||||
indexr(id, "1001", "lowerfilt", "toyota"); // for spellcheck
|
indexr(id, "1001", "lowerfilt", "toyota", s1, "k"); // for spellcheck
|
||||||
|
|
||||||
indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models", "mathematical analysis"});
|
indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models", "mathematical analysis"}, s1, "l");
|
||||||
indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
|
indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
|
||||||
indexr(id, 16, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
|
indexr(id, 16, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
|
||||||
String[] vals = new String[100];
|
String[] vals = new String[100];
|
||||||
|
@ -873,7 +879,13 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
||||||
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a b/c \\' \\} foo'}"+t1,"facet.limit",5, "facet.shard.limit",5);
|
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a b/c \\' \\} foo'}"+t1,"facet.limit",5, "facet.shard.limit",5);
|
||||||
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a'}"+t1,"facet.limit",5, "facet.shard.limit",5);
|
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a'}"+t1,"facet.limit",5, "facet.shard.limit",5);
|
||||||
handle.remove("facet_fields");
|
handle.remove("facet_fields");
|
||||||
|
// Make sure there is no macro expansion for field values
|
||||||
|
query("q","*:*", "rows",0, "facet","true", "facet.field",s1,"facet.limit",5, "facet.shard.limit",5);
|
||||||
|
query("q","*:*", "rows",0, "facet","true", "facet.field",s1,"facet.limit",5, "facet.shard.limit",5, "expandMacros", "true");
|
||||||
|
query("q","*:*", "rows",0, "facet","true", "facet.field",s1,"facet.limit",5, "facet.shard.limit",5, "expandMacros", "false");
|
||||||
|
// Macro expansion should still work for the parameters
|
||||||
|
query("q","*:*", "rows",0, "facet","true", "facet.field","${foo}", "f.${foo}.mincount", 1, "foo", s1);
|
||||||
|
query("q","*:*", "rows",0, "facet","true", "facet.field","${foo}", "f.${foo}.mincount", 1, "foo", s1, "expandMacros", "true");
|
||||||
|
|
||||||
// index the same document to two servers and make sure things
|
// index the same document to two servers and make sure things
|
||||||
// don't blow up.
|
// don't blow up.
|
||||||
|
|
Loading…
Reference in New Issue