optional text search and filter
See original GitHub issue@dj-nitehawk thank you for this great library.
I need little help.
I can apply a text search filter and field filter like this without no problem:
[HttpGet("search-filter")]
public async Task<IActionResult> SearchAndFilter(FilterProductDTO filter)
{
var products = await DB.Find<ProductEntity>()
.Match(Search.Full, filter.SearchTerm)
.ManyAsync(a => a.Category == filter.CategoryId);
return Ok(products);
}
public class FilterProductDTO
{
public string CategoryId { get; set; }
public string SearchTerm { get; set; }
public decimal? MinPrice { get; set; }
public decimal? MaxPrice { get; set; }
public bool? IsInStock { get; set; }
}
But I want to apply these filters optionally, only if they are not null or empty I want to apply.
I guess this can be accomplished with linq IQueryable features. But is it possible to apply text search in linq?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Find - $text search with $or + other optional values
I can't get to query multiple optional values on several fields. ... I already know that $text search can't be used with $or....
Read more >Using optional filters
Learn how to use optional filters to modify your custom ranking. ... They don't just remove records that don't match the filter values....
Read more >How can I build a Dashboard/Search to use optional...
I am trying to build a dashboard with multiple Text inputs that are ... By default the search filters have a logic AND...
Read more >Optional 'free text' search in a primarily category based ...
Our search UI allows users to search across multiple categories: Day, Type, Area, etc. Each selected criteria is ANDed. We also allow a...
Read more >How to make filters in queries optional
Take a look at the Orchard.Projections module. That's where you'll find many of the default query filters (including the date field filter you ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Your last example worked perfectly, thank you very much.
actually, this can also be done in an easier way with the find interface like so: