mirror of
https://github.com/simon987/sist2.git
synced 2025-09-07 07:06:54 +00:00
Fixes #536
This commit is contained in:
parent
f5d070496f
commit
ea23bf01e3
@ -93,7 +93,9 @@ export default {
|
||||
threads: "Number of threads",
|
||||
batchSize: "Index batch size",
|
||||
script: "User script",
|
||||
searchIndex: "Search index file location"
|
||||
searchIndex: "Search index file location",
|
||||
esMappings: "Elasticsearch mappings file override",
|
||||
esSettings: "Elasticsearch settings file override"
|
||||
},
|
||||
scanOptions: {
|
||||
title: "Scanning options",
|
||||
|
@ -44,6 +44,12 @@
|
||||
|
||||
<label>{{ $t("backendOptions.batchSize") }}</label>
|
||||
<b-form-input v-model="backend.batch_size" type="number" min="1" @change="update()"></b-form-input>
|
||||
|
||||
<label>{{ $t("backendOptions.esMappings") }}</label>
|
||||
<b-form-textarea v-model="backend.es_mappings" rows="4" @change="update()"></b-form-textarea>
|
||||
|
||||
<label>{{ $t("backendOptions.esSettings") }}</label>
|
||||
<b-form-textarea v-model="backend.es_settings" rows="4" @change="update()"></b-form-textarea>
|
||||
</template>
|
||||
<template v-else>
|
||||
<label>{{ $t("backendOptions.searchIndex") }}</label>
|
||||
|
@ -10,7 +10,7 @@ from logging import FileHandler, StreamHandler
|
||||
from subprocess import Popen, PIPE
|
||||
from tempfile import NamedTemporaryFile
|
||||
from threading import Thread
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -40,6 +40,8 @@ class Sist2SearchBackend(BaseModel):
|
||||
|
||||
es_url: str = "http://elasticsearch:9200"
|
||||
es_insecure_ssl: bool = False
|
||||
es_mappings: Optional[str] = None
|
||||
es_settings: Optional[str] = None
|
||||
es_index: str = "sist2"
|
||||
threads: int = 1
|
||||
batch_size: int = 70
|
||||
@ -57,6 +59,8 @@ class IndexOptions(BaseModel):
|
||||
path: str = None
|
||||
incremental_index: bool = True
|
||||
search_backend: str = None
|
||||
es_mappings_file: Optional[str] = None
|
||||
es_settings_file: Optional[str] = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@ -75,6 +79,12 @@ class IndexOptions(BaseModel):
|
||||
|
||||
if search_backend.es_insecure_ssl:
|
||||
args.append(f"--es-insecure-ssl")
|
||||
|
||||
if self.es_mappings_file:
|
||||
args.append(f"--mappings-file={self.es_mappings_file}")
|
||||
if self.es_settings_file:
|
||||
args.append(f"--settings-file={self.es_settings_file}")
|
||||
|
||||
if self.incremental_index:
|
||||
args.append(f"--incremental-index")
|
||||
|
||||
@ -249,6 +259,20 @@ class Sist2:
|
||||
|
||||
def index(self, options: IndexOptions, search_backend: Sist2SearchBackend, logs_cb, set_pid_cb):
|
||||
|
||||
if search_backend.es_mappings:
|
||||
with NamedTemporaryFile("w", prefix="sist2-admin", suffix=".txt", delete=False) as f:
|
||||
f.write(search_backend.es_mappings)
|
||||
options.es_mappings_file = f.name
|
||||
else:
|
||||
options.es_mappings_file = None
|
||||
|
||||
if search_backend.es_settings:
|
||||
with NamedTemporaryFile("w", prefix="sist2-admin", suffix=".txt", delete=False) as f:
|
||||
f.write(search_backend.es_settings)
|
||||
options.es_settings_file = f.name
|
||||
else:
|
||||
options.es_settings_file = None
|
||||
|
||||
args = [
|
||||
self.bin_path,
|
||||
*options.args(search_backend),
|
||||
|
Loading…
x
Reference in New Issue
Block a user