Pavel
Pavel

Reputation: 974

Unable to create Solr Core, key type mismatch

Running DataStax Enterprise Server 4.6.0 with 6 node cluster, fresh, only 1 record inside this table:

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 looks like this:

    <?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>

Whenever I run:

curl "http://localhost:8983/solr/admin/cores?action=CREATE&name=tweets.tweets"

I get:

... 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&amp;action=CREATE</str>

Very confusing error ... what does "Solr key field tweet_id with type bigint" have anything to do with "Cassandra key alias created with type timestamp" ?

Upvotes: 1

Views: 666

Answers (1)

phact
phact

Reputation: 7305

Your primary key should match your unique key. Why don't you let DSE generate your schema xml automatically.

Upvotes: 2

Related Questions