fix for elasticsearch

This commit is contained in:
simon 2019-10-26 19:05:47 -04:00
parent ef79681024
commit b4199a1fd8
5 changed files with 21 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"index": {
"refresh_interval": "-1",
"refresh_interval": "30s",
"codec": "best_compression"
},
"analysis": {
@ -24,13 +24,15 @@
"my_nGram": {
"tokenizer": "my_nGram_tokenizer",
"filter": [
"lowercase"
"lowercase",
"asciifolding"
]
},
"content_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase"
"lowercase",
"asciifolding"
]
}
}

View File

@ -70,7 +70,8 @@ void elastic_flush() {
while (line != NULL) {
char action_str[512];
snprintf(action_str, 512, "{\"index\":{\"_id\": \"%s\", \"_type\":\"_doc\"}}", line->uuid_str);
snprintf(action_str, 512,
"{\"index\":{\"_id\":\"%s\", \"_type\":\"_doc\", \"_index\":\"sist2\"}}\n", line->uuid_str);
size_t action_str_len = strlen(action_str);
size_t line_len = strlen(line->line);
@ -98,6 +99,14 @@ void elastic_flush() {
snprintf(bulk_url, 4096, "%s/sist2/_bulk", Indexer->es_url);
response_t *r = web_post(bulk_url, buf, "Content-Type: application/x-ndjson");
printf("Indexed %3d documents (%zukB) <%d>\n", count, buf_cur / 1024, r->status_code);
cJSON *ret_json = cJSON_Parse(r->body);
if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) {
fprintf(stderr, "%s\n", r->body);
}
cJSON_Delete(ret_json);
free_response(r);
}
@ -187,7 +196,7 @@ void elastic_init(int force_reset) {
printf("Update settings <%d>\n", r->status_code);
free_response(r);
snprintf(url, 4096, "%s/sist2/_mappings/_doc", IndexCtx.es_url);
snprintf(url, 4096, "%s/sist2/_mappings/_doc?include_type_name=true", IndexCtx.es_url);
r = web_put(url, mappings_json, "Content-Type: application/json");
printf("Update mappings <%d>\n", r->status_code);
free_response(r);

File diff suppressed because one or more lines are too long

View File

@ -232,7 +232,9 @@ void read_index(const char *path, const char index_id[UUID_STR_LEN], index_func
case MetaTitle: {
buf.cur = 0;
while ((c = getc(file)) != 0) {
dyn_buffer_write_char(&buf, (char) c);
if (!(SHOULD_IGNORE_CHAR(c) || c == ' ')) {
dyn_buffer_write_char(&buf, (char) c);
}
}
dyn_buffer_write_char(&buf, '\0');
cJSON_AddStringToObject(document, get_meta_key_text(key), buf.buf);

View File

@ -5,7 +5,7 @@
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
static const char *const Version = "1.0.1";
static const char *const Version = "1.0.2";
static const char *const usage[] = {
"sist2 scan [OPTION]... PATH",
"sist2 index [OPTION]... INDEX",