drilonb Posted April 19, 2011 Share Posted April 19, 2011 do you have any idea ore help to creat page for search and form only for keywords in site ? Link to comment Share on other sites More sharing options...
ryan Posted April 19, 2011 Share Posted April 19, 2011 What are the field names and types that you want to be searchable? Generally, you can find all pages that match keywords for a given text or textarea field like this: <?php // find pages that match the phrase 'some keywords' on the 'title' or 'body' fields: $matches = $pages->find("title|body*=some keywords"); // find pages that match the words 'some keywords' anywhere in the 'title' or 'body' fields: $matches = $pages->find("title|body~=some keywords"); // find pages matching 'some keywords' phrase in 'title', and 'some other keywords' words anywhere in 'body' $matches = $pages->find("title*=some keywords, body~='some other keywords'"); Link to comment Share on other sites More sharing options...
drilonb Posted April 19, 2011 Author Share Posted April 19, 2011 Thnaks RYAN i fix it now its working great just need some little styling i use this code and work great $matches = $pages->find("title|body~=$q"); Link to comment Share on other sites More sharing options...
marcin Posted April 23, 2011 Share Posted April 23, 2011 @drilonb, remember to sanitize $q. Link to comment Share on other sites More sharing options...
landitus Posted September 16, 2011 Share Posted September 16, 2011 Hi! I'm having a lot of fun with PW! It rocks! I was wondering if the search term can be of 3 characters, cause I'm working on a product catalog which has a lot of 3 letter products. I've noticed that these products don't show on the search results. Is there a way? Link to comment Share on other sites More sharing options...
apeisa Posted September 16, 2011 Share Posted September 16, 2011 landitus: welcome to the forums. I had similar problem earlier and Ryan provided quick tip to fix that problem: http://processwire.com/talk/index.php/topic,159.msg1003.html#msg1003 Link to comment Share on other sites More sharing options...
ryan Posted September 16, 2011 Share Posted September 16, 2011 You can also use the "%=" operator in your selector, rather than "*=", i.e. "body%=que", and that will work. The "%=" operator uses the MySQL LIKE command rather than a fulltext index, so it's not bound by word length or stopwords. However, on a large site it is a lot slower since it's not using indexes. Though you may have to be dealing with hundreds or thousands of pages before the difference would be major. I compared broad text searches on a site with 3,500 pages and didn't perceive any difference in speed when replacing the "*=" with "%=". However, it really may depend on the server and *= is going to be measurably (if not noticeably) faster the larger the site gets. So if you can tweak your MySQL settings to support words below 4 characters like in Antti's link, then that is preferable since it is technically more efficient. Link to comment Share on other sites More sharing options...
landitus Posted September 16, 2011 Share Posted September 16, 2011 Thank you very much for your answers. I ended up with '%=', cause it's a small catalog and didn't want to mess with mysql settings! 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