Answer the question
In order to leave comments, you need to log in
How to set Sphinx relevance to the beginning of the line?
I make a request and get the result.
Query: brush
Answer the question
In order to leave comments, you need to log in
Key parameter min_hit_pos
More details here
As an option:
$query = 'кисточ';
try {
$sp = new PDO('mysql:host=127.0.0.1;port=9306', '', '');
$list = $sp->query("SELECT * FROM test1 WHERE MATCH('$query') OPTION ranker = expr('sum(4*lcs+100/(min_hit_pos)+bm25)')");
while ( $row = $list->fetch(PDO::FETCH_ASSOC) ) { //Преобразуем результат в ассоциативный массив
echo $row['id'] . ' - '; //id товара в mysql
echo $row['weight'] . ' - '; //Релевантный вес
echo $row['name'] . '<br/>'; //Название товара
};
} catch( PDOException $e) {
echo "You have an error: ".$e->getMessage()."<br>";
echo "On line: ".$e->getLine();
}
Go in the direction of relevance and query popularity weights, and then sort by this index, how could it be otherwise?
In select, add a separate "Short Title" field, which is built on the fly as the first 2 words of the line (if the second word is "for", then without it). Or not 2 words, but the whole line before the punctuation mark, "for", "with".
And assign a high weight to this field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question