当前位置: 首页 > 知识库问答 >
问题:

“索引”:elasticsearch中的“未分析”

姚韬
2023-03-14

我用cmd删除了映射

curl -XDELETE 'http://localhost:9200/logstash_log*/'

在我的配置文件中,我定义了如下索引:,

output {
   elasticsearch {
   hosts => localhost
   index => "logstash_log-%{+YYYY.MM.dd}"
 }

并尝试创建一个新的映射,但我得到了错误

 #curl -XPUT http://localhost:9200/logstash_log*/_mapping/log -d '

{


     "properties":{
          "@timestamp":"type":"date","format":"strict_date_optional_time||epoch_millis"},
           "message":{"type":"string"},
           "host":{"type":"ip"},
           "name":{"type":"string","index": "not_analyzed"},
           "type":{"type":"string"}
                }

}'

{“error”:{“root_cause”:[{“type”:“index_not_found_exception”,“reason”:“no-this index”,“resource.type”:“index_or_alias”,“resource.id”:“logstash_log*”,“index”:“logstash_log*”,“type”:“index_not found__exception”,“reason”:“no-this index”,“resource.type”:“index_or_alias”,“resource.id”:“logstash_log*”,“index”:“logstash_log*”,”状态:404

我该怎么修?任何帮助都将不胜感激!!

共有2个答案

叶坚
2023-03-14

*是索引名的无效字符。

索引名不能包含以下字符[\,/,*,?,\”,

越学义
2023-03-14

您需要像这样重新创建索引:

# curl -XPUT http://localhost:9200/logstash_log -d '{
  "mappings": {
    "log": {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        },
        "message": {
          "type": "string"
        },
        "host": {
          "type": "ip"
        },
        "name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "type": {
          "type": "string"
        }
      }
    }
  }
}'

虽然看起来像是从logstash创建每日索引,但最好还是创建一个模板。将以下内容存储index_模板中。json

{
  "template": "logstash-*",
  "mappings": {
    "log": {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        },
        "message": {
          "type": "string"
        },
        "host": {
          "type": "ip"
        },
        "name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "type": {
          "type": "string"
        }
      }
    }
  }
}

然后修改日志存储配置,如下所示:

output {
   elasticsearch {
   hosts => localhost
   index => "logstash_log-%{+YYYY.MM.dd}"
   manage_template => true
   template_name => "logstash"
   template => "/path/to/index_template.json"
   template_overwrite => true
}
 类似资料:
  • 问题内容: 我在Elasticsearch上遇到问题,我不希望对索引项进行分析。但是elasticsearch有一些默认设置,可以在空间上标记它。因此,我的方面查询未返回我想要的结果。 我读到索引类型的属性应该工作。但是问题是我事先不知道我的文档结构。我会在不知道表结构的情况下将随机MySQL数据库索引到elasticsearch。 我如何设置elasticsearch,使其默认情况下会一直使用,

  • 问题内容: 我需要更改索引中的分片数量。索引很大,为了达到测试目的,我可能不得不将配置更改10-15次才能满意。是否有开箱即用的工具提供这种功能?或最简单的方法是做到这一点? 问题答案: 无论是Perl的和Ruby客户直接支持重建索引。 在Perl中,您可以执行以下操作: 在Clinton Gormley 的帖子中查找更多信息。 在Ruby中,您可以执行以下操作: 在相关的 Tyre 提交中找到更

  • 我阅读了关于在Elasticsearch中索引文档的教程。例如,批量索引。我有个问题,当为循环中的一个项创建带有两个键的数组时,是否正确: 为什么循环中有两个数组初始化$params['body][]?必须使用与my_字段相同的键进行索引设置? 我的意思是一种情况,当有关index的所有信息都由一个键(index)添加到数组中时: 同样在搜索查询后,我得到错误: 消息:非法字符串偏移量“匹配”在所

  • 主要内容:创建索引,删除索引,获取索引,测试索引存在,打开/关闭索引API,索引别名,索引设置,分析,索引模板,索引统计,刷新清除数据, 刷新索引这些API负责管理索引的所有方面,如设置,别名,映射,索引模板。 创建索引 此API可用于创建索引。 当用户将对象传递到任何索引时,可以自动创建索引,也可以在此之前创建索引。 要创建索引,只需要发送包含设置,映射和别名的发布请求,或者只发送一个没有正文的简单请求。 例如, 响应 或者,加上一些设置 - 请求正文 响应 或使用映射 - 请求正文 响应 或

  • 问题内容: Elasticsearch中的索引是什么?一个应用程序有多个索引还是只有一个索引?假设您为某些汽车制造商构建了一个系统。它涉及人员,汽车,零件等。您是否有一个名为制造商的索引,或者您有一个人的索引,一个用于汽车的索引和一个用于零备件的索引?有人可以解释吗? 问题答案: 很好的问题,答案比人们期望的要细腻得多。您可以将索引用于几种不同的目的。 关系指标 最简单,最熟悉的布局将克隆您从关系

  • 问题内容: 我正在考虑使用Elasticsearch建立排名。如果我索引根据分数排序的元素列表。我可以按元素名称查询并获得其在索引上的位置吗? 例如我建立一个包含两个元素的索引: “ Element1”,得分:8“ Element2”,得分:7“ Element3”,得分:10 当我通过“ Element2”查询时,我想获得position = 3 问题答案: Elasticsearch在实际收集