Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-10-14 14:56:07

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Sort by txp:search_result_excerpt count

Search results in Textpattern are rendered (and sorted) by txp:article. How to sort results by density of the queried keywords? The flexible layout usually would look more consistent and logical: az.on.lt/?q=pirm.

Offline

#2 2019-10-14 16:12:39

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Sort by txp:search_result_excerpt count

It actually does sort them by relevancy, but MySQL MATCH ... AGAINST construction used as score works rather unpredictably in my tests.

Offline

#3 2019-10-14 16:17:53

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: Sort by txp:search_result_excerpt count

Yeah, unsure how to fix this. From memory, it should default to sort="score desc" (or score asc ??) for search results, but that may be wishful thinking. If not, does setting that manually in your search result article make any difference?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#4 2019-10-14 16:31:32

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: Sort by txp:search_result_excerpt count

Bloke wrote #319707:

it should default to sort="score desc" (or score asc ??) for search results, but that may be wishful thinking. If not, does setting that manually in your search result article make any difference?

Tried — with no difference…

Offline

#5 2021-05-19 20:47:56

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Sort by txp:search_result_excerpt count

This could work (unsure about the performance):

sort='CHAR_LENGTH(Body) - CHAR_LENGTH( REPLACE ( Body, "<txp:search_term />", "") ) DESC'

Offline

Board footer

Powered by FluxBB