diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchOperator.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchOperator.java index b80a7a9a..73ed1251 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchOperator.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchOperator.java @@ -68,13 +68,15 @@ public class SearchOperator { } public List doSiteSearch(Context ctx, - String domain) { + String domain, + int count) { - var queryParams = paramFactory.forSiteSearch(domain); + var queryParams = paramFactory.forSiteSearch(domain, count); var queryResponse = queryClient.search(ctx, queryParams); return searchQueryService.getResultsFromQuery(queryResponse); } + public List doBacklinkSearch(Context ctx, String domain) { diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchQueryParamFactory.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchQueryParamFactory.java index fc35ae79..11eef2a0 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchQueryParamFactory.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchQueryParamFactory.java @@ -36,7 +36,7 @@ public class SearchQueryParamFactory { } - public QueryParams forSiteSearch(String domain) { + public QueryParams forSiteSearch(String domain, int count) { return new QueryParams("site:"+domain, null, List.of(), @@ -48,12 +48,11 @@ public class SearchQueryParamFactory { SpecificationLimit.none(), SpecificationLimit.none(), List.of(), - new QueryLimits(100, 100, 100, 512), + new QueryLimits(count, count, 100, 512), SearchSetIdentifier.NONE ); } - public QueryParams forBacklinkSearch(String domain) { return new QueryParams("links:"+domain, null, diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java index 8cb9a84f..badaaeed 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java @@ -119,6 +119,7 @@ public class SearchSiteInfoService { final DomainInformation domainInfo; final List similarSet; final List linkingDomains; + String url = "https://" + domainName + "/";; if (domainId < 0 || !assistantClient.isAccepting()) { domainInfo = createDummySiteInfo(domainName); @@ -133,10 +134,16 @@ public class SearchSiteInfoService { linkingDomains = assistantClient .linkedDomains(ctx, domainId, 100) .blockingFirst(); + + List sampleResults = searchOperator.doSiteSearch(ctx, domainName, 1); + if (!sampleResults.isEmpty()) { + url = sampleResults.getFirst().url.withPathAndParam("/", null).toString(); + } } return new SiteInfoWithContext(domainName, domainId, + url, domainInfo, similarSet, linkingDomains @@ -154,7 +161,7 @@ public class SearchSiteInfoService { private Docs listDocs(Context ctx, String domainName) { return new Docs(domainName, domainQueries.tryGetDomainId(new EdgeDomain(domainName)).orElse(-1), - searchOperator.doSiteSearch(ctx, domainName)); + searchOperator.doSiteSearch(ctx, domainName, 100)); } public record Docs(Map view, @@ -190,11 +197,13 @@ public class SearchSiteInfoService { Map domainState, String domain, long domainId, + String siteUrl, DomainInformation domainInformation, List similar, List linking) { public SiteInfoWithContext(String domain, long domainId, + String siteUrl, DomainInformation domainInformation, List similar, List linking @@ -204,6 +213,7 @@ public class SearchSiteInfoService { Map.of(domainInfoState(domainInformation), true), domain, domainId, + siteUrl, domainInformation, similar, linking); diff --git a/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb b/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb index 345ee6ae..89954e98 100644 --- a/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb +++ b/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb @@ -5,10 +5,10 @@
-

🌎 {{domain}}

+

🌎 {{domain}}

- + Screenshot of {{domain}} {{#with domainInformation}}