Skip to content

Commit

Permalink
added keywords dictionary to RT index
Browse files Browse the repository at this point in the history
git-svn-id: http://sphinxsearch.googlecode.com/svn/trunk@2948 8b96e2b9-35c5-2c16-bc47-5122d61876d4
  • Loading branch information
tomat committed Sep 11, 2011
1 parent e45f00f commit 0d382cb
Show file tree
Hide file tree
Showing 11 changed files with 998 additions and 337 deletions.
6 changes: 5 additions & 1 deletion src/indextool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ int main ( int argc, char ** argv )
if ( hConf["index"][sIndex]("type") && hConf["index"][sIndex]["type"]=="rt" )
{
CSphSchema tSchema;
bool bDictKeywords = false;
if ( hConf["index"][sIndex].Exists ( "dict" ) )
bDictKeywords = ( hConf["index"][sIndex]["dict"]=="keywords" );

if ( sphRTSchemaConfigure ( hConf["index"][sIndex], &tSchema, &sError ) )
pIndex = sphCreateIndexRT ( tSchema, sIndex.cstr(), 32*1024*1024, hConf["index"][sIndex]["path"].cstr() );
pIndex = sphCreateIndexRT ( tSchema, sIndex.cstr(), 32*1024*1024, hConf["index"][sIndex]["path"].cstr(), bDictKeywords );
} else
{
pIndex = sphCreateIndexPhrase ( sIndex.cstr(), hConf["index"][sIndex]["path"].cstr() );
Expand Down
2 changes: 1 addition & 1 deletion src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int main ( int argc, char ** argv )
CSphQueryResult * pResult = NULL;

CSphIndex * pIndex = sphCreateIndexPhrase ( NULL, hIndex["path"].cstr() );
pIndex->m_bEnableStar = ( hIndex.GetInt("enable_star")!=0 );
pIndex->SetEnableStar ( hIndex.GetInt("enable_star")!=0 );
pIndex->SetWordlistPreload ( hIndex.GetInt("ondisk_dict")==0 );

CSphString sWarning;
Expand Down
18 changes: 12 additions & 6 deletions src/searchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12137,7 +12137,7 @@ bool CheckIndex ( const CSphIndex * pIndex, CSphString & sError )
{
const CSphIndexSettings & tSettings = pIndex->GetSettings ();

if ( ( tSettings.m_iMinPrefixLen>0 || tSettings.m_iMinInfixLen>0 ) && !pIndex->m_bEnableStar )
if ( ( tSettings.m_iMinPrefixLen>0 || tSettings.m_iMinInfixLen>0 ) && !pIndex->IsStarEnabled() )
{
CSphDict * pDict = pIndex->GetDictionary ();
assert ( pDict );
Expand Down Expand Up @@ -12240,7 +12240,7 @@ static void RotateIndexMT ( const CSphString & sIndex )
tNewIndex.m_bOnlyNew = pRotating->m_bOnlyNew;

tNewIndex.m_pIndex = sphCreateIndexPhrase ( NULL, NULL ); // FIXME! check if it's ok
tNewIndex.m_pIndex->m_bEnableStar = pRotating->m_bStar;
tNewIndex.m_pIndex->SetEnableStar ( pRotating->m_bStar );
tNewIndex.m_pIndex->m_bExpandKeywords = pRotating->m_bExpand;
tNewIndex.m_pIndex->SetPreopen ( pRotating->m_bPreopen || g_bPreopenIndexes );
tNewIndex.m_pIndex->SetWordlistPreload ( !pRotating->m_bOnDiskDict && !g_bOnDiskDicts );
Expand Down Expand Up @@ -12445,7 +12445,7 @@ void SeamlessTryToForkPrereader ()
if ( !g_pPrereading )
g_pPrereading = sphCreateIndexPhrase ( NULL, NULL ); // FIXME! check if it's ok

g_pPrereading->m_bEnableStar = tServed.m_bStar;
g_pPrereading->SetEnableStar ( tServed.m_bStar );
g_pPrereading->m_bExpandKeywords = tServed.m_bExpand;
g_pPrereading->SetPreopen ( tServed.m_bPreopen || g_bPreopenIndexes );
g_pPrereading->SetWordlistPreload ( !tServed.m_bOnDiskDict && !g_bOnDiskDicts );
Expand Down Expand Up @@ -13064,11 +13064,17 @@ ESphAddIndex AddIndex ( const char * szIndexName, const CSphConfigSection & hInd

// index
ServedIndex_t tIdx;
tIdx.m_pIndex = sphCreateIndexRT ( tSchema, szIndexName, uRamSize, hIndex["path"].cstr() );
bool bWordDict = strcmp ( hIndex.GetStr ( "dict", "" ), "keywords" )==0;
tIdx.m_pIndex = sphCreateIndexRT ( tSchema, szIndexName, uRamSize, hIndex["path"].cstr(), bWordDict );
tIdx.m_bEnabled = false;
tIdx.m_sIndexPath = hIndex["path"];
tIdx.m_bRT = true;
tIdx.m_pIndex->SetWordlistPreload ( !hIndex.GetInt("ondisk_dict") && !g_bOnDiskDicts );

ConfigureIndex ( tIdx, hIndex );
tIdx.m_pIndex->SetEnableStar ( tIdx.m_bStar );
tIdx.m_pIndex->m_iExpansionLimit = g_iExpansionLimit;
tIdx.m_pIndex->SetPreopen ( tIdx.m_bPreopen || g_bPreopenIndexes );
tIdx.m_pIndex->SetWordlistPreload ( !tIdx.m_bOnDiskDict && !g_bOnDiskDicts );

// pick config settings
// they should be overriden later by Preload() if needed
Expand Down Expand Up @@ -13119,7 +13125,7 @@ ESphAddIndex AddIndex ( const char * szIndexName, const CSphConfigSection & hInd
// try to create index
CSphString sWarning;
tIdx.m_pIndex = sphCreateIndexPhrase ( szIndexName, hIndex["path"].cstr() );
tIdx.m_pIndex->m_bEnableStar = tIdx.m_bStar;
tIdx.m_pIndex->SetEnableStar ( tIdx.m_bStar );
tIdx.m_pIndex->m_bExpandKeywords = tIdx.m_bExpand;
tIdx.m_pIndex->m_iExpansionLimit = g_iExpansionLimit;
tIdx.m_pIndex->SetPreopen ( tIdx.m_bPreopen || g_bPreopenIndexes );
Expand Down
Loading

0 comments on commit 0d382cb

Please sign in to comment.