-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SolrRequest.getParams never null; and clarify mutability #3140
base: main
Are you sure you want to change the base?
Changes from 2 commits
bfdec90
04eac02
e428006
010ae6f
44a83b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,11 +625,8 @@ protected long addDocAndGetVersion(Object... fields) throws Exception { | |
SolrInputDocument doc = new SolrInputDocument(); | ||
addFields(doc, fields); | ||
|
||
ModifiableSolrParams params = new ModifiableSolrParams(); | ||
params.add("versions", "true"); | ||
|
||
UpdateRequest ureq = new UpdateRequest(); | ||
ureq.setParams(params); | ||
ureq.getParams().set("versions", true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a clear mutability story, the requirement here is now easy with this one-liner. (same elsewhere) |
||
ureq.add(doc); | ||
UpdateResponse resp; | ||
|
||
|
@@ -647,10 +644,10 @@ protected long addDocAndGetVersion(Object... fields) throws Exception { | |
|
||
protected long deleteDocAndGetVersion( | ||
String id, ModifiableSolrParams params, boolean deleteByQuery) throws Exception { | ||
params.add("versions", "true"); | ||
|
||
UpdateRequest ureq = new UpdateRequest(); | ||
ureq.setParams(params); | ||
ureq.getParams().add(params); | ||
Comment on lines
-653
to
+648
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose to call |
||
ureq.getParams().set("versions", true); | ||
|
||
if (deleteByQuery) { | ||
ureq.deleteByQuery("id:" + id); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,15 @@ public void after() throws Exception { | |
|
||
public void testSimple() throws Exception { | ||
|
||
ModifiableSolrParams params = | ||
new ModifiableSolrParams() | ||
.add("processor", "template") | ||
.add("template.field", "id:{firstName}_{lastName}") | ||
.add("template.field", "another:{lastName}_{firstName}") | ||
.add("template.field", "missing:{lastName}_{unKnown}"); | ||
AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(null, params)); | ||
var cmd = | ||
new AddUpdateCommand( | ||
new LocalSolrQueryRequest( | ||
null, | ||
new ModifiableSolrParams() | ||
.add("processor", "template") | ||
.add("template.field", "id:{firstName}_{lastName}") | ||
.add("template.field", "another:{lastName}_{firstName}") | ||
.add("template.field", "missing:{lastName}_{unKnown}"))); | ||
|
||
cmd.solrDoc = new SolrInputDocument(); | ||
cmd.solrDoc.addField("firstName", "Tom"); | ||
|
@@ -69,14 +71,11 @@ public void testSimple() throws Exception { | |
SolrInputDocument solrDoc = new SolrInputDocument(); | ||
solrDoc.addField("id", "1"); | ||
|
||
params = | ||
new ModifiableSolrParams() | ||
.add("processor", "template") | ||
.add("commit", "true") | ||
.add("template.field", "x_s:key_{id}"); | ||
params.add("commit", "true"); | ||
UpdateRequest add = new UpdateRequest().add(solrDoc); | ||
add.setParams(params); | ||
add.getParams() | ||
.add("processor", "template") | ||
.add("template.field", "x_s:key_{id}") | ||
.add("commit", "true"); | ||
Comment on lines
+75
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so nice IMO |
||
NamedList<Object> result = | ||
cluster | ||
.getSolrClient() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was clearly a hack to work around it's weird mutability situation. Now not needed here and elsewhere.