@@ -921,16 +921,7 @@ protected DynamoModel(IStartConfiguration config)
921
921
922
922
CustomNodeManager = new CustomNodeManager ( NodeFactory , MigrationManager , LibraryServices ) ;
923
923
924
- LuceneSearch . LuceneUtilityNodeSearch = new LuceneSearchUtility ( this ) ;
925
-
926
- if ( IsTestMode )
927
- {
928
- LuceneUtility . InitializeLuceneConfig ( string . Empty , LuceneSearchUtility . LuceneStorage . RAM ) ;
929
- }
930
- else
931
- {
932
- LuceneUtility . InitializeLuceneConfig ( LuceneConfig . NodesIndexingDirectory ) ;
933
- }
924
+ LuceneSearch . LuceneUtilityNodeSearch = new LuceneSearchUtility ( this , LuceneSearchUtility . DefaultNodeIndexStartConfig ) ;
934
925
935
926
InitializeCustomNodeManager ( ) ;
936
927
@@ -1013,10 +1004,15 @@ protected DynamoModel(IStartConfiguration config)
1013
1004
TraceReconciliationProcessor = this ;
1014
1005
1015
1006
State = DynamoModelState . StartedUIless ;
1016
- // This event should only be raised at the end of this method.
1017
- DynamoReady ( new ReadyParams ( this ) ) ;
1018
1007
// Write index to disk only once
1019
1008
LuceneUtility . CommitWriterChanges ( ) ;
1009
+ //Disposed writer if it is in file system mode so that the index files can be used by other processes (potentially a second Dynamo session)
1010
+ if ( LuceneUtility . startConfig . StorageType == LuceneSearchUtility . LuceneStorage . FILE_SYSTEM )
1011
+ {
1012
+ LuceneUtility . DisposeWriter ( ) ;
1013
+ }
1014
+ // This event should only be raised at the end of this method.
1015
+ DynamoReady ( new ReadyParams ( this ) ) ;
1020
1016
}
1021
1017
1022
1018
private void SearchModel_ItemProduced ( NodeModel node )
@@ -1405,12 +1401,8 @@ public void Dispose()
1405
1401
PreferenceSettings . MessageLogged -= LogMessage ;
1406
1402
}
1407
1403
1408
- //The writer have to be disposed at DynamoModel level due that we could index package-nodes as new packages are installed
1409
- LuceneUtility . DisposeWriter ( ) ;
1410
-
1411
1404
// Lucene disposals (just if LuceneNET was initialized)
1412
- LuceneUtility . indexDir ? . Dispose ( ) ;
1413
- LuceneUtility . dirReader ? . Dispose ( ) ;
1405
+ LuceneUtility . DisposeAll ( ) ;
1414
1406
1415
1407
#if DEBUG
1416
1408
CurrentWorkspace . NodeAdded -= CrashOnDemand . CurrentWorkspace_NodeAdded ;
@@ -1474,7 +1466,7 @@ private void InitializeCustomNodeManager()
1474
1466
var iDoc = LuceneUtility . InitializeIndexDocumentForNodes ( ) ;
1475
1467
if ( searchElement != null )
1476
1468
{
1477
- AddNodeTypeToSearchIndex ( searchElement , iDoc ) ;
1469
+ LuceneUtility . AddNodeTypeToSearchIndex ( searchElement , iDoc ) ;
1478
1470
}
1479
1471
1480
1472
Action < CustomNodeInfo > infoUpdatedHandler = null ;
@@ -1543,7 +1535,7 @@ private void InitializeIncludedNodes()
1543
1535
1544
1536
var cnbNode = new CodeBlockNodeSearchElement ( cbnData , LibraryServices ) ;
1545
1537
SearchModel ? . Add ( cnbNode ) ;
1546
- AddNodeTypeToSearchIndex ( cnbNode , iDoc ) ;
1538
+ LuceneUtility . AddNodeTypeToSearchIndex ( cnbNode , iDoc ) ;
1547
1539
1548
1540
var symbolSearchElement = new NodeModelSearchElement ( symbolData )
1549
1541
{
@@ -1562,10 +1554,10 @@ private void InitializeIncludedNodes()
1562
1554
} ;
1563
1555
1564
1556
SearchModel ? . Add ( symbolSearchElement ) ;
1565
- AddNodeTypeToSearchIndex ( symbolSearchElement , iDoc ) ;
1557
+ LuceneUtility . AddNodeTypeToSearchIndex ( symbolSearchElement , iDoc ) ;
1566
1558
1567
1559
SearchModel ? . Add ( outputSearchElement ) ;
1568
- AddNodeTypeToSearchIndex ( outputSearchElement , iDoc ) ;
1560
+ LuceneUtility . AddNodeTypeToSearchIndex ( outputSearchElement , iDoc ) ;
1569
1561
1570
1562
}
1571
1563
@@ -1719,7 +1711,7 @@ private void LoadNodeModels(List<TypeLoadData> nodes, bool isPackageMember)
1719
1711
// TODO: get search element some other way
1720
1712
if ( ele != null )
1721
1713
{
1722
- AddNodeTypeToSearchIndex ( ele , iDoc ) ;
1714
+ LuceneUtility . AddNodeTypeToSearchIndex ( ele , iDoc ) ;
1723
1715
}
1724
1716
}
1725
1717
catch ( Exception e )
@@ -3219,24 +3211,6 @@ private NodeModelSearchElement AddNodeTypeToSearch(TypeLoadData typeLoadData)
3219
3211
return node ;
3220
3212
}
3221
3213
3222
- /// <summary>
3223
- /// Add node information to Lucene index
3224
- /// </summary>
3225
- /// <param name="node">node info that will be indexed</param>
3226
- /// <param name="doc">Lucene document in which the node info will be indexed</param>
3227
- internal void AddNodeTypeToSearchIndex ( NodeSearchElement node , Document doc )
3228
- {
3229
- if ( LuceneUtility . addedFields == null ) return ;
3230
-
3231
- LuceneUtility . SetDocumentFieldValue ( doc , nameof ( LuceneConfig . NodeFieldsEnum . FullCategoryName ) , node . FullCategoryName ) ;
3232
- LuceneUtility . SetDocumentFieldValue ( doc , nameof ( LuceneConfig . NodeFieldsEnum . Name ) , node . Name ) ;
3233
- LuceneUtility . SetDocumentFieldValue ( doc , nameof ( LuceneConfig . NodeFieldsEnum . Description ) , node . Description ) ;
3234
- if ( node . SearchKeywords . Count > 0 ) LuceneUtility . SetDocumentFieldValue ( doc , nameof ( LuceneConfig . NodeFieldsEnum . SearchKeywords ) , node . SearchKeywords . Aggregate ( ( x , y ) => x + " " + y ) , true , true ) ;
3235
- LuceneUtility . SetDocumentFieldValue ( doc , nameof ( LuceneConfig . NodeFieldsEnum . Parameters ) , node . Parameters ?? string . Empty ) ;
3236
-
3237
- LuceneUtility . writer ? . AddDocument ( doc ) ;
3238
- }
3239
-
3240
3214
/// <summary>
3241
3215
/// Remove node information from Lucene indexing.
3242
3216
/// </summary>
@@ -3296,7 +3270,7 @@ private void AddZeroTouchNodeToSearch(FunctionDescriptor functionDescriptor, Doc
3296
3270
{
3297
3271
var ele = new ZeroTouchSearchElement ( functionDescriptor ) ;
3298
3272
SearchModel ? . Add ( ele ) ;
3299
- AddNodeTypeToSearchIndex ( ele , iDoc ) ;
3273
+ LuceneUtility . AddNodeTypeToSearchIndex ( ele , iDoc ) ;
3300
3274
}
3301
3275
}
3302
3276
0 commit comments