无法为Cassandra键空间创建Elasticsearch映射

时间:2019-01-30 07:18:58

标签: elasticsearch cassandra elassandra

目前,我正在尝试Elassandra(Elasticsearch和Cassandra的组合)。我现在有一个带有表的Cassandra键空间,想要创建一个到Elasticsearch的映射,以便可以使用Elasticsearch API搜索/过滤数据。

不幸的是,它不起作用,我不确定为什么会这样。

首先,我向Elasticsearch HTTP端点发出PUT请求以创建映射:

{
    "settings": {
        "keyspace": "my_keyspace"
    },
    "mapping": {
        "sensordatatable": {
            "discover": ".*"
        },
        "eventtable": {
                "discover": ".*"
        }
    }
} 

然后我得到这个答案:

{
    "error": {
        "root_cause": [
            {
                "type": "settings_exception",
                "reason": "Cannot create index, underlying keyspace requires the NetworkTopologyStrategy."
            }
        ],
        "type": "settings_exception",
        "reason": "Cannot create index, underlying keyspace requires the NetworkTopologyStrategy."
    },
    "status": 500
}

在此帖子(https://github.com/strapdata/elassandra/issues/44#issuecomment-253055846)中,某人还使用了SimpleStrategy,它似乎很适合他。有人可以向我解释为什么我必须使用NetworkTopologyStrategy吗?

1 个答案:

答案 0 :(得分:0)

从Elassandra 5+开始,仅支持<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">> <EditText android:layout_width ="match_parent" android:layout_height="wrap_content" /> <Button android:layout_width ="match_parent" android:layout_height="wrap_content" android:text ="CALCULATE" /> <LinearLayout android:layout_width ="match_parent" android:layout_height="wrap_content"> <TextView android:text ="Tip" android:layout_width ="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width ="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:layout_width ="match_parent" android:layout_height="wrap_content"> <TextView android:text ="Total" android:layout_width ="wrap_content" android:layout_height="match_parent" /> <TextView android:layout_width ="wrap_content" android:layout_height="match_parent" /> </LinearLayout> </LinearLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" app:srcCompat="@android:drawable/ic_dialog_email" /> </RelativeLayout> ,尽管也没有阻止支持NetworkTopologyStrategy的技术问题。 SimpleStrategy通常只是首选,因为它允许您扩展多个数据中心。

顺便说一句,您正在尝试在两个表上创建索引。但是从版本6开始,Elasticsearch每个索引仅支持一种类型。如果需要在同一键空间中索引两个表,则可以创建两个单独的索引:

NetworkTopologyStrategy

和:

PUT sensordata
{
    "settings": {
        "keyspace": "my_keyspace"
    },
    "mapping": {
        "_doc": {
            "discover": ".*"
        }
    }
}