Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I do searches Only in the Titles of Posts?
How do I do searches Only in the Titles of Posts instead of the complete post text?
Thanks for the help
Offline
#2 2007-01-22 20:26:38
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How do I do searches Only in the Titles of Posts?
You can’t without hacking (not recommended) or a plugin (don’t know if one exists).
Offline
Re: How do I do searches Only in the Titles of Posts?
OK thanks.
Offline
Re: How do I do searches Only in the Titles of Posts?
The hack would be to edit this file (DO AT YOUR OWN RISK):
textpattern/publish/search.php
around line #35 change:
“(Title rlike ‘$q’ or Body rlike ‘$q’) $s_filter
to this
“(Title rlike ‘$q’) $s_filter
Textpattern should actually rank the title higher in general… so i suggest as future release separate the FULLTEXT of Title,Body so you can make title score higher …
nuff-respec ::: dannyb
Offline
#5 2007-01-22 23:59:00
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How do I do searches Only in the Titles of Posts?
That’s been asked for before, and, you can’t: you would have to make three separate indexes instead of just 1 (that’s how MySQL works). That’s not efficient at all, especially over time, and when most people do want both title and body searched.
A plugin could do it, though.
Offline
Re: How do I do searches Only in the Titles of Posts?
Indexes aren’t so bad ??
… and two (one for TITLE one for BODY) will do since you are using RLIKE to actually do the search , and FULLTEXT index only to rank the results. I think INDEXES are only really expensive when you INSERT into the database… maybe in the future you could just use MySQL FULLTEXT searching to also return the results, although you would have to worry about STOP words and not getting results if your database is really small.
nuff-respec ::: dannyb
Offline