Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6037 lucene overloaded nodes #14136

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/DynamoCore/Configuration/LuceneConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ public enum IndexFieldsEnum
/// <summary>
/// Hosts - Package hosts
/// </summary>
Hosts
Hosts,

/// <summary>
/// Node Input Parameters as string (there are nodes with same name and category but different parameters)
/// </summary>
Parameters
}

/// <summary>
Expand All @@ -138,7 +143,8 @@ public enum IndexFieldsEnum
nameof(IndexFieldsEnum.Description),
Copy link
Contributor

@reddyashish reddyashish Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the Enum name from IndexFieldsEnum to NodeIndexFields, as it is specific to that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed IndexFieldsEnum to NodeIndexFields
commit: fab8b07

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion, I just saw that the same enum property is used in PackageIndexFields also and one of the enum values is "Hosts". Not a big deal, you can revert this last name change if you want.

nameof(IndexFieldsEnum.SearchKeywords),
nameof(IndexFieldsEnum.DocName),
nameof(IndexFieldsEnum.Documentation)};
nameof(IndexFieldsEnum.Documentation),
nameof(IndexFieldsEnum.Parameters)};


/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3257,6 +3257,7 @@ private void AddNodeTypeToSearchIndex(NodeSearchElement node, Document doc)
LuceneSearchUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.IndexFieldsEnum.Name), node.Name);
LuceneSearchUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.IndexFieldsEnum.Description), node.Description);
if (node.SearchKeywords.Count > 0) LuceneSearchUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.IndexFieldsEnum.SearchKeywords), node.SearchKeywords.Aggregate((x, y) => x + " " + y), true, true);
LuceneSearchUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.IndexFieldsEnum.Parameters), node.Parameters?? string.Empty);

LuceneSearchUtility.writer?.AddDocument(doc);
}
Expand Down
4 changes: 3 additions & 1 deletion src/DynamoCore/Utilities/LuceneSearchUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ internal Document InitializeIndexDocumentForNodes()
var keywords = new TextField(nameof(LuceneConfig.IndexFieldsEnum.SearchKeywords), string.Empty, Field.Store.YES);
var docName = new StringField(nameof(LuceneConfig.IndexFieldsEnum.DocName), string.Empty, Field.Store.YES);
var fullDoc = new TextField(nameof(LuceneConfig.IndexFieldsEnum.Documentation), string.Empty, Field.Store.YES);
var parameters = new TextField(nameof(LuceneConfig.IndexFieldsEnum.Parameters), string.Empty, Field.Store.YES);

var d = new Document()
{
Expand All @@ -93,7 +94,8 @@ internal Document InitializeIndexDocumentForNodes()
description,
keywords,
fullDoc,
docName
docName,
parameters
};
return d;
}
Expand Down
14 changes: 11 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -965,14 +965,15 @@ internal IEnumerable<NodeSearchElementViewModel> Search(string search, bool useL
string name = resultDoc.Get(nameof(LuceneConfig.IndexFieldsEnum.Name));
string docName = resultDoc.Get(nameof(LuceneConfig.IndexFieldsEnum.DocName));
string cat = resultDoc.Get(nameof(LuceneConfig.IndexFieldsEnum.FullCategoryName));
string parameters = resultDoc.Get(nameof(LuceneConfig.IndexFieldsEnum.Parameters));

if (!string.IsNullOrEmpty(docName))
{
//code for setting up documentation info
}
else
{
var foundNode = FindViewModelForNodeNameAndCategory(name, cat);
var foundNode = FindViewModelForNodeNameAndCategory(name, cat, parameters);
if (foundNode != null)
{
candidates.Add(foundNode);
Expand All @@ -992,13 +993,20 @@ internal IEnumerable<NodeSearchElementViewModel> Search(string search, bool useL
/// </summary>
/// <param name="nodeName">Name of the node</param>
/// <param name="nodeCategory">Full Category of the node</param>
/// <param name="parameters">Node input parameters</param>
/// <returns></returns>
private NodeSearchElementViewModel FindViewModelForNodeNameAndCategory(string nodeName, string nodeCategory)
private NodeSearchElementViewModel FindViewModelForNodeNameAndCategory(string nodeName, string nodeCategory, string parameters)
{
var result = Model.SearchEntries.Where(e => {
if (e.Name.Equals(nodeName) && e.FullCategoryName.Equals(nodeCategory))
{
return true;
//When the node info was indexed if Parameters was null we added an empty space (null cannot be indexed)
//Then in this case when searching if e.Parameters is null we need to check against empty space
if (e.Parameters == null)
return string.IsNullOrEmpty(parameters);
//Parameters contain a value so we need to compare against the value indexed
else
return e.Parameters.Equals(parameters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put comments for this block, not too intuitive to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added more comments please let me know if the explanation is clear. Thanks
commit: 6bc39b7

}
return false;
});
Expand Down