gpt4 book ai didi

elasticsearch - 尝试为我的Elasticsearch索引设置分析器

转载 作者:行者123 更新时间:2023-12-03 00:16:42 25 4
gpt4 key购买 nike

具有以下映射:

curl -XPUT 'localhost:9200/borrador' -d '{
"mappings": {
"item": {
"dynamic": "strict",
"properties" : {
"title" : { "type" : "string" },
"body" : { "type": "string" },
"source_id" : { "type": "integer" },
}}}}'

我正在使用以下 Elasticsearch-JDBC importer脚本从数据库中导入所有数据
#!/bin/sh

bin=/usr/share/elasticsearch/elasticsearch-jdbc-2.1.1.2/bin
lib=/usr/share/elasticsearch/elasticsearch-jdbc-2.1.1.2/lib
echo "Indexando base de datos..."
echo '{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mydbip/mydbname",
"user" : "username",
"password" : "pw",
"sql" : "select source_id, body, id as _id from table_name",
"index" : "borrador",
"type" : "item",
"detect_json": false
}
}' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter

事实是,我正在寻找一种适合我的方法的正确的 analyzer,但我有点迷失: 我正在寻找一种使用可以适应多种语言的analyzer的方法。
这意味着有时DB的输入是西类牙语,英语或其他任何语言。用户将数据添加到数据库中,因此它可以是任何语言,也可以是未存储的语言本身,这意味着我不知道哪种语言具有当前条目。而且,语言不会混合在一起(没有一行使用两种不同的语言)。

归档此目标的最佳方法是哪种?最好将通用分析器用于所有语言,还是最好为每种语言构建不同的分析器?如果有人提供给我带有 analyzer的映射,将不胜感激。

最佳答案

您可以尝试对body.enbody.fr,...所使用的每种语言使用多字段

例如 :

"properties": {
"body" : {
"type": "string",
"fields": {
"fr": {
"type": "string",
"analyzer": "french"
},
"en": {
"type": "string",
"analyzer": "english"
},
"es": {
"type": "string",
"analyzer": "spanish"
},
"de": {
"type": "string",
"analyzer": "german"
},
"pt": {
"type": "string",
"analyzer": "portuguese"
},
"nl": {
"type": "string",
"analyzer": "dutch"
},
"dk": {
"type": "string",
"analyzer": "danish"
}
}
}

关于elasticsearch - 尝试为我的Elasticsearch索引设置分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35573502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com