How can I display more accurate results using the search extension? #748
-
Hello, Currently the search extension allows to modify the text length of page excerpts. In theory you can set this to a high value and completely render result pages matching the given search string, which is not very comfortable when searching through pages with a bigger amount of text. If possible, how can I modify the search extension layout to display a shorter but more accurate text excerpt from a page? I would like to have a typical search engine result with page title and an excerpt displaying only the relevant text with surrounding context, (e. g. 5 to 10 words around the actual search result). As an example, searching for the word "voluptate" should return something like the following in the page excerpt:
I've already found the function Steffen |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Here's what we discussed on Discord. The search extension is roughly divided into two parts. The first part is the logic that searches trough all pages and calculates a "searchScore" based on text and meta data. The second part is the visualisation that loops trough stored pages and generates output from the "beginning of page content" converted to text. If someone wants to display a more accurate text excerpt from a page, here some thoughts and ideas:
Apologies for not answering earlier. I planned taking a break from GitHub discussions in 2022 and probably will answer less frequently. Of course will be available for code reviews, Steffen. Let me know what you find out. |
Beta Was this translation helpful? Give feedback.
-
The search extension has been updated and now jumps directly to the first match of a search term and displays a text excerpt. Thank you, this makes the extension a lot more useful. 👍 |
Beta Was this translation helpful? Give feedback.
Here's what we discussed on Discord. The search extension is roughly divided into two parts. The first part is the logic that searches trough all pages and calculates a "searchScore" based on text and meta data. The second part is the visualisation that loops trough stored pages and generates output from the "beginning of page content" converted to text.
If someone wants to display a more accurate text excerpt from a page, here some thoughts and ideas:
$pageSearch->set("searchscore", $searchScore)
in filesea…