Permalink
Browse files

fixed #366 empty documents at PQ result set; added regressions to tes…

…t 359
  • Loading branch information...
tomatolog committed Aug 13, 2018
1 parent b5ea8dc commit 930e831a43fd3d1ce996185be968d1df49a088d0
Showing with 98 additions and 6 deletions.
  1. +7 −6 src/sphinxrt.cpp
  2. +1 −0 test/test_359/model.bin
  3. +90 −0 test/test_359/test.xml
@@ -11676,6 +11676,10 @@ static void MatchingWork ( const StoredQuery_t * pStored, PercolateMatchContext_
const bool bCollectDocs = tMatchCtx.m_bGetDocs;
int iDocsOff = tMatchCtx.m_dDocsMatched.GetLength();
int iMatchCount = 0;
// reserve space for matched docs counter
if ( bCollectDocs )
tMatchCtx.m_dDocsMatched.Add ( 0 );
if ( !pStored->IsFullscan() ) // matching path
{
@@ -11697,8 +11701,6 @@ static void MatchingWork ( const StoredQuery_t * pStored, PercolateMatchContext_
if ( bCollectDocs )
{
// docs encoding: docs-count; docs matched
if ( !iMatchCount )
tMatchCtx.m_dDocsMatched.Add ( 0 );
tMatchCtx.m_dDocsMatched.Reserve ( tMatchCtx.m_dDocsMatched.GetLength() + iMatches );
for ( int iMatch=0; iMatch<iMatches; iMatch++ )
tMatchCtx.m_dDocsMatched.Add ( pMatch[iMatch].m_uDocID );
@@ -11708,10 +11710,6 @@ static void MatchingWork ( const StoredQuery_t * pStored, PercolateMatchContext_
}
} else // full-scan path
{
// reserve space for matched docs counter
if ( bCollectDocs )
tMatchCtx.m_dDocsMatched.Add ( 0 );
CSphMatch tDoc;
int iStride = DOCINFO_IDSIZE + tMatchCtx.m_tSchema.GetRowSize();
const CSphIndex * pIndex = tMatchCtx.m_pTermSetup->m_pIndex;
@@ -11751,6 +11749,9 @@ static void MatchingWork ( const StoredQuery_t * pStored, PercolateMatchContext_
tDesc.m_sFilters = tMatchCtx.m_tFilterBuf.cstr();
}
}
} else if ( bCollectDocs ) // pop's up reserved but not used matched counter
{
tMatchCtx.m_dDocsMatched.Resize ( iDocsOff );
}
if ( tMatchCtx.m_bVerbose )
@@ -0,0 +1 @@
a:1:{i:0;a:26:{i:0;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:1;a:2:{s:8:"sphinxql";s:76:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:2;a:2:{s:8:"sphinxql";s:88:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:3;a:3:{s:8:"sphinxql";s:113:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"1";s:9:"Documents";s:2:"21";s:5:"Query";s:0:"";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}i:4;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:5;a:2:{s:8:"sphinxql";s:88:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:6;a:2:{s:8:"sphinxql";s:76:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:7;a:3:{s:8:"sphinxql";s:113:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"2";s:9:"Documents";s:2:"21";s:5:"Query";s:0:"";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}i:8;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:9;a:2:{s:8:"sphinxql";s:88:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:10;a:2:{s:8:"sphinxql";s:87:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.staff=\'got some\'')";s:14:"total_affected";i:1;}i:11;a:2:{s:8:"sphinxql";s:76:"INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:12;a:3:{s:8:"sphinxql";s:113:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"3";s:9:"Documents";s:2:"21";s:5:"Query";s:0:"";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}i:13;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:14;a:2:{s:8:"sphinxql";s:80:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:15;a:2:{s:8:"sphinxql";s:92:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:16;a:3:{s:8:"sphinxql";s:132:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"1";s:9:"Documents";s:2:"21";s:5:"Query";s:4:"test";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}i:17;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:18;a:2:{s:8:"sphinxql";s:92:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:19;a:2:{s:8:"sphinxql";s:80:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:20;a:3:{s:8:"sphinxql";s:132:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"2";s:9:"Documents";s:2:"21";s:5:"Query";s:4:"test";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}i:21;a:2:{s:8:"sphinxql";s:19:"TRUNCATE rtindex pq";s:14:"total_affected";i:0;}i:22;a:2:{s:8:"sphinxql";s:92:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')";s:14:"total_affected";i:1;}i:23;a:2:{s:8:"sphinxql";s:91:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.staff=\'got some\'')";s:14:"total_affected";i:1;}i:24;a:2:{s:8:"sphinxql";s:80:"INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')";s:14:"total_affected";i:1;}i:25;a:3:{s:8:"sphinxql";s:132:"CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:3:"UID";s:1:"3";s:9:"Documents";s:2:"21";s:5:"Query";s:4:"test";s:4:"Tags";s:0:"";s:7:"Filters";s:30:" json_data.text.status.state=0";}}}}}
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<test>
<name>percolate query vs docs matched</name>
<config>
indexer
{
mem_limit = 16M
}
searchd
{
<searchd_settings/>
workers = threads
}
source dummy
{
type = mysql
<sql_settings/>
sql_query = select * from test_table
sql_attr_uint = gid
}
index dummy
{
source = dummy
path = <data_path/>/dummy
}
index pq
{
type = percolate
path = <data_path/>/pq_re
rt_field = title
rt_attr_json = json_data
}
</config>
<db_create>
CREATE TABLE `test_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`gid` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
)
</db_create>
<db_drop>DROP TABLE IF EXISTS `test_table`;</db_drop>
<db_insert>INSERT INTO `test_table` VALUES ( 1, 1, 'test 1' )</db_insert>
<sphqueries>
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
<!-- docs missed due to zero counter from not matched stored query -->
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.staff=\'got some\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
<!-- same for full-text path -->
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
<sphinxql>TRUNCATE rtindex pq</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.favorited=\'false\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.staff=\'got some\'')</sphinxql>
<sphinxql>INSERT INTO pq (query, filters) VALUES ('test', 'json_data.text.status.state=0')</sphinxql>
<sphinxql>CALL PQ ('pq', ('{"id":21,"json_data":{"text":{"status":{"state":0}}}, "title":"test me"}'), 1 as docs, 1 as query, 'id' as docs_id)</sphinxql>
</sphqueries>
</test>

0 comments on commit 930e831

Please sign in to comment.