mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-10-06 07:32:38 +02:00
Compare commits
2 Commits
deploy-027
...
deploy-027
Author | SHA1 | Date | |
---|---|---|---|
|
390f053406 | ||
|
b03c43224c |
@@ -30,10 +30,11 @@ public class ApiSearchOperator {
|
|||||||
|
|
||||||
public ApiSearchResults query(String query,
|
public ApiSearchResults query(String query,
|
||||||
int count,
|
int count,
|
||||||
|
int domainCount,
|
||||||
int index,
|
int index,
|
||||||
NsfwFilterTier filterTier)
|
NsfwFilterTier filterTier)
|
||||||
{
|
{
|
||||||
var rsp = queryClient.search(createParams(query, count, index, filterTier));
|
var rsp = queryClient.search(createParams(query, count, domainCount, index, filterTier));
|
||||||
|
|
||||||
return new ApiSearchResults("RESTRICTED", query,
|
return new ApiSearchResults("RESTRICTED", query,
|
||||||
rsp.results()
|
rsp.results()
|
||||||
@@ -44,13 +45,13 @@ public class ApiSearchOperator {
|
|||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryParams createParams(String query, int count, int index, NsfwFilterTier filterTirer) {
|
private QueryParams createParams(String query, int count, int domainCount, int index, NsfwFilterTier filterTirer) {
|
||||||
SearchSetIdentifier searchSet = selectSearchSet(index);
|
SearchSetIdentifier searchSet = selectSearchSet(index);
|
||||||
|
|
||||||
return new QueryParams(
|
return new QueryParams(
|
||||||
query,
|
query,
|
||||||
RpcQueryLimits.newBuilder()
|
RpcQueryLimits.newBuilder()
|
||||||
.setResultsByDomain(2)
|
.setResultsByDomain(Math.clamp(domainCount, 1, 100))
|
||||||
.setResultsTotal(Math.min(100, count))
|
.setResultsTotal(Math.min(100, count))
|
||||||
.setTimeoutMs(150)
|
.setTimeoutMs(150)
|
||||||
.setFetchSize(8192)
|
.setFetchSize(8192)
|
||||||
|
@@ -119,6 +119,7 @@ public class ApiService extends SparkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int count = intParam(request, "count", 20);
|
int count = intParam(request, "count", 20);
|
||||||
|
int domainCount = intParam(request, "dc", 2);
|
||||||
int index = intParam(request, "index", 3);
|
int index = intParam(request, "index", 3);
|
||||||
int nsfw = intParam(request, "nsfw", 1);
|
int nsfw = intParam(request, "nsfw", 1);
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ public class ApiService extends SparkService {
|
|||||||
.labels(license.key)
|
.labels(license.key)
|
||||||
.time(() ->
|
.time(() ->
|
||||||
searchOperator
|
searchOperator
|
||||||
.query(query, count, index, nsfwFilterTier)
|
.query(query, count, domainCount, index, nsfwFilterTier)
|
||||||
.withLicense(license.getLicense())
|
.withLicense(license.getLicense())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ public class BangCommand implements SearchCommandInterface {
|
|||||||
|
|
||||||
if (match.isPresent()) {
|
if (match.isPresent()) {
|
||||||
var url = String.format(redirectPattern, URLEncoder.encode(match.get(), StandardCharsets.UTF_8));
|
var url = String.format(redirectPattern, URLEncoder.encode(match.get(), StandardCharsets.UTF_8));
|
||||||
new MapModelAndView("redirect.jte", Map.of("url", url));
|
return Optional.of(new MapModelAndView("redirect.jte", Map.of("url", url)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,19 @@
|
|||||||
|
package nu.marginalia.search.command.commands;
|
||||||
|
|
||||||
|
import nu.marginalia.WebsiteUrl;
|
||||||
|
import nu.marginalia.search.command.SearchParameters;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class BangCommandTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testWikipediaRedirect() {
|
||||||
|
BangCommand bc = new BangCommand();
|
||||||
|
|
||||||
|
assertTrue(bc.process(SearchParameters.defaultsForQuery(new WebsiteUrl("test"), "!w plato", 1)).isPresent());
|
||||||
|
assertFalse(bc.process(SearchParameters.defaultsForQuery(new WebsiteUrl("test"), "plato", 1)).isPresent());
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user