diff --git a/ErsatzTV.Infrastructure/Search/CustomMultiFieldQueryParser.cs b/ErsatzTV.Infrastructure/Search/CustomMultiFieldQueryParser.cs index 6c2122b9c..3130bf9c4 100644 --- a/ErsatzTV.Infrastructure/Search/CustomMultiFieldQueryParser.cs +++ b/ErsatzTV.Infrastructure/Search/CustomMultiFieldQueryParser.cs @@ -84,10 +84,25 @@ public class CustomMultiFieldQueryParser : MultiFieldQueryParser bool startInclusive, bool endInclusive) { - if (CustomQueryParser.NumericFields.Contains(field) && int.TryParse(part1, out int min) && - int.TryParse(part2, out int max)) + if (CustomQueryParser.NumericFields.Contains(field)) { - return NumericRangeQuery.NewInt32Range(field, 1, min, max, startInclusive, endInclusive); + if (part1 is null or "*" && int.TryParse(part2, out int max1)) + { + return NumericRangeQuery.NewInt32Range(field, null, max1, startInclusive, endInclusive); + } + + if (int.TryParse(part1, out int min)) + { + if (part2 is null or "*") + { + return NumericRangeQuery.NewInt32Range(field, min, null, startInclusive, endInclusive); + } + + if (int.TryParse(part2, out int max)) + { + return NumericRangeQuery.NewInt32Range(field, min, max, startInclusive, endInclusive); + } + } } return base.GetRangeQuery(field, part1, part2, startInclusive, endInclusive); diff --git a/ErsatzTV.Infrastructure/Search/CustomQueryParser.cs b/ErsatzTV.Infrastructure/Search/CustomQueryParser.cs index adf50dd07..d86b4dee7 100644 --- a/ErsatzTV.Infrastructure/Search/CustomQueryParser.cs +++ b/ErsatzTV.Infrastructure/Search/CustomQueryParser.cs @@ -91,9 +91,25 @@ public class CustomQueryParser : QueryParser bool startInclusive, bool endInclusive) { - if (NumericFields.Contains(field) && int.TryParse(part1, out int min) && int.TryParse(part2, out int max)) + if (NumericFields.Contains(field)) { - return NumericRangeQuery.NewInt32Range(field, 1, min, max, startInclusive, endInclusive); + if (part1 is null or "*" && int.TryParse(part2, out int max1)) + { + return NumericRangeQuery.NewInt32Range(field, null, max1, startInclusive, endInclusive); + } + + if (int.TryParse(part1, out int min)) + { + if (part2 is null or "*") + { + return NumericRangeQuery.NewInt32Range(field, min, null, startInclusive, endInclusive); + } + + if (int.TryParse(part2, out int max)) + { + return NumericRangeQuery.NewInt32Range(field, min, max, startInclusive, endInclusive); + } + } } return base.GetRangeQuery(field, part1, part2, startInclusive, endInclusive);