1

我使用 Elassandra 在邮件中进行搜索,使用 Cassandra 保存邮件,使用 ElasticSearch 在这些邮件中进行搜索。

我的问题是,从 ElasticSearch 6 开始,我们不能在一个映射中使用多种类型。这是我的映射:

"mappings": {
    "mail__mail": {
        "discover" : ".*",
        "properties": {
            "mailfrom": { 
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "ngram": {
                        "type": "text",
                        "analyzer": "edge_ngram_analyzer",
                        "search_analyzer": "edge_ngram_search_analyzer"
                    }
                }
            },
            "subject": { 
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "ngram": {
                        "type": "text",
                        "analyzer": "edge_ngram_analyzer",
                        "search_analyzer": "edge_ngram_search_analyzer"
                    }
                }
            },
            "date" : {
                "type" : "date"
            },
            "folderid" : {
                "type" : "text"
            }
        }
    },
    "mail__account" : {
        "discover" : ".*",
        "properties": {
            "userId" : {
                "type" : "Integer"
            }
        }
    }
}

如何使用 ElasticSearch 6 在多个 cassandra 表中进行搜索?

4

2 回答 2

1

正如@Alex 所说,您需要为每个 ES 索引映射 1 个表,但您可以为每个键空间创建多个 ES 索引,映射到不同的表。

您必须指定一个键空间名称作为索引设置。这是通过以下语法完成的:

curl -XPUT "http://localhost:9200/your_index/" -d '{
    "settings" : { "keyspace" : "your_keyspace" },
    "mappings" : {
        "your_table" : {
            "properties" : {
                ...
            }
        }
    }
}
于 2018-09-20T11:36:08.920 回答
1

从 ES6 开始,您需要为每个索引映射 1 个表。搜索多个索引:

https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html

于 2018-09-18T15:20:41.530 回答