Skip to content

Commit ddaba97

Browse files
committed
Higher boost for fuzziness
1 parent 1afb37e commit ddaba97

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/api/Elastic.Documentation.Api.Infrastructure/Adapters/Search/ElasticsearchGateway.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ public ElasticsearchGateway(ElasticsearchOptions elasticsearchOptions, ILogger<E
8282
.Query(q => q
8383
.Bool(b => b
8484
.Should(
85-
// Tier 1: Exact/Prefix matches (highest boost)
8685
sh => sh.Prefix(p => p
8786
.Field("title.keyword")
8887
.Value(searchQuery)
8988
.CaseInsensitive(true)
9089
.Boost(300.0f)
9190
),
92-
93-
// Tier 2: Semantic search (combined into one clause)
91+
sh => sh.Match(m => m
92+
.Field(f => f.Title)
93+
.Query(searchQuery)
94+
.Fuzziness("AUTO")
95+
.Boost(250.0f)
96+
),
9497
sh => sh.DisMax(dm => dm
9598
.Queries(
9699
dq => dq.Semantic(sem => sem
@@ -104,8 +107,6 @@ public ElasticsearchGateway(ElasticsearchOptions elasticsearchOptions, ILogger<E
104107
)
105108
.Boost(200.0f)
106109
),
107-
108-
// Tier 3: Standard text matching
109110
sh => sh.DisMax(dm => dm
110111
.Queries(
111112
dq => dq.MatchBoolPrefix(m => m
@@ -124,20 +125,10 @@ public ElasticsearchGateway(ElasticsearchOptions elasticsearchOptions, ILogger<E
124125
)
125126
.Boost(100.0f)
126127
),
127-
128-
// Tier 4: Parent matching
129128
sh => sh.Match(m => m
130129
.Field("parents.title")
131130
.Query(searchQuery)
132131
.Boost(75.0f)
133-
),
134-
135-
// Tier 5: Fuzzy fallback
136-
sh => sh.Match(m => m
137-
.Field(f => f.Title)
138-
.Query(searchQuery)
139-
.Fuzziness(1) // Reduced from 2
140-
.Boost(25.0f)
141132
)
142133
)
143134
.MustNot(mn => mn.Terms(t => t

0 commit comments

Comments
 (0)