0

尝试在现有 Cassandra 表中的多个字段(发现 2 个字段)上创建索引,如下代码所示。

curl -XPUT -H 'Content-Type: application/json' 'http://x.x.x.x:9200/final_index' -d '
{
  "settings" : {"keyspace" : "keyspace1"},
  "mappings" : {
    "table1" : {
      "discover" : ["to_address", "sent_date"],
      "properties" : {
        "to_address" : {"type" : "keyword"},
        "sent_date" : {"type" : "date", "format": "yyyy-MM-dd HH:mm:ssZZ"}
      }
    }
  }
}'

错误: “caused_by”:{“type”:“class_cast_exception”,“reason”:“java.util.ArrayList 无法转换为 java.lang.String”}},

4

1 回答 1

1

需要如下发现必填字段,其余字段需要将 Index 设置为 false。

curl -XPUT -H 'Content-Type: application/json' 'http://x.x.x.x:9200/final_index' -d '
{
  "settings" : {"keyspace" : "keyspace1"},
  "mappings" : {
    "table1" : {
      "discover" : (to_address|sent_date),
      "properties" : {
        "to_address" : {"type" : "keyword"},
        "sent_date" : {"type" : "date", "format": "yyyy-MM-dd HH:mm:ssZZ"},
        "contact_number" : {"index" : "false"}
      }
    }
  }
}'
于 2018-11-28T16:15:23.360 回答