gpt4 book ai didi

elasticsearch - 使用 Elasticsearch JDBC Importer 后, 'asciifolding' 未按预期工作

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

将 Elasticsearch JDBC 导入器与此配置一起使用:

bin=/usr/share/elasticsearch/elasticsearch-jdbc-2.1.1.2/bin
lib=/usr/share/elasticsearch/elasticsearch-jdbc-2.1.1.2/lib
echo '{
"type" : "jdbc",
"jdbc" : {
"url" : "ip/db",
"user" : "myuser",
"password" : "a7sdf7hsdf8hn78df",
"sql" : "SELECT title, body, source_id, time_order, type, blablabla...",
"index" : "importeditems",
"type" : "item",
"elasticsearch.host": "_eth0_",
"detect_json" : false
}
}' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter

我已经使用以下表格正确索引了一些文档:
{
"title":"Tiempo de Opinión: Puede comenzar un ciclo",
"body":"Sebas Álvaro nos trae cada lunes historias y anécdotas de la montaña<!-- com -->",
"source_id":21188,
"time_order":"1438638043:55c2c6bb96d4c"
"type":"rss"
}

我试图忽略重音符号(例如,标题中的 opinión ó ),所以如果用户搜索 "tiempo de opinión""tiempo de opinion"match_phrase它与带或不带重音的文档匹配。

因此,在使用导入器并索引所有内容后,我将索引设置更改为 default带有 asciifolding 的分析仪筛选。
curl -XPOST 'localhost:9200/importeditems/_close'

curl -XPUT 'localhost:9200/importeditems/_settings?pretty=true' -d '{
"analysis": {
"analyzer": {
"default": {
"tokenizer" : "standard",
"filter": [ "lowercase", "asciifolding"]
}}}}'

curl -XPOST 'localhost:9200/importeditems/_open'

然后我做一个 match_phrase匹配 "tiempo de opinion" (无重音)和 "tiempo de opinión" (带重音)
# No accent
curl -XGET 'localhost:9200/importeditems/_search?pretty=true' -d'
{
"query": {
"match_phrase" : {
"title" : "tiempo de opinion"
}}}'

# With accent
curl -XGET 'localhost:9200/importeditems/_search?pretty=true' -d'
{
"query": {
"match_phrase" : {
"title" : "tiempo de opinión"
}}}'

但是当它们存在时没有给出匹配(如果我 match_phrase 短语 tiempo de 它返回一些包含 tiempo de opinión 的命中)。

我认为问题是由于 de JDBC Importer 造成的,因为我在不使用导入器的情况下重现了错误,手动添加了另一个索引和条目,将索引设置也更改为 asciifolding一切都按预期工作。您可以在 here 右侧查看此工作示例.

如果我检查使用导入器后创建的索引的设置( importeditems )
curl -XGET 'localhost:9200/importeditems/_settings?pretty=true'

这输出:
{
"importeditems" : {
"settings" : {
"index" : {
"creation_date" : "1457533907278",
"analysis" : {
"analyzer" : {
"default" : {
"filter" : [ "lowercase", "asciifolding" ],
"tokenizer" : "standard"
}
}
},
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "x",
"version" : {
"created" : "2010199"
}}}}

...如果我检查手动创建的索引( test )的设置:
curl -XGET 'localhost:9200/test/_settings?pretty=true'

我得到相同的输出:
 {
"test" : {
"settings" : {
"index" : {
"creation_date" : "1457603253278",
"analysis" : {
"analyzer" : {
"default" : {
"filter" : [ "lowercase", "asciifolding" ],
"tokenizer" : "standard"
}
}
},
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "x",
"version" : {
"created" : "2010199"
}}}}

如果我使用 Elasticsearch JDBC Importer,有人可以告诉我为什么它不起作用,如果我添加原始数据,为什么它会起作用?

最佳答案

我终于通过首先更改 settings 解决了这个问题通过添加 analysis模块:

curl -XPOST 'localhost:9200/importeditems/_close'

curl -XPUT 'localhost:9200/importeditems/_settings?pretty=true' -d '{
"analysis": {
"analyzer": {
"default": {
"tokenizer" : "standard",
"filter": [ "lowercase", "asciifolding"]
}}}}'

curl -XPOST 'localhost:9200/importeditems/_open'

...然后再次导入所有数据。

这是多余的,因为正如我在帖子中所说,我在两种情况下都做了完全相同的事情(使用 JDBC 导入器和原始数据):
  • 指数数据
  • 变化指数settings
  • 使用 match_phrase 进行查询

  • 它适用于原始数据( test ),而不是我使用导入器的数据( importeditems )。我唯一能想到的是 importeditems超过 12GB,需要时间重新创建 asciifolding 的内容在上面。这就是为什么在 asciifolding 之后没有反射(reflect)这些更改的原因。被激活。

    无论如何,如果有人遇到同样的问题,特别是那些处理大量数据的人,请记住首先设置分析器,然后索引所有数据。

    根据 docs :

    Queries can find only terms that actually exist in the inverted index, so it is important to ensure that the same analysis process is applied both to the document at index time, and to the query string at search time so that the terms in the query match the terms in the inverted index.

    关于elasticsearch - 使用 Elasticsearch JDBC Importer 后, 'asciifolding' 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35914330/

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