Class IsSubmittablePredicate

All Implemented Interfaces:
Matchable<ChangeData>

public class IsSubmittablePredicate extends BooleanPredicate
  • Constructor Details

    • IsSubmittablePredicate

      public IsSubmittablePredicate()
  • Method Details

    • rewrite

      public static Predicate<ChangeData> rewrite(Predicate<ChangeData> in)
      Rewrite the is:submittable predicate.

      If we run a query with "is:submittable OR -is:submittable" the result should match all changes. In Lucene, we keep separate sub-indexes for open and closed changes. The Lucene backend inspects the input predicate and depending on all its child predicates decides if the query should run against the open sub-index, closed sub-index or both.

      The "is:submittable" operator is implemented as:

      issubmittable:1

      But we want to exclude closed changes from being matched by this query. For the normal case, we rewrite the query as:

      issubmittable:1 AND status:new

      Hence Lucene will match the query against the open sub-index. For the negated case (i.e. "-is:submittable"), we cannot just negate the previous query because it would result in:

      -(issubmittable:1 AND status:new)

      Lucene will conclude that it should look for changes that are not new and hence will run the query against the closed sub-index, not matching with changes that are open but not submittable. For this case, we need to rewrite the query to match with closed changes or changes that are not submittable.