diff --git a/src/searchnode.cpp b/src/searchnode.cpp index 39ae02c2dd..fa7e3b8c13 100644 --- a/src/searchnode.cpp +++ b/src/searchnode.cpp @@ -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_pHit2 {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; }; @@ -4983,6 +4988,7 @@ void ExtUnit_c::Reset ( const ISphQwordSetup & tSetup ) m_pDocs1 = m_pDocs2 = m_pDotDocs = nullptr; m_pDoc1 = m_pDoc2 = m_pDotDoc = nullptr; + m_bNeedDotHits = false; BufferedNode_c::Reset(); } @@ -5161,7 +5167,6 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk() bool bNeedDoc1Hits = false; bool bNeedDoc2Hits = false; - bool bNeedDotHits = false; while ( iDocHintRowID(tRowID); pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk(); - bNeedDotHits = true; + m_bNeedDotHits = true; } // skip preceding docs @@ -5221,7 +5226,7 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk() if ( !HasDocs(pDotDoc) ) { pDotDoc = m_pDotDocs = m_pDot->GetDocsChunk(); - bNeedDotHits = true; + m_bNeedDotHits = true; } } @@ -5258,10 +5263,10 @@ const ExtDoc_t * ExtUnit_c::GetDocsChunk() { // got both hits and dots // rewind to relevant dots hits, then do sentence boundary detection - if ( bNeedDotHits ) + if ( m_bNeedDotHits ) { pDotHit = m_pDot->GetHits ( pDotDoc ); - bNeedDotHits = false; + m_bNeedDotHits = false; } while ( pDotHit->m_tRowID < tRowID ) diff --git a/test/test_377/model.bin b/test/test_377/model.bin new file mode 100644 index 0000000000..3b108f170d --- /dev/null +++ b/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";}}}}} \ No newline at end of file diff --git a/test/test_377/test.xml b/test/test_377/test.xml new file mode 100644 index 0000000000..d88a278371 --- /dev/null +++ b/test/test_377/test.xml @@ -0,0 +1,113 @@ + + + +SENTENCE hitbuffer edge cases + + +indexer +{ + mem_limit = 16M +} + +searchd +{ + + workers = threads + binlog_path = # + subtree_docs_cache = 128k + subtree_hits_cache = 128k +} + +source dummysrc +{ + type = mysql + + sql_query = SELECT * FROM test_table +} + +index dummysrcmain +{ + source = dummysrc + path = /dummysrcmain +} + +index test1 +{ + type = rt + path = /rt + + rt_field = title + rt_attr_uint = idd + + html_strip = 1 + index_sp = 1 +} + + + + +CREATE TABLE test_table +( + id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, + title varchar(255) NOT NULL +); + + +DROP TABLE IF EXISTS test_table; +insert into test_table values ( 1, 'first') + + + + +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.' ) + + + + SELECT * FROM test1 WHERE MATCH (' one SENTENCE two' ) ORDER BY id DESC + + + +