Dynamic Order By Entity Framework
I have the following query:
I was asked to make it so that searchText can have multiple searches, IE:
If I type in "Hello World", I should have the results ordered so that anything that starts with "Hello" or "World" appears first. But this needs to be dynamic in length.
So the search text "Hello World Bob" would check for three items.
In addition, I need to support partial matches. So "Hel Wor Bo" would at minimum return the same results as "Hello World Bob".
How would I go about doing this? If I didn't need to worry about partial matches, I could just do
p => searchText.Contains(p.Name)
.
But I need to support partial queries.6 Replies
there's this framework for searching
I forgot what it's called
it should have this functionality
Not sure.
Looked into it more, I am pretty confident that EF doesn't have a way to do this
in raw SQL this query would be complex as is
(I only pasted a partial, the order by logic has a lot of steps in reality, was trying to adopt it to this new logic)
elastic search
I've seen this thing mentioned a lot
the easiest way is a custom query
It's got to be
I wonder if
EF.Functions.Like()
would work here?nah it's too much logic for a single expression
It does work, but it is VERY VERY VERY slow
because it is also looking at a json column =/
I will celebrate the day we get rid of it