mirror of
https://github.com/simon987/sist2.git
synced 2025-12-11 14:38:54 +00:00
Improve scroll feature, UI fix
This commit is contained in:
@@ -129,7 +129,7 @@ void elastic_flush() {
|
||||
Indexer->queued = 0;
|
||||
|
||||
char bulk_url[4096];
|
||||
snprintf(bulk_url, 4096, "%s/sist2/_bulk", Indexer->es_url);
|
||||
snprintf(bulk_url, 4096, "%s/sist2/_bulk?pipeline=tie", Indexer->es_url);
|
||||
response_t *r = web_post(bulk_url, buf, "Content-Type: application/x-ndjson");
|
||||
|
||||
if (r->status_code == 0) {
|
||||
@@ -245,6 +245,11 @@ void elastic_init(int force_reset) {
|
||||
LOG_INFOF("elastic.c", "Close index <%d>", r->status_code);
|
||||
free_response(r);
|
||||
|
||||
snprintf(url, 4096, "%s/_ingest/pipeline/tie", IndexCtx.es_url);
|
||||
r = web_put(url, pipeline_json, "Content-Type: application/json");
|
||||
LOG_INFOF("elastic.c", "Create pipeline <%d>", r->status_code);
|
||||
free_response(r);
|
||||
|
||||
snprintf(url, 4096, "%s/sist2/_settings", IndexCtx.es_url);
|
||||
r = web_put(url, settings_json, "Content-Type: application/json");
|
||||
LOG_INFOF("elastic.c", "Update settings <%d>", r->status_code);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||
|
||||
|
||||
static const char *const Version = "1.2.5";
|
||||
static const char *const Version = "1.2.6";
|
||||
static const char *const usage[] = {
|
||||
"sist2 scan [OPTION]... PATH",
|
||||
"sist2 index [OPTION]... INDEX",
|
||||
|
||||
@@ -221,14 +221,6 @@ int search(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||
return OCS_NOT_PROCESSED;
|
||||
}
|
||||
|
||||
char *scroll_param;
|
||||
const char *scroll = onion_request_get_query(req, "scroll");
|
||||
if (scroll != NULL) {
|
||||
scroll_param = "?scroll=3m";
|
||||
} else {
|
||||
scroll_param = "";
|
||||
}
|
||||
|
||||
const struct onion_block_t *block = onion_request_get_data(req);
|
||||
|
||||
if (block == NULL) {
|
||||
@@ -236,7 +228,7 @@ int search(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||
}
|
||||
|
||||
char url[4096];
|
||||
snprintf(url, 4096, "%s/sist2/_search%s", WebCtx.es_url, scroll_param);
|
||||
snprintf(url, 4096, "%s/sist2/_search", WebCtx.es_url);
|
||||
response_t *r = web_post(url, onion_block_data(block), "Content-Type: application/json");
|
||||
|
||||
set_default_headers(res);
|
||||
@@ -254,43 +246,6 @@ int search(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||
return OCS_PROCESSED;
|
||||
}
|
||||
|
||||
int scroll(UNUSED(void *p), onion_request *req, onion_response *res) {
|
||||
|
||||
int flags = onion_request_get_flags(req);
|
||||
if ((flags & OR_METHODS) != OR_GET) {
|
||||
return OCS_NOT_PROCESSED;
|
||||
}
|
||||
|
||||
char url[4096];
|
||||
snprintf(url, 4096, "%s/_search/scroll", WebCtx.es_url);
|
||||
|
||||
const char *scroll_id = onion_request_get_query(req, "scroll_id");
|
||||
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(json, "scroll_id", scroll_id);
|
||||
cJSON_AddStringToObject(json, "scroll", "3m");
|
||||
|
||||
char *json_str = cJSON_PrintUnformatted(json);
|
||||
response_t *r = web_post(url, json_str, "Content-Type: application/json");
|
||||
|
||||
cJSON_Delete(json);
|
||||
cJSON_free(json_str);
|
||||
|
||||
if (r->status_code != 200) {
|
||||
free_response(r);
|
||||
return OCS_NOT_PROCESSED;
|
||||
}
|
||||
|
||||
set_default_headers(res);
|
||||
onion_response_set_header(res, "Content-Type", "application/json");
|
||||
onion_response_set_header(res, "Content-Disposition", "application/json");
|
||||
onion_response_set_length(res, r->size);
|
||||
onion_response_write(res, r->body, r->size);
|
||||
free_response(r);
|
||||
|
||||
return OCS_PROCESSED;
|
||||
}
|
||||
|
||||
int serve_file_from_url(cJSON *json, index_t *idx, onion_request *req, onion_response *res) {
|
||||
|
||||
const char *path = cJSON_GetObjectItem(json, "path")->valuestring;
|
||||
@@ -466,7 +421,6 @@ void serve(const char *hostname, const char *port) {
|
||||
onion_url_add(urls, "img/sprite-skin-flat.png", img_sprite_skin_flag);
|
||||
|
||||
onion_url_add(urls, "es", search);
|
||||
onion_url_add(urls, "scroll", scroll);
|
||||
onion_url_add(urls, "status", status);
|
||||
onion_url_add(
|
||||
urls,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user