douning5041 2018-12-02 07:43
浏览 167
已采纳

在字段ElasticSearch 6.4.3上未声明类型关键字的处理程序

I wonder what the cause is. This is the code

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)
    // }

}

I received an error, No Handler for Type Keyword declared on Field ElasticSearch 6.4.3. Based on the information that I got, ES 6.4.3 should use type keyword. I have no idea that my code is not working.

Does anyone know what the mistake is?

Thanks

  • 写回答

1条回答 默认 最新

  • dp152153 2018-12-02 08:01
    关注

    You have misspelled "keyword" as "keyowrd" for "message" field. Corrected below:

    {
            "mappings" : {
                "log" : {
                    "properties" : {
                        "app" : { "type" : "keyword" },
                        "message" : { "type" : "keyword" },
                        "time" : { "type" : "date" }
                    }
                }
            }
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同