-
Notifications
You must be signed in to change notification settings - Fork 638
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-5795 Lucene Search Weights #14062
Merged
QilongTang
merged 1 commit into
DynamoDS:master
from
RobertGlobant20:DYN-5795-Lucene-Search-Weights
Jun 13, 2023
+85
−39
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -959,21 +959,16 @@ internal IEnumerable<NodeSearchElementViewModel> Search(string search, bool useL | |
Document resultDoc = Model.Searcher.Doc(topDocs.ScoreDocs[i].Doc); | ||
|
||
// TODO: use consts in static class for the Lucene field names | ||
string name = resultDoc.Get("Name"); | ||
string name = resultDoc.Get(nameof(Configurations.IndexFieldsEnum.Name)); | ||
|
||
string docName = resultDoc.Get("DocName"); | ||
string cat = resultDoc.Get("FullCategoryName"); | ||
string fulldesc = resultDoc.Get("Documentation"); | ||
string pkgName = resultDoc.Get("PackageName"); | ||
string docName = resultDoc.Get(nameof(Configurations.IndexFieldsEnum.DocName)); | ||
string cat = resultDoc.Get(nameof(Configurations.IndexFieldsEnum.FullCategoryName)); | ||
string fulldesc = resultDoc.Get(nameof(Configurations.IndexFieldsEnum.Description)); | ||
|
||
if (!string.IsNullOrEmpty(docName)) | ||
{ | ||
//code for setting up documentation info | ||
} | ||
else if (!string.IsNullOrEmpty(pkgName)) | ||
{ | ||
//code for setting up package info | ||
} | ||
else | ||
{ | ||
var foundNode = FindViewModelForNodeNameAndCategory(name, cat); | ||
|
@@ -1018,13 +1013,25 @@ private string CreateSearchQuery(string[] fields, string searchKey) | |
} | ||
|
||
var wildcardQuery = new WildcardQuery(new Term(f, searchTerm)); | ||
if (f.Equals("Name")) { wildcardQuery.Boost = 10; } | ||
else { wildcardQuery.Boost = 6; } | ||
if (f.Equals(nameof(Configurations.IndexFieldsEnum.Name))) | ||
{ | ||
wildcardQuery.Boost = 10; | ||
} | ||
else | ||
{ | ||
wildcardQuery.Boost = 6; | ||
} | ||
booleanQuery.Add(wildcardQuery, Occur.SHOULD); | ||
|
||
wildcardQuery = new WildcardQuery(new Term(f, searchTerm + "*")); | ||
if (f.Equals("Name")) { wildcardQuery.Boost = 7; } | ||
else { wildcardQuery.Boost = 4; } | ||
wildcardQuery = new WildcardQuery(new Term(f, "*" + searchTerm + "*")); | ||
if (f.Equals(nameof(Configurations.IndexFieldsEnum.Name))) | ||
{ | ||
wildcardQuery.Boost = 7; | ||
} | ||
else | ||
{ | ||
wildcardQuery.Boost = 4; | ||
} | ||
booleanQuery.Add(wildcardQuery, Occur.SHOULD); | ||
|
||
if (searchTerm.Contains(' ') || searchTerm.Contains('.')) | ||
|
@@ -1036,9 +1043,16 @@ private string CreateSearchQuery(string[] fields, string searchKey) | |
fuzzyQuery = new FuzzyQuery(new Term(f, s), fuzzyLogicRange); | ||
booleanQuery.Add(fuzzyQuery, Occur.SHOULD); | ||
} | ||
wildcardQuery = new WildcardQuery(new Term(f, s + "*")); | ||
if (f.Equals("Name")) { wildcardQuery.Boost = 5; } | ||
else { wildcardQuery.Boost = 2; } | ||
wildcardQuery = new WildcardQuery(new Term(f, "*" + s + "*")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably could benefit with some comments |
||
|
||
if (f.Equals(nameof(Configurations.IndexFieldsEnum.Name))) | ||
{ | ||
wildcardQuery.Boost = 5; | ||
} | ||
else | ||
{ | ||
wildcardQuery.Boost = 2; | ||
} | ||
booleanQuery.Add(wildcardQuery, Occur.SHOULD); | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine place for now, I may move these to dedicated Lucene config file later in my PR