无法索引/发现Elassandra中的多个字段

时间:2018-11-05 17:21:19

标签: elasticsearch cassandra elassandra

尝试在现有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”}},

1 个答案:

答案 0 :(得分: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"}
      }
    }
  }
}'