弹性搜索多语言支持

时间:2014-03-11 13:16:46

标签: elasticsearch multilingual

我想在弹性搜索中存储多种语言的推文并搜索它们。我尝试使用以下映射存储推文,但无法搜索除英语之外的其他内容。我确定通过弹性搜索为每种支持的语言正确生成了lang字段。有人可以帮助我理解如何进行多语言搜索。

{
"mappings": {
    "tweet": {
        "_analyzer": { "path": "lang" },
        "_all": { "enabled": "false" },
        "properties": {
            "screename": {"type": "string", "store": "yes", index: "not_analyzed" },
            "id": {"type": "string", "store": "yes", index: "not_analyzed" },               
            "createdAt": {"type": "date", "store": "yes", "format": "yyyy-MM-dd HH:mm:ss" }
            "message": {
                "type": "multi_field",
                "fields": {
                    "message": { "type": "string", "index": "analyzed", "store": "yes" }
                    "default": {"type": "string", "index": "analyzed", "store": "yes", "analyzer": "simple" }
                }
            },
            "lang": {"type": "string", "index": "not_analyzed", "store": "yes" }                
        }
    }
}

}

有关信息,我将语言字段填充为lang-detect google api的以下基础之一,如果api无法识别语言,则lang字段为空。

Arabic Bulgarian Simplified Chinese Traditional Chinese Czech Dannish Dutch English Finnish French German Greek Hindi Hungarian Indonesian Italian Norwegian Persian Portuguese Romanian Russian Spanish Swedish Thai Turkish

0 个答案:

没有答案