private static BooleanQuery GetCombinedTermAndSplitQuery(string prefix, IEnumerable<Query> upperSplitQuery, Range currentPart)
 {
     var upperRangeQuery = new BooleanQuery();
     upperRangeQuery.AddTermQuery(currentPart.Name(prefix), currentPart.Value(currentPart.End));
     upperRangeQuery.AddClause(upperSplitQuery.First());
     return upperRangeQuery;
 }
        private static IEnumerable<Query> GetQuery(IEnumerable<Range> parts, string prefix)
        {
            var currentPart = parts.First();
            var remainingParts = parts.Skip(1);

            if (currentPart.IsRange)
            {
                var splitQueries = Split(parts, prefix);
                if (splitQueries.Any())
                {
                    var query = new BooleanQuery();
                    query.AddClause(splitQueries.First());
                    yield return query;
                }
            }
            else
            {
                var query = new BooleanQuery();
                query.AddTermQuery(currentPart.Name(prefix), currentPart.Value(currentPart.Start));

                if (remainingParts.Any())
                {
                    foreach (var childQuery in GetQuery(remainingParts, prefix))
                    {
                        query.AddClause(childQuery);
                    }
                }

                yield return query;
            }
        }