-
Notifications
You must be signed in to change notification settings - Fork 32
Fix/synonym tweaks #2229
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
Fix/synonym tweaks #2229
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,9 @@ internal sealed record DocumentDto | |
| [JsonPropertyName("url_segment_count")] | ||
| public int UrlSegmentCount { get; init; } | ||
|
|
||
| [JsonPropertyName("headings")] | ||
| public string[] Headings { get; init; } = []; | ||
|
|
||
| [JsonPropertyName("parents")] | ||
| public ParentDocumentDto[] Parents { get; init; } = []; | ||
|
|
||
|
|
@@ -88,10 +91,15 @@ public ElasticsearchGateway(ElasticsearchOptions elasticsearchOptions, ILogger<E | |
|
|
||
| var lexicalSearchRetriever = | ||
| ((Query)new PrefixQuery(Infer.Field<DocumentDto>(f => f.Title.Suffix("keyword")), searchQuery) { Boost = 10.0f, CaseInsensitive = true } | ||
| || new MatchPhrasePrefixQuery(Infer.Field<DocumentDto>(f => f.Title), searchQuery) { Boost = 9.0f } | ||
|
Member
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 is for a follow up but jotting thoughts down here, we probably do not want to have all these prefix queries score so high. I think we should set up an explicit completion fields: For general purpose: https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/search-as-you-type And explicit |
||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Title), searchQuery) { Operator = Operator.And, Boost = 8.0f } | ||
| || new MatchBoolPrefixQuery(Infer.Field<DocumentDto>(f => f.Title), searchQuery) { Boost = 6.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Abstract), searchQuery) { Boost = 4.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.StrippedBody), searchQuery) { Boost = 3.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Abstract), searchQuery) { Operator = Operator.And, Boost = 5.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.StrippedBody), searchQuery) { Operator = Operator.And, Boost = 4.5f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Headings), searchQuery) { Operator = Operator.And, Boost = 4.5f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Abstract), searchQuery) { Operator = Operator.Or, Boost = 4.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.StrippedBody), searchQuery) { Operator = Operator.Or, Boost = 3.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Headings), searchQuery) { Operator = Operator.Or, Boost = 3.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Parents.First().Title), searchQuery) { Boost = 2.0f } | ||
| || new MatchQuery(Infer.Field<DocumentDto>(f => f.Title), searchQuery) { Fuzziness = 1, Boost = 1.0f } | ||
| ) | ||
|
|
@@ -129,7 +137,8 @@ public ElasticsearchGateway(ElasticsearchOptions elasticsearchOptions, ILogger<E | |
| e => e.Title, | ||
| e => e.Url, | ||
| e => e.Description, | ||
| e => e.Parents | ||
| e => e.Parents, | ||
| e => e.Headings | ||
| ) | ||
| ) | ||
| ) | ||
|
|
@@ -193,6 +202,7 @@ private static (int TotalHits, List<SearchResultItem> Results) ProcessSearchResp | |
| Url = doc.Url, | ||
| Title = doc.Title, | ||
| Description = doc.Description ?? string.Empty, | ||
| Headings = doc.Headings, | ||
| Parents = doc.Parents.Select(parent => new SearchResultItemParent | ||
| { | ||
| Title = parent.Title, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.