Reject generic pages for concrete research identifiers
CI / test (push) Successful in 1m25s
CI / test (pull_request) Successful in 1m18s

This commit is contained in:
m
2026-08-26 02:11:51 +03:00
parent 23a1eeae56
commit 04018cbd07
2 changed files with 45 additions and 0 deletions
+21
View File
@@ -1812,6 +1812,9 @@ func nearestFlightQuery(query string) bool {
// search-engine snippets from becoming a human-facing answer when a search
// term has a common non-travel meaning.
func researchFindingMatchesIntent(query string, finding epistemics.ResearchFinding) bool {
if !findingContainsRequestedIdentifier(query, finding) {
return false
}
if !nearestFlightQuery(query) {
return true
}
@@ -1841,6 +1844,24 @@ func researchFindingMatchesIntent(query string, finding epistemics.ResearchFindi
return true
}
// findingContainsRequestedIdentifier prevents a generic landing page from
// being presented as a result for a concrete model, article or brand request.
// Identifiers are detected by their syntax, not by a catalogue of providers or
// entities, so the rule stays valid as user vocabulary changes.
func findingContainsRequestedIdentifier(query string, finding epistemics.ResearchFinding) bool {
identifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1)
if len(identifiers) == 0 {
return true
}
evidence := strings.ToLower(strings.Join([]string{finding.Source.Title, finding.Source.Locator, finding.Excerpt.Text}, " "))
for _, identifier := range identifiers {
if !strings.Contains(evidence, strings.ToLower(identifier)) {
return false
}
}
return true
}
// nearestFlightRouteTerms retains only the two endpoint-shaped terms from a
// structured flight search. It has no city or provider vocabulary: endpoint
// relevance is determined from the request itself.