S
S
Sergei2015-11-17 23:52:46
PHP
Sergei, 2015-11-17 23:52:46

How to format search results?

Good afternoon. I use to search for sphinx. I get an array with search results as an output.
What is the best way to format the received results for their issuance to the end user?
Let me give you an example of what I mean.
Search for: "Regulations of the department"
In the search results there are articles of 2-3k characters
"Regulations of department A"
"Regulations of department B"
, etc.
Displaying 2-3k characters for each result and turning the search into mountains of text is not an option. In a stupid cut after n characters is also not suitable.
I would like to somehow beautifully cut pieces of text around the found matches.
Ideally, I submit the found text on the request "Vasya" and at the output of 2-3k I get 50-60 characters like:
"... Lorem ipsum dolor sit amet Vasya, consectetur adipiscing elit ...". Vasya... Nunc vitae tincidunt tortor, eget lobortis velit. Donec viverra, sem at dapibus fringilla

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-11-18
@Neversmille

Solved using buildExcerpts

A
Andrew, 2015-11-18
@R0dger

sphinxsearch.com/forum/view.html?id=10870 - should suit you
Or cut the search itself after you get it in your backend.

P
Puma Thailand, 2015-11-18
@opium

This is all done on the side of the programming language, cut and format as you please

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question