Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Solr唯一键的最大长度_Solr_Datastax Enterprise - Fatal编程技术网

Solr唯一键的最大长度

Solr唯一键的最大长度,solr,datastax-enterprise,Solr,Datastax Enterprise,我有一个带有4字段复合键的CQL表,我想在Solr中对其进行索引。所有4个复合PK字段在CQL中均为“文本”类型,在Solr中均为“字符串”类型;其中2个可能包含长字符串。当我初始化Solr core时,我在system.log中看到以下许多警告消息: 实际的消息要比这个长得多(一行200000多个字符),但为了可读性,我把它截断了。从初始化core到索引过程提前终止(是的,Solr无法索引我的数据),这种警告的连续流会淹没我的日志文件 来自MySQL的背景,我知道PKs有一个最大长度(MyS

我有一个带有4字段复合键的CQL表,我想在Solr中对其进行索引。所有4个复合PK字段在CQL中均为“文本”类型,在Solr中均为“字符串”类型;其中2个可能包含长字符串。当我初始化Solr core时,我在system.log中看到以下许多警告消息:

实际的消息要比这个长得多(一行200000多个字符),但为了可读性,我把它截断了。从初始化core到索引过程提前终止(是的,Solr无法索引我的数据),这种警告的连续流会淹没我的日志文件

来自MySQL的背景,我知道PKs有一个最大长度(MySQL中为700字节);因此,即使Cassandra或Solr文档中没有提到类似的限制,我所做的第一件事就是用一个简单的文本键替换CQL复合键,该文本键包含先前属于复合PK的4个字段的sha-1哈希。警告消失了,索尔能够索引我的数据。所以我现在的问题是,Solr对uniqueKey的长度有限制吗?Cassandra似乎对长复合PK没有问题(因为我可以通过CQL查询我的一些数据),但Solr似乎有一个限制

更新:

CREATE TABLE myks.mycf (
  phrase text,
  host text,
  domain text,
  path text,
  created timestamp,
  modified timestamp,

  attr1 int,
  attr2 bigint,
  attr3 double,
  attr4 int,
  attr5 bigint,
  attr6 bigint,
  attr7 double,
  attr8 double,

  scores map<text,int>,
  estimates map<text,bigint>,
  searches map<text,bigint>,

  PRIMARY KEY (phrase,domain,host,path),
) WITH gc_grace_seconds = 1296000
AND compaction={'class': 'LeveledCompactionStrategy'}
AND compression={'sstable_compression': 'LZ4Compressor'}
<schema name="myks" version="1.5">
  <types>
    <fieldType name="text" class="solr.TextField">
     <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
     </analyzer>
    </fieldType>
    <fieldType name="string" class="solr.StrField" omitNorms="true"/>
    <fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
    <fieldtype name="binary" class="solr.BinaryField"/>
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
    <fieldType name="date" class="solr.TrieDateField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
  </types>
  <fields>
    <field name="phrase" type="string" indexed="true" stored="true"/>
    <field name="host" type="string" indexed="true" stored="true"/>
    <field name="domain" type="string" indexed="true" stored="true"/>
    <field name="path" type="string" indexed="true" stored="true"/>
    <field name="created" type="date" indexed="true" stored="true"/>
    <field name="modified" type="date" indexed="true" stored="true"/>

    <field name="attr1" type="int" indexed="true" stored="true"/>
    <field name="attr2" type="long" indexed="true" stored="true"/>
    <field name="attr3" type="double" indexed="true" stored="true"/>
    <field name="attr4" type="int" indexed="true" stored="true"/>
    <field name="attr5" type="long" indexed="true" stored="true"/> 
    <field name="attr6" type="long" indexed="true" stored="true"/>
    <field name="attr7" type="double" indexed="true" stored="true"/>
    <field name="attr8" type="double" indexed="true" stored="true"/>

    <!-- CQL collection maps -->
    <dynamicField name="scores*" type="int" indexed="true" stored="true"/>
    <dynamicField name="estimates*" type="long" indexed="true" stored="true"/>
    <dynamicField name="searches*" type="long" indexed="true" stored="true"/>

    <!-- docValues - facet -->
    <field name="dv__domain" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>
    <field name="dv__attr4" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
    <field name="dv__attr8" type="double" indexed="true" stored="false" docValues="true" multiValued="true"/>

    <!-- docValues - group -->
    <field name="dv__phrase" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>

    <!-- docValues - sort -->
    <field name="dv__attr2" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
    <field name="dv__attr5" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
    <field name="dv__attr1" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
  </fields>

  <!-- Why we use copyFields for docValues: http://stackoverflow.com/questions/26495208/solr-docvalues-usage -->
  <copyField source="domain" dest="dv__domain"/>
  <copyField source="attr4" dest="dv__attr4"/>
  <copyField source="attr8" dest="dv__attr8"/>
  <copyField source="phrase" dest="dv__phrase"/>
  <copyField source="attr2" dest="dv__attr2"/>
  <copyField source="attr5" dest="dv__attr5"/>
  <copyField source="attr1" dest="dv__attr1"/>

  <defaultSearchField>phrase</defaultSearchField>
  <uniqueKey>(phrase,domain,host,path)</uniqueKey>
</schema>
在进一步测试之后,我发现不知何故,正是我的表模式中的复合PK和CQL映射的混合导致了Solr索引问题

  • 复合主键+无映射(被许多列替换)=有效
  • 简单PK(复合PK列的sha-1哈希)+映射=工作
  • 复合PK+maps=不起作用
  • 我仍然不确定这个问题是否与我的数据长度有关

    CQL表架构:

    CREATE TABLE myks.mycf (
      phrase text,
      host text,
      domain text,
      path text,
      created timestamp,
      modified timestamp,
    
      attr1 int,
      attr2 bigint,
      attr3 double,
      attr4 int,
      attr5 bigint,
      attr6 bigint,
      attr7 double,
      attr8 double,
    
      scores map<text,int>,
      estimates map<text,bigint>,
      searches map<text,bigint>,
    
      PRIMARY KEY (phrase,domain,host,path),
    ) WITH gc_grace_seconds = 1296000
    AND compaction={'class': 'LeveledCompactionStrategy'}
    AND compression={'sstable_compression': 'LZ4Compressor'}
    
    <schema name="myks" version="1.5">
      <types>
        <fieldType name="text" class="solr.TextField">
         <analyzer>
            <tokenizer class="solr.StandardTokenizerFactory"/>
         </analyzer>
        </fieldType>
        <fieldType name="string" class="solr.StrField" omitNorms="true"/>
        <fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
        <fieldtype name="binary" class="solr.BinaryField"/>
        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="date" class="solr.TrieDateField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
      </types>
      <fields>
        <field name="phrase" type="string" indexed="true" stored="true"/>
        <field name="host" type="string" indexed="true" stored="true"/>
        <field name="domain" type="string" indexed="true" stored="true"/>
        <field name="path" type="string" indexed="true" stored="true"/>
        <field name="created" type="date" indexed="true" stored="true"/>
        <field name="modified" type="date" indexed="true" stored="true"/>
    
        <field name="attr1" type="int" indexed="true" stored="true"/>
        <field name="attr2" type="long" indexed="true" stored="true"/>
        <field name="attr3" type="double" indexed="true" stored="true"/>
        <field name="attr4" type="int" indexed="true" stored="true"/>
        <field name="attr5" type="long" indexed="true" stored="true"/> 
        <field name="attr6" type="long" indexed="true" stored="true"/>
        <field name="attr7" type="double" indexed="true" stored="true"/>
        <field name="attr8" type="double" indexed="true" stored="true"/>
    
        <!-- CQL collection maps -->
        <dynamicField name="scores*" type="int" indexed="true" stored="true"/>
        <dynamicField name="estimates*" type="long" indexed="true" stored="true"/>
        <dynamicField name="searches*" type="long" indexed="true" stored="true"/>
    
        <!-- docValues - facet -->
        <field name="dv__domain" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr4" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr8" type="double" indexed="true" stored="false" docValues="true" multiValued="true"/>
    
        <!-- docValues - group -->
        <field name="dv__phrase" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>
    
        <!-- docValues - sort -->
        <field name="dv__attr2" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr5" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr1" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
      </fields>
    
      <!-- Why we use copyFields for docValues: http://stackoverflow.com/questions/26495208/solr-docvalues-usage -->
      <copyField source="domain" dest="dv__domain"/>
      <copyField source="attr4" dest="dv__attr4"/>
      <copyField source="attr8" dest="dv__attr8"/>
      <copyField source="phrase" dest="dv__phrase"/>
      <copyField source="attr2" dest="dv__attr2"/>
      <copyField source="attr5" dest="dv__attr5"/>
      <copyField source="attr1" dest="dv__attr1"/>
    
      <defaultSearchField>phrase</defaultSearchField>
      <uniqueKey>(phrase,domain,host,path)</uniqueKey>
    </schema>
    
    创建表myks.mycf(
    短语文本,
    主机文本,
    域文本,
    路径文本,
    创建时间戳,
    修改的时间戳,
    属性1 int,
    attr2 bigint,
    3双,
    属性4 int,
    attr5 bigint,
    attr6 bigint,
    7双,
    8双,
    分数地图,
    估计地图,
    搜索地图,
    主键(短语、域、主机、路径),
    )gc_grace_秒=1296000
    和压缩={'class':'LeveledCompactionStrategy'}
    AND compression={'sstable_compression':'LZ4Compressor'}
    
    Solr模式:

    CREATE TABLE myks.mycf (
      phrase text,
      host text,
      domain text,
      path text,
      created timestamp,
      modified timestamp,
    
      attr1 int,
      attr2 bigint,
      attr3 double,
      attr4 int,
      attr5 bigint,
      attr6 bigint,
      attr7 double,
      attr8 double,
    
      scores map<text,int>,
      estimates map<text,bigint>,
      searches map<text,bigint>,
    
      PRIMARY KEY (phrase,domain,host,path),
    ) WITH gc_grace_seconds = 1296000
    AND compaction={'class': 'LeveledCompactionStrategy'}
    AND compression={'sstable_compression': 'LZ4Compressor'}
    
    <schema name="myks" version="1.5">
      <types>
        <fieldType name="text" class="solr.TextField">
         <analyzer>
            <tokenizer class="solr.StandardTokenizerFactory"/>
         </analyzer>
        </fieldType>
        <fieldType name="string" class="solr.StrField" omitNorms="true"/>
        <fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
        <fieldtype name="binary" class="solr.BinaryField"/>
        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="date" class="solr.TrieDateField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
      </types>
      <fields>
        <field name="phrase" type="string" indexed="true" stored="true"/>
        <field name="host" type="string" indexed="true" stored="true"/>
        <field name="domain" type="string" indexed="true" stored="true"/>
        <field name="path" type="string" indexed="true" stored="true"/>
        <field name="created" type="date" indexed="true" stored="true"/>
        <field name="modified" type="date" indexed="true" stored="true"/>
    
        <field name="attr1" type="int" indexed="true" stored="true"/>
        <field name="attr2" type="long" indexed="true" stored="true"/>
        <field name="attr3" type="double" indexed="true" stored="true"/>
        <field name="attr4" type="int" indexed="true" stored="true"/>
        <field name="attr5" type="long" indexed="true" stored="true"/> 
        <field name="attr6" type="long" indexed="true" stored="true"/>
        <field name="attr7" type="double" indexed="true" stored="true"/>
        <field name="attr8" type="double" indexed="true" stored="true"/>
    
        <!-- CQL collection maps -->
        <dynamicField name="scores*" type="int" indexed="true" stored="true"/>
        <dynamicField name="estimates*" type="long" indexed="true" stored="true"/>
        <dynamicField name="searches*" type="long" indexed="true" stored="true"/>
    
        <!-- docValues - facet -->
        <field name="dv__domain" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr4" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr8" type="double" indexed="true" stored="false" docValues="true" multiValued="true"/>
    
        <!-- docValues - group -->
        <field name="dv__phrase" type="string" indexed="true" stored="false" docValues="true" multiValued="true"/>
    
        <!-- docValues - sort -->
        <field name="dv__attr2" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr5" type="long" indexed="true" stored="false" docValues="true" multiValued="true"/>
        <field name="dv__attr1" type="int" indexed="true" stored="false" docValues="true" multiValued="true"/>
      </fields>
    
      <!-- Why we use copyFields for docValues: http://stackoverflow.com/questions/26495208/solr-docvalues-usage -->
      <copyField source="domain" dest="dv__domain"/>
      <copyField source="attr4" dest="dv__attr4"/>
      <copyField source="attr8" dest="dv__attr8"/>
      <copyField source="phrase" dest="dv__phrase"/>
      <copyField source="attr2" dest="dv__attr2"/>
      <copyField source="attr5" dest="dv__attr5"/>
      <copyField source="attr1" dest="dv__attr1"/>
    
      <defaultSearchField>phrase</defaultSearchField>
      <uniqueKey>(phrase,domain,host,path)</uniqueKey>
    </schema>
    
    
    短语
    (短语、域、主机、路径)
    
    我使用
    cqlstablewriter
    从MySQL转储的CSV生成sstables。对于CQL映射,我选择Java
    HashMap
    来表示值


    我今天还发现,即使是卡桑德拉似乎也对化合物PK和maps的混合存在问题。当我查看文件系统时,使用复合PK+映射的表副本的文件夹大小比使用简单PK+映射或复合PK+无映射的表副本的文件夹大小小得多

    Cassandra的密钥限制为64K

    通常在Solr中,“text”不应用于键,因为它是标记化的。改为使用“字符串”字段

    正如Cassandra FAQ wiki所指出的,对于使用长文本值作为键,哈希是更好的选择:

    归根结底,这取决于您希望如何查询Solr文档


    Solr中“限制”的一般指导原则就是“合理”——任何大的事情都很可能在某个地方给你带来问题。

    感谢你指出卡桑德拉的限制。至于我的Solr模式,我在OP中不是很清楚,但我的字段类型在Solr中实际上是“字符串”-“文本”类型在相应的CQL模式中。你能确认我是否达到了Solr限制吗?我希望尽可能避免使用简单的散列PK,因为它会阻止我进行部分CQL筛选(即在复合PK列的子集上进行多个筛选)。我的大多数读取操作都是通过Solr进行的,但有些(如Spark生成的)是CQL。您能分享创建core时看到的错误吗?我创建core时没有错误。这个问题发生在索引过程中。我尝试了两种变体:1。创建表,将所有数据导入Cassandra,然后初始化Solr核心;2.创建表,初始化Solr核心,然后导入所有数据。这两种情况导致了相同的情况-每个节点中的索引过程最多达到2%(通常为0%或1%),并且除了充斥系统的许多警告线之外,没有任何错误消息退出。logHmm好的,我是问的,因为墓碑错误实际上与cassandra有关。不确定它们会如何影响索引。您正在进行大量删除吗?不。这是一个尚未在生产中使用的表(仍处于批量加载阶段)。此外,请参阅OP中的“我的更新”。如果您共享您的表格,可能会给出一个俱乐部,您将尝试复制。