how to use multi-fields search for issues in REST api?
Added by Alex Last almost 6 years ago
hi guys!
someone submitted a feature request for Redmine Java library to support free-form search with multiple params like "f[]".
I added support for this, but I do not see any documentation on how to use that free-form search in Redmine REST API.
I have this integration test that fails because it returns more than 1 issue, which indicates that search terms I used result in "or" operation rather than expected "and". this test is in Java, but you can see the idea in it - the search part is not specific to any language, it is specific to Redmine only.
can someone please post a link to a page describing how to use free-form search for redmine objects (like "f[]", "op[..]=xyz", "and", "or", etc)?
/**
* regression test for https://github.com/taskadapter/redmine-java-api/issues/12 and
* https://github.com/taskadapter/redmine-java-api/issues/215
*/
public void issuesCanBeFoundByMultiQuerySearch() throws RedmineException {
final Issue issue1 = IssueFactory.create(projectId, "summary 1 here");
issue1.setDescription("abc description");
issueManager.createIssue(issue1);
final Issue issue2 = IssueFactory.create(projectId, "summary 2 here");
issue2.setDescription("def totally different description");
issueManager.createIssue(issue2);
final Issue issue3 = IssueFactory.create(projectId, "another");
issue3.setDescription("abc");
issueManager.createIssue(issue3);
Params params = new Params()
.add("set_filter", "1")
.add("f[]", "summary")
.add("op[summary]", "~")
.add("v[summary]", "another")
.add("f[]", "description")
.add("op[description]", "~")
.add("v[description][]", "abc");
final ResultsWrapper<Issue> list = issueManager.getIssues(params);
// only 1 issue must be found
assertThat(list.getResults()).hasSize(1);
}
Replies (1)
RE: how to use multi-fields search for issues in REST api?
-
Added by Alex Last almost 6 years ago
I found this combination of params to work:
public void issuesCanBeFoundByMultiQuerySearch() throws RedmineException {
final Issue issue1 = IssueFactory.create(projectId, "summary 1 here");
issueManager.createIssue(issue1);
final Issue issue2 = IssueFactory.create(projectId, "summary 2 here");
issueManager.createIssue(issue2);
final Issue issue3 = IssueFactory.create(projectId, "another");
issueManager.createIssue(issue3);
final User currentUser = userManager.getCurrentUser();
Params params = new Params()
.add("set_filter", "1")
.add("f[]", "subject")
.add("op[subject]", "~")
.add("v[subject][]", "another")
.add("f[]", "author_id")
.add("op[author_id]", "~")
.add("v[author_id][]", currentUser.getId()+"");
final ResultsWrapper<Issue> list = issueManager.getIssues(params);
// only 1 issue must be found
assertThat(list.getResults()).hasSize(1);
}
(1-1/1)