Eunico Cornelius Posted April 6, 2018 Share Posted April 6, 2018 I am trying to filter my $pages with a find($selector method). $matches = $pages->find($selector); and this is an example of what my selector looks like $selector = "include=all, title|body~=$q, limit=50"; In this case, it only searches according to the matching exact words. For example:we search="art", the result="art times","these art",.... Is there any way to search based on the alphabet? For example: we search="ab", the result="absolutely correct","abstract art",.... Link to comment Share on other sites More sharing options...
DaveP Posted April 6, 2018 Share Posted April 6, 2018 If I understand correctly, in your $selector, use body^=$q instead of body~=$q. (Note caret instead of tilde.) See https://processwire.com/api/selectors/#operators 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 6, 2018 Share Posted April 6, 2018 Fuzzy matching like one is expecting nowadays of a good search field is actually quite difficult to do with mysql. If you need a fast search returning relevant content for such short search terms you're most often better served using something like elasticsearch or angolia. 1 Link to comment Share on other sites More sharing options...
Eunico Cornelius Posted April 9, 2018 Author Share Posted April 9, 2018 On 4/6/2018 at 5:24 PM, DaveP said: If I understand correctly, in your $selector, use body^=$q instead of body~=$q. (Note caret instead of tilde.) See https://processwire.com/api/selectors/#operators I understand this part, and I have tried to do it with body^=$q, However in a search, this will only apply for the first part of the word. For example, if I have a question "What is the best pet" this will only work if I search for "wh" and it will not show if I even search for "best". I have read the documentation and body*=$q fits more for search queries. Thank you for you help . @DaveP @LostKobrakai Link to comment Share on other sites More sharing options...
DaveP Posted April 9, 2018 Share Posted April 9, 2018 Aaahh, I wasn't understanding correctly. Maybe something like this might be useful. 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