evanmcd Posted April 16, 2013 Share Posted April 16, 2013 Hi all, I'm tweaking a search engine that's built using PW selectors. I'm wondering if there is a way to set the selector to find word fragments, for example the user searches on 'grass seed' and I want to find fields that have the words 'grasses' and 'seeding' (or 'grassy' and 'seeds' for another example). I know I can use the %= selector, but my options there are body%=grass seed or body%=grass|seed, neither of which return just what I want. I could switch to using raw SQL (body LIKE 'grass%' AND body LIKE 'seed%') but I'd rather stick with PW selectors if I can. Thanks! Link to comment Share on other sites More sharing options...
WillyC Posted April 16, 2013 Share Posted April 16, 2013 mabe.usar [italicamos]and[/italicamos] insted o [italicamos]or[/italacimos] ? $pages->find("body%=grass, body%=seed") htis is impossibel match: body LIKE 'grass%' AND body LIKE 'seed%' start.wit grass and seed a text cannot Link to comment Share on other sites More sharing options...
ryan Posted April 18, 2013 Share Posted April 18, 2013 While I don't understand what WillyC is saying, his code is correct. Try "body%=grass, body%=seed" so that you are requiring both terms to be present somewhere in the target text. While that would match 'grasses' and 'seeding', it would also match 'seagrass' and 'birdseed', which you may not want. In that case, you would want to replace the %= with *=, which will use the fulltext index. Because the individual words are indexed, it would match 'grasses' and 'seeding', but not 'seagrass' and 'birdseed'. Also your raw SQL would not work because it would only find fields that begin with the word "grass" AND "seed" – an impossible condition. 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