Skip to content

Commit

Permalink
fixed #829 query with SENTENCE; added regression to test 377
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatolog committed May 10, 2019
1 parent 81bed36 commit 055586a
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/searchnode.cpp
Expand Up @@ -826,6 +826,11 @@ class ExtUnit_c : public ExtNode_c, public BufferedNode_c
const ExtHit_t * m_pHit1 {nullptr}; ///< current in-chunk ptr const ExtHit_t * m_pHit1 {nullptr}; ///< current in-chunk ptr
const ExtHit_t * m_pHit2 {nullptr}; ///< current in-chunk ptr const ExtHit_t * m_pHit2 {nullptr}; ///< current in-chunk ptr
const ExtHit_t * m_pDotHit {nullptr}; ///< current in-chunk ptr const ExtHit_t * m_pDotHit {nullptr}; ///< current in-chunk ptr

// need to keep this between GetDocsChunk
// as one call of GetDocsChunk might fetch m_pDotDocs
// but fetch m_pDotHit many calls later
bool m_bNeedDotHits = false;
}; };




Expand Down Expand Up @@ -4983,6 +4988,7 @@ void ExtUnit_c::Reset ( const ISphQwordSetup & tSetup )


m_pDocs1 = m_pDocs2 = m_pDotDocs = nullptr; m_pDocs1 = m_pDocs2 = m_pDotDocs = nullptr;
m_pDoc1 = m_pDoc2 = m_pDotDoc = nullptr; m_pDoc1 = m_pDoc2 = m_pDotDoc = nullptr;
m_bNeedDotHits = false;


BufferedNode_c::Reset(); BufferedNode_c::Reset();
} }
Expand Down Expand Up @@ -5161,7 +5167,6 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk()


bool bNeedDoc1Hits = false; bool bNeedDoc1Hits = false;
bool bNeedDoc2Hits = false; bool bNeedDoc2Hits = false;
bool bNeedDotHits = false;
while ( iDoc<MAX_BLOCK_DOCS-1 ) while ( iDoc<MAX_BLOCK_DOCS-1 )
{ {
// fetch more candidate docs, if needed // fetch more candidate docs, if needed
Expand Down Expand Up @@ -5209,7 +5214,7 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk()
{ {
m_pDot->HintRowID(tRowID); m_pDot->HintRowID(tRowID);
pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk(); pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk();
bNeedDotHits = true; m_bNeedDotHits = true;
} }


// skip preceding docs // skip preceding docs
Expand All @@ -5221,7 +5226,7 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk()
if ( !HasDocs(pDotDoc) ) if ( !HasDocs(pDotDoc) )
{ {
pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk(); pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk();
bNeedDotHits = true; m_bNeedDotHits = true;
} }
} }


