canwild Posted February 15 Share Posted February 15 Hi all, I'm looking for an elegant way to prioritize certain fields in search. Basically, a search for "pizza" should return a page titled pizza before a page with pizza somewhere deep in the text. What do you recommend? Thanks! $q = wire('input')->get('q'); $q = wire('sanitizer')->text($q); if($q) { $q = wire('sanitizer')->selectorValue($q); $selector = "title|summary|textarea|text|citation_author|citation_book|citation_publisher*+=$q"; $results = $results->filter($selector); } else { // } Link to comment Share on other sites More sharing options...
ngrmm Posted February 15 Share Posted February 15 @canwild I think the way to go is to have multiple selectors // selectors $selector_title = "title%=$q"; $selector_summary = "summary%=$q"; // do the search // make matches unique $matches_summary->removeItems($matches_title); $matches_title->import($matches_summary); Link to comment Share on other sites More sharing options...
canwild Posted February 21 Author Share Posted February 21 Thank you, I'll give that a try! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now