运行带有6个节点集群的DataStax Enterprise Server 4.6.0,此表中只有1条新记录:
CREATE TABLE tweets.tweets (uid bigint, tweet_id bigint,
tweet text,created timestamp,PRIMARY KEY (uid , created) )
WITH CLUSTERING ORDER BY (created DESC);
schema.xml如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="tweets" version="1.1">
<types>
<fieldType name="bigint" class="solr.TrieLongField"/>
<fieldType name="timestamp" class="solr.TrieDateField"/>
<fieldType name="text" class="solr.TextField">
<analyzer><tokenizer class="solr.StandardTokenizerFactory"/></analyzer>
</fieldType>
</types>
<fields>
<field name="uid" type="bigint" indexed="true" stored="true"/>
<field name="tweet_id" type="bigint" indexed="true" stored="true"/>
<field name="tweet" type="text" indexed="true" stored="false"/>
<field name="created" type="timestamp" indexed="true" stored="false"/>
</fields>
<defaultSearchField>tweet</defaultSearchField>
<uniqueKey>(uid,tweet_id)</uniqueKey>
</schema>
每当我跑:
curl "http://localhost:8983/solr/admin/cores?action=CREATE&name=tweets.tweets"
我明白了:
... java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Mismatch between Solr key field tweet_id with type bigint{class=org.apache.solr.schema.TrieLongField,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer,args={class=solr.TrieLongField}} and Cassandra key alias created with type timestamp
at com.datastax.bdp.search.solr.core.Cql3CassandraSolrSchemaUpdater.validateUniqueKeyStructure(Cql3CassandraSolrSchemaUpdater.java:234)
at com.datastax.bdp.search.solr.core.Cql3CassandraSolrSchemaUpdater.update(Cql3CassandraSolrSchemaUpdater.java:46)
at com.datastax.bdp.search.solr.core.CassandraCoreContainer.create(CassandraCoreContainer.java:275)
... 31 more
</str><int name="code">500</int></lst><str name="params">name=tweets.tweets&action=CREATE</str>
非常令人困惑的错误......“类型为bigint的Solr键字段tweet_id”与“使用类型时间戳创建的Cassandra键别名”有什么关系?
答案 0 :(得分:2)
您的主键应与您的唯一键匹配。为什么不让DSE自动生成架构xml。