Expand Down Expand Up @@ -5258,10 +5263,10 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk()
{ {
// got both hits and dots // got both hits and dots
// rewind to relevant dots hits, then do sentence boundary detection // rewind to relevant dots hits, then do sentence boundary detection
if ( bNeedDotHits ) if ( m_bNeedDotHits )
{ {
pDotHit = m_pDot->GetHits ( pDotDoc ); pDotHit = m_pDot->GetHits ( pDotDoc );
bNeedDotHits = false; m_bNeedDotHits = false;
} }


while ( pDotHit->m_tRowID < tRowID ) while ( pDotHit->m_tRowID < tRowID )
Expand Down
46 changes: 46 additions & 0 deletions test/test_377/model.bin
@@ -0,0 +1,46 @@
a:1:{i:0;a:2:{i:0;a:2:{s:8:"sphinxql";s:2203:"
INSERT INTO test1 (id, title) VALUES
( 10, 'The one book might be same as two books' ),
( 11, 'The one book might be same as two books' ),
( 12, 'The one book might be same as two books' ),
( 13, 'The one book might be same as two books' ),
( 14, 'The one book might be same as two books' ),
( 15, 'The one book might be same as two books' ),
( 16, 'The one book might be same as two books' ),
( 17, 'The one book might be same as two books' ),
( 18, 'The one book might be same as two books' ),
( 19, 'The one book might be same as two books' ),
( 20, 'The one book might be same as two books' ),
( 21, 'The one book might be same as two books' ),
( 22, 'The one book might be same as two books' ),
( 23, 'The one book might be same as two books' ),
( 24, 'The one book might be same as two books' ),
( 25, 'The one book might be same as two books' ),
( 26, 'The one book might be same as two books' ),
( 27, 'The one book might be same as two books' ),
( 28, 'The one book might be same as two books' ),
( 29, 'The one book might be same as two books' ),
( 30, 'The one book might be same as two books' ),
( 31, 'The one book might be same as two books' ),
( 32, 'The one book might be same as two books' ),
( 33, 'The one book might be same as two books' ),
( 34, 'The one book might be same as two books' ),
( 35, 'The one book might be same as two books' ),
( 36, 'The one book might be same as two books' ),
( 37, 'The one book might be same as two books' ),
( 38, 'The one book might be same as two books' ),
( 39, 'The one book might be same as two books' ),
( 40, 'The one book might be same as two books' ),
( 41, 'The one book might be same as two books' ),
( 42, 'The one book might be same as two books' ),
( 43, 'The one book might be same as two books' ),
( 44, 'The one book might be same as two books' ),
( 45, 'The one book might be same as two books' ),
( 46, 'The one book might be same as two books' ),
( 47, 'The one book might be same as two books' ),
( 48, 'The one book might be same as two books' ),
( 49, 'The one book might be same as two books' ),

( 110, 'The one book. Not same as two books' ),
( 111, 'The one book is not same as two books. But tree might be better.' )
";s:14:"total_affected";i:42;}i:1;a:3:{s:8:"sphinxql";s:73:" SELECT * FROM test1 WHERE MATCH (' one SENTENCE two' ) ORDER BY id DESC ";s:10:"total_rows";i:20;s:4:"rows";a:20:{i:0;a:2:{s:2:"id";s:3:"111";s:3:"idd";s:1:"0";}i:1;a:2:{s:2:"id";s:2:"49";s:3:"idd";s:1:"0";}i:2;a:2:{s:2:"id";s:2:"48";s:3:"idd";s:1:"0";}i:3;a:2:{s:2:"id";s:2:"47";s:3:"idd";s:1:"0";}i:4;a:2:{s:2:"id";s:2:"46";s:3:"idd";s:1:"0";}i:5;a:2:{s:2:"id";s:2:"45";s:3:"idd";s:1:"0";}i:6;a:2:{s:2:"id";s:2:"44";s:3:"idd";s:1:"0";}i:7;a:2:{s:2:"id";s:2:"43";s:3:"idd";s:1:"0";}i:8;a:2:{s:2:"id";s:2:"42";s:3:"idd";s:1:"0";}i:9;a:2:{s:2:"id";s:2:"41";s:3:"idd";s:1:"0";}i:10;a:2:{s:2:"id";s:2:"40";s:3:"idd";s:1:"0";}i:11;a:2:{s:2:"id";s:2:"39";s:3:"idd";s:1:"0";}i:12;a:2:{s:2:"id";s:2:"38";s:3:"idd";s:1:"0";}i:13;a:2:{s:2:"id";s:2:"37";s:3:"idd";s:1:"0";}i:14;a:2:{s:2:"id";s:2:"36";s:3:"idd";s:1:"0";}i:15;a:2:{s:2:"id";s:2:"35";s:3:"idd";s:1:"0";}i:16;a:2:{s:2:"id";s:2:"34";s:3:"idd";s:1:"0";}i:17;a:2:{s:2:"id";s:2:"33";s:3:"idd";s:1:"0";}i:18;a:2:{s:2:"id";s:2:"32";s:3:"idd";s:1:"0";}i:19;a:2:{s:2:"id";s:2:"31";s:3:"idd";s:1:"0";}}}}}
113 changes: 113 additions & 0 deletions test/test_377/test.xml
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<test>

<name>SENTENCE hitbuffer edge cases</name>

<config>
indexer
{
mem_limit = 16M
}

searchd
{
<searchd_settings/>
workers = threads
binlog_path = #
subtree_docs_cache = 128k
subtree_hits_cache = 128k
}

source dummysrc
{
type = mysql
<sql_settings/>
sql_query = SELECT * FROM test_table
}

index dummysrcmain
{
source = dummysrc
path = <data_path/>/dummysrcmain
}

index test1
{
type = rt
path = <data_path/>/rt

rt_field = title
rt_attr_uint = idd

html_strip = 1
index_sp = 1
}

</config>

<db_create>
CREATE TABLE test_table
(
id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL
);
</db_create>

<db_drop>DROP TABLE IF EXISTS test_table;</db_drop>
<db_insert>insert into test_table values ( 1, 'first')</db_insert>

<sphqueries>

<sphinxql>
INSERT INTO test1 (id, title) VALUES
( 10, 'The one book might be same as two books' ),
( 11, 'The one book might be same as two books' ),
( 12, 'The one book might be same as two books' ),
( 13, 'The one book might be same as two books' ),
( 14, 'The one book might be same as two books' ),
( 15, 'The one book might be same as two books' ),
( 16, 'The one book might be same as two books' ),
( 17, 'The one book might be same as two books' ),
( 18, 'The one book might be same as two books' ),
( 19, 'The one book might be same as two books' ),
( 20, 'The one book might be same as two books' ),
( 21, 'The one book might be same as two books' ),
( 22, 'The one book might be same as two books' ),
( 23, 'The one book might be same as two books' ),
( 24, 'The one book might be same as two books' ),
( 25, 'The one book might be same as two books' ),
( 26, 'The one book might be same as two books' ),
( 27, 'The one book might be same as two books' ),
( 28, 'The one book might be same as two books' ),
( 29, 'The one book might be same as two books' ),
( 30, 'The one book might be same as two books' ),
( 31, 'The one book might be same as two books' ),
( 32, 'The one book might be same as two books' ),
( 33, 'The one book might be same as two books' ),
( 34, 'The one book might be same as two books' ),
( 35, 'The one book might be same as two books' ),
( 36, 'The one book might be same as two books' ),
( 37, 'The one book might be same as two books' ),
( 38, 'The one book might be same as two books' ),
( 39, 'The one book might be same as two books' ),
( 40, 'The one book might be same as two books' ),
( 41, 'The one book might be same as two books' ),
( 42, 'The one book might be same as two books' ),
( 43, 'The one book might be same as two books' ),
( 44, 'The one book might be same as two books' ),
( 45, 'The one book might be same as two books' ),
( 46, 'The one book might be same as two books' ),
( 47, 'The one book might be same as two books' ),
( 48, 'The one book might be same as two books' ),
( 49, 'The one book might be same as two books' ),

( 110, 'The one book. Not same as two books' ),
( 111, 'The one book is not same as two books. But tree might be better.' )
</sphinxql>

<!-- regression for dot hit after buffer of regular matches -->
<sphinxql> SELECT * FROM test1 WHERE MATCH (' one SENTENCE two' ) ORDER BY id DESC </sphinxql>

</sphqueries>

</test>

0 comments on commit 055586a

Please sign in to comment.