private Maybe <QueryPlan> BuildNoSquadEntityProjectContextPlan(QueryData data, DocumentIndexTypeToken project, DocumentIndexTypeToken entityType)
        {
            var projectContextPlan = BuildProjectContextPlan(data.ProjectIds, data.IncludeNoProject, project);

            if (!projectContextPlan.HasValue)
            {
                return(Maybe.Nothing);
            }
            string         noSquadEntityTypeIdsQuery = String.Join(" ", _entityTypeProvider.NoSquadEntityTypeNames);
            IDocumentIndex entityTypeIndex           = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext, entityType);
            QueryPlan      noSquadEntityPlan         = entityTypeIndex.BuildExecutionPlan(new ParsedQuery(words: noSquadEntityTypeIdsQuery), _profile.Initialized);

            return(Maybe.Return(QueryPlan.And(noSquadEntityPlan, projectContextPlan.Value)));
        }
        private static Maybe <QueryPlan> Op(Maybe <QueryPlan> left, Maybe <QueryPlan> right, Operation operation)
        {
            if (left.HasValue && right.HasValue)
            {
                switch (operation)
                {
                case Operation.And:
                    return(Maybe.Return(QueryPlan.And(left.Value, right.Value)));

                case Operation.Or:
                    return(Maybe.Return(QueryPlan.Or(left.Value, right.Value)));

                default:
                    throw new ArgumentException("{0} is not supported.".Fmt(operation));
                }
            }
            return(left.HasValue ? left : right);
        }
 private QueryPlan And(QueryPlan left, Maybe <QueryPlan> right)
 {
     return(right.HasValue ? QueryPlan.And(left, right.Value) : left);
 }