Fix full-text search for case of partially matched sequence

This commit is contained in:
Abs62 2017-08-26 03:08:24 +03:00
parent 6262047e18
commit 4ef7046327

View file

@ -459,6 +459,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
int pos = 0;
int matchWordNom = 0;
int unmatchWordNom = 0;
int nextNotFoundPos = 0;
QVector< QStringList > allOrders;
QStringList order;
@ -539,8 +540,15 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
if( i < wordsList.size() )
{
// Word found
matchWordNom += 1;
if( matchWordNom == 1 )
{
// Store position to remake search if sequence will not be found
nextNotFoundPos = pos + ( s.isEmpty() ? 1 : s.length() );
}
if( matchWordNom >= words.size() )
{
// All words are found
@ -563,6 +571,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
unmatchWordNom = 0;
for( int i = 0; i < wordsList.size(); i++ )
wordsList[ i ].second = true;
nextNotFoundPos = 0;
break;
}
@ -592,6 +601,12 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
{
matchWordNom += 1;
if( matchWordNom == 1 )
{
// Store position to remake search if sequence will not be found
nextNotFoundPos = pos + ( s.isEmpty() ? 1 : s.length() );
}
if( needHandleBrackets )
{
if( parsedWords.size() > 1 )
@ -628,6 +643,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
matchWordNom = 0;
unmatchWordNom = 0;
order.clear();
nextNotFoundPos = 0;
}
else
breakSearch = true;
@ -652,6 +668,12 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
}
if( breakSearch )
break;
if( nextNotFoundPos > 0 && matchWordNom == 0 )
{
pos = nextNotFoundPos;
nextNotFoundPos = 0;
}
else
pos += s.isEmpty() ? 1 : s.length();
}
}