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" }
                    }
                }
            }
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!