elasticsearch - 没有在 Field ElasticSearch 6.4.3 上声明类型关键字的处理程序

标签 elasticsearch go

请问这是什么原因。这是代码

package main

import (
    "context"
    "errors"
    "fmt"
    "time"

    "github.com/olivere/elastic"
)

const (
    indexName    = "applications"
    docType      = "log"
    appName      = "myApp"
    indexMapping = `{
        "mappings" : {
            "log" : {
                "properties" : {
                    "app" : { "type" : "keyword" },
                    "message" : { "type" : "keyowrd" },
                    "time" : { "type" : "date" }
                }
            }
        }
    }`
)

type Log struct {
    App     string    `json:"app"`
    Message string    `json:"message"`
    Time    time.Time `json:"time"`
}

func main() {

    client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))

    if err != nil {
        panic(err)
    }

    err = createIndexWithLogs(client)
    if err != nil {
        panic(err)
    }

    // err = findAndPrintAppLogs(client)
    // if err != nil {
    //  panic(err)
    // }

}

我收到一个错误,在 Field ElasticSearch 6.4.3 上声明的类型关键字没有处理程序。根据我得到的信息,ES 6.4.3 应该使用 type 关键字。我不知道我的代码不起作用。

有谁知道错误是什么?

谢谢

最佳答案

您将 "keyword" 拼错为 "keyword" 用于 "message" 字段。更正如下:

{
        "mappings" : {
            "log" : {
                "properties" : {
                    "app" : { "type" : "keyword" },
                    "message" : { "type" : "keyword" },
                    "time" : { "type" : "date" }
                }
            }
        }
    }

关于elasticsearch - 没有在 Field ElasticSearch 6.4.3 上声明类型关键字的处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53578367/

相关文章:

go - 在 GoLang 中生成 CosmosDB 身份验证 token

go - 对于选择组问题

elasticsearch - 根据不同文档中同一字段的不同值进行过滤

python - 使用 elastic4s 查询产生零结果

file - golang 阅读更多 4096 字节

go - 找不到文件/无法导入包

mongodb - 在使用MongoDB-mgo插入许多文档的同时,如何忽略重复的键错误并继续插入?

elasticsearch - 带有排名实现的Elasticsearch(v 5.2)标签

elasticsearch - Elasticsearch 2.0如何在Loopback和Non-Loopback接口(interface)上绑定(bind)?

Elasticsearch Sense chrome 插件已禁用,需要获取在控制台中编写的 dsl 查询