jarektkaczyk / eloquence-base

base for the Eloquence extensions + Searchable
https://softonsofa.com
MIT License
77 stars 69 forks source link

Search Tweak #3

Closed matthewscalf closed 6 years ago

matthewscalf commented 6 years ago

How hard would it be to add the function in where it give higher weights to searches that contain words combined together. Basically from the example package:

Prioritize matches containing "John Doe" above matches containing only "John" or "Doe".

jarektkaczyk commented 6 years ago

Search works like that by default, so all you need to do is provide whole phrase as one of the keywords for search:

$query->search(['john doe', 'john', 'doe'], false)

2nd param in this case means it is strict search, ie. it doesn't apply wildcard to each word (in mysql: %john%, %doe%) which is what you probably want in this case.