Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-04 15:13:08

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

Search in excerpt

Hi,
It’s seems that the search don’t match in the excerpt (the file publish.php allow only search on Title and Body).
Is there a possibility ?
Tks for your answer.

Last edited by Pat64 (2006-09-04 16:00:03)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#2 2006-09-04 16:52:53

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Search in excerpt

in publish.php, you’ll find these two lines:
<pre>
<code>$match = “, match (Title,Body) against (‘$q’) as score”;
$search = “ and (Title rlike ‘$q’ or Body rlike ‘$q’) $s_filter”;</code>
</pre>

Changing that as follows should do give you searchable excerpts (not tested):
<pre>
<code>$match = “, match (Title,Body,Excerpt) against (‘$q’) as score”;
$search = “ and (Title rlike ‘$q’ or Body rlike ‘$q’ or Excerpt rlike ‘$q’) $s_filter”;</code>
</pre>

However, without additional changes you won’t get the search query highlighted (bold) in the search results if it only matches in the Excerpt.

Perhaps there’s a plugin that can do this for you without having to change the code…

If would be nice if the search functionality could be configurable so that you could choose to search only titles, only bodies, only excerpts… or combinations of those. Perhaps an extra attribute ‘search’, set by default to ‘Title,Body’?

Offline

#3 2006-09-05 08:19:42

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

Re: Search in excerpt

Hi Ruud.
Ok. I try it yesterday, before my post, but this mod don’t work (on TXP 4.0.4)

ruud wrote:


If would be nice if the search functionality could be configurable so that you could choose to search only titles, only bodies, only excerpts… or combinations of those. Perhaps an extra attribute ‘search’, set by default to ‘Title,Body’?

Yes. Absolutely, I agree. Possibility to choose/combine on which element to apply the search query is a big miss on TXP.

I understand that an excerpt can’t be relevant in the majority of the cases for a research. In other cases, the use of the excerpt can be a hack with the limitation of the fields in the articles. The “summary” then becoming an independent element of information. As important as the title and the body.

Last edited by Pat64 (2006-09-05 08:31:16)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#4 2006-09-05 08:27:24

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Search in excerpt

but this mod don’t work (on TXP 4.0.4)

There is no 4.0.4. There is only development snapshots of and pre-releases from the 4.0 branch.

Offline

#5 2006-09-05 08:33:24

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

Re: Search in excerpt

Tks Sencer for this precision. So do this mod above can wok for search on the excerpt in TXP 4.0 branch?
Cheers.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#6 2006-09-05 21:24:15

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Search in excerpt

The mod works (tested on txp 4.0.3, but should work in the 4.0 development branch as well, because those lines haven’t changed), but you have to add a fulltext index for Excerpt to the textpattern table, using this SQL query (If you’ve set a prefix for textpattern tables, you have to change the table name accordingly):
<notextile><pre>
<code>ALTER TABLE `textpattern` DROP INDEX `searching` ,
ADD FULLTEXT `searching` (
`Title` ,
`Body` ,
`Excerpt`
)</code></notextile></pre>

Last edited by ruud (2006-09-05 21:29:02)

Offline

#7 2006-09-05 22:32:23

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,674
GitHub Twitter

Re: Search in excerpt

Right. I’ve forget to check the tables :)
Tks lot Ruud.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB