Project index: Add parent predicate

Enabling the search by parent enables the rewrite
of the ListChildProjects REST-API that extracts the children
of a project. Using the Lucene index avoids the full scan
of the ProjectCache and thus speedup the extraction and
reduce the JVM heap consumption.

Bug: Issue 10401
Change-Id: I568d6ba0e5a0bff391f57e2357de6d059d77fe5d
This commit is contained in:
David Ostrovsky
2019-01-29 20:42:38 +01:00
committed by Luca Milanesio
parent ef655ff6a4
commit 30b0a80290
4 changed files with 48 additions and 0 deletions

View File

@@ -27,6 +27,10 @@ public class ProjectPredicates {
return new ProjectPredicate(ProjectField.NAME, nameKey.get());
}
public static Predicate<ProjectData> parent(Project.NameKey parentNameKey) {
return new ProjectPredicate(ProjectField.PARENT_NAME, parentNameKey.get());
}
public static Predicate<ProjectData> inname(String name) {
return new ProjectPredicate(ProjectField.NAME_PART, name.toLowerCase(Locale.US));
}

View File

@@ -44,6 +44,11 @@ public class ProjectQueryBuilder extends QueryBuilder<ProjectData> {
return ProjectPredicates.name(new Project.NameKey(name));
}
@Operator
public Predicate<ProjectData> parent(String parentName) {
return ProjectPredicates.parent(new Project.NameKey(parentName));
}
@Operator
public Predicate<ProjectData> inname(String namePart) {
if (namePart.isEmpty()) {