mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 04:58:59 +00:00
(index) Two useful debug endpoints
This commit is contained in:
parent
14372e0ef0
commit
d160954080
@ -60,6 +60,10 @@ public class IndexService extends Service {
|
||||
|
||||
Spark.post("/search/", indexQueryService::search, gson::toJson);
|
||||
|
||||
Spark.get("/public/debug/docmeta", indexQueryService::debugEndpointDocMetadata, gson::toJson);
|
||||
Spark.get("/public/debug/wordmeta", indexQueryService::debugEndpointWordMetadata, gson::toJson);
|
||||
Spark.get("/public/debug/word", indexQueryService::debugEndpointWordEncoding, gson::toJson);
|
||||
|
||||
Spark.post("/ops/repartition", opsService::repartitionEndpoint);
|
||||
Spark.post("/ops/reindex", opsService::reindexEndpoint);
|
||||
|
||||
|
@ -24,6 +24,8 @@ import nu.marginalia.index.query.IndexQuery;
|
||||
import nu.marginalia.index.results.IndexResultDomainDeduplicator;
|
||||
import nu.marginalia.index.svc.searchset.SmallSearchSet;
|
||||
import nu.marginalia.model.gson.GsonFactory;
|
||||
import nu.marginalia.model.idx.DocumentMetadata;
|
||||
import nu.marginalia.model.idx.WordMetadata;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Marker;
|
||||
@ -71,6 +73,29 @@ public class IndexQueryService {
|
||||
this.metadataService = metadataService;
|
||||
this.searchTermsSvc = searchTerms;
|
||||
}
|
||||
public DocumentMetadata debugEndpointDocMetadata(Request request, Response response) {
|
||||
String docId = request.queryParams("docId");
|
||||
response.type("application/json");
|
||||
|
||||
return new DocumentMetadata(index.getDocumentMetadata(Long.parseLong(docId)));
|
||||
}
|
||||
|
||||
public WordMetadata debugEndpointWordMetadata(Request request, Response response) {
|
||||
String word = request.queryParams("word");
|
||||
String docId = request.queryParams("docId");
|
||||
response.type("application/json");
|
||||
|
||||
return new WordMetadata(index.getTermMetadata(
|
||||
searchTermsSvc.getWordId(word),
|
||||
new long[] { Long.parseLong(docId) }
|
||||
)[0]);
|
||||
}
|
||||
public String debugEndpointWordEncoding(Request request, Response response) {
|
||||
String word = request.queryParams("word");
|
||||
response.type("application/json");
|
||||
|
||||
return Long.toHexString(searchTermsSvc.getWordId(word));
|
||||
}
|
||||
|
||||
public Object search(Request request, Response response) {
|
||||
String json = request.body();
|
||||
|
@ -29,6 +29,15 @@ server {
|
||||
location /site/ {
|
||||
rewrite ^/site/(.*)$ /search?query=site:$1&profile=yolo;
|
||||
}
|
||||
location /debug/wordmeta {
|
||||
proxy_pass http://index-service:5021/public/debug/wordmeta;
|
||||
}
|
||||
location /debug/docmeta {
|
||||
proxy_pass http://index-service:5021/public/debug/docmeta;
|
||||
}
|
||||
location /debug/word {
|
||||
proxy_pass http://index-service:5021/public/debug/word;
|
||||
}
|
||||
location /suggest/ {
|
||||
proxy_pass http://assistant-service:5025/public$request_uri;
|
||||
access_log off;
|
||||
|
Loading…
Reference in New Issue
Block a user