请问这是什么原因。这是代码
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/