elassandra多类型Map

niwlg2el  于 2021-06-15  发布在  Cassandra
关注(0)|答案(2)|浏览(452)

我用elassandra在邮件中搜索,cassandra保存邮件,elasticsearch在这些邮件中搜索。
我的问题是,由于ElasticSearch6,我们不能在一个Map中使用多个类型。这是我的Map:

"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表中进行搜索?

xwbd5t1u

xwbd5t1u1#

正如@alex所说,您需要为每个es索引Map一个表,但是您可以为每个键空间创建多个es索引,Map到不同的表。
必须指定键空间名称作为索引设置。这是通过以下语法完成的:

curl -XPUT "http://localhost:9200/your_index/" -d '{
    "settings" : { "keyspace" : "your_keyspace" },
    "mappings" : {
        "your_table" : {
            "properties" : {
                ...
            }
        }
    }
}
qcuzuvrc

qcuzuvrc2#

由于es6,每个索引需要Map一个表。搜索多个索引:
https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html

相关问题