DSE 6.7 Solr Searh始终返回空

时间:2019-01-23 09:41:28

标签: solr cassandra datastax-enterprise

我正在使用具有3个节点的DSE 6.7,每个节点128个虚拟节点。 我已经配置solr IKAnalyzer来搜索中文文本。如下图所示,它在solr控制台中测试正常: enter image description here

但是在查询中不能正常测试,总是返回空数据。

enter image description here

然后我在cassandra devCenter中测试,是否相同,返回数据计数不为空,但数据始终为空? enter image description here enter image description here

有人可以帮我吗?

表定义

<component
  :is="subQuestion.component"
  :parentQuestion="question"
  :question="subQuestion" />

Solr模式:

CREATE TABLE IF NOT EXISTS rawdata.tax_law (
    type text,
    cityname text,
    items text,
    title text,
    link text,
    accessory text,
    content text,
    article date text,
    number text,
    pubdate date,
    valid text,
    PRIMARY KEY (title, type, date)
);

在此处发布我的简单表架构和测试数据,下面的查询返回空值。

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <schema name="autoSolrSchema" version="1.5">   <types>
    <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
    <fieldType class="com.datastax.bdp.search.solr.core.types.SimpleDateField" name="SimpleDateField"/>
    <fieldType name="text_ik" class="solr.TextField">
        <analyzer type="index" useSmart="false" >
                <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
        </analyzer>
        <analyzer type="query" useSmart="true" >
                <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
        </analyzer>
    </fieldType>   </types>   <fields>
    <field indexed="true" multiValued="false" name="title" stored="true" type="StrField"/>
    <field indexed="true" multiValued="false" name="items" type="StrField"/>
    <field indexed="true" multiValued="false" name="article_date" type="StrField"/>
    <field indexed="true" multiValued="false" name="cityname" type="StrField"/>
    <field indexed="true" multiValued="false" name="number" type="StrField"/>
    <field docValues="true" indexed="true" multiValued="false" name="pubdate" type="SimpleDateField"/>
    <field indexed="true" multiValued="false" name="content" stored="true" type="text_ik"/>
    <field indexed="true" multiValued="false" name="link" type="StrField"/>
    <field indexed="true" multiValued="false" name="type" type="StrField"/>
    <field indexed="true" multiValued="false" name="valid" type="StrField"/>
    <field indexed="true" multiValued="false" name="accessory" type="StrField"/>
    <field name="searchText" type="text_ik" indexed="true" stored="false" multiValued="true" />   </fields>   <uniqueKey>(title,type,article_date)</uniqueKey>

  <defaultSearchField>searchText</defaultSearchField>  
     <solrQueryParser defaultOperator="OR" />    <copyField source="title" dest="searchText" />   <copyField source="content" dest="searchText" />   </schema>

enter image description here

3 个答案:

答案 0 :(得分:0)

我正在尝试进行复制,但对我来说还不清楚:似乎type是一个关键字,我不确定表创建/索引创建是否进展顺利。

使用提供的表创建

CREATE TABLE IF NOT EXISTS rawdata.tax_law ( type text, cityname text, items text, title text, link text, accessory text, content text, article date text, number text, pubdate date, valid text, PRIMARY KEY (title, type, date) );

不起作用

您是否不使用dse搜索从纯Cassandra查询中获取正确的数据?

答案 1 :(得分:0)

@peter我做了一些实验,并使用默认的StrText和IK,一切按预期进行:


    cqlsh
    Connected to master at 127.0.0.1:9042.
    [cqlsh 5.0.1 | DSE 6.7.0 | CQL spec 3.4.5 | DSE protocol v2]
    Use HELP for help.
    cqlsh> CREATE KEYSPACE rawdata WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}  AND durable_writes = true;
    cqlsh> 
    cqlsh> CREATE TABLE rawdata.test (
       ...     id int,
       ...     title text,
       ...     content text,
       ...     solr_query text,
       ...     PRIMARY KEY (id, title));
    cqlsh> 
    cqlsh> CREATE TABLE rawdata.test2 (
       ...     id text,
       ...     title text,
       ...     content text,
       ...     solr_query text,
       ...     PRIMARY KEY (id, title));
    cqlsh> 
    cqlsh> CREATE SEARCH INDEX ON rawdata.test;

    Warnings :
    Please remember this operation is DC specific and should be repeated on each desired DC.

    cqlsh> CREATE SEARCH INDEX ON rawdata.test2;

    Warnings :
    Please remember this operation is DC specific and should be repeated on each desired DC.

    cqlsh> 
    cqlsh> insert into rawdata.test2(id, title, content) values ('簇', '我喜欢吃鱼', '我喜欢吃鱼');
    cqlsh> insert into rawdata.test(id, title, content) values (1, '我喜欢吃鱼', '我喜欢吃鱼');
    cqlsh> 
    cqlsh> SELECT * from rawdata.test WHERE solr_query='content:我喜欢吃鱼';

     id | title | content | solr_query
    ----+-------+---------+------------

    (0 rows)
    cqlsh> SELECT * from rawdata.test2 WHERE solr_query='content:我喜欢吃鱼';

     id | title | content | solr_query
    ----+-------+---------+------------

    (0 rows)
    cqlsh> 
    cqlsh> SELECT * from rawdata.test2 WHERE solr_query='content:我喜欢吃鱼';

     id | title | content | solr_query
    ----+-------+---------+------------

    (0 rows)
    cqlsh> SELECT * from rawdata.test2 WHERE solr_query='content:我喜欢吃鱼';

     id | title | content | solr_query
    ----+-------+---------+------------

    (0 rows)
    cqlsh> commit search index on rawdata.test;
    cqlsh> commit search index on rawdata.test2;
    cqlsh> SELECT * from rawdata.test2 WHERE solr_query='content:我喜欢吃鱼';

     id | title      | content    | solr_query
    ----+------------+------------+------------
     簇 | 我喜欢吃鱼 | 我喜欢吃鱼 |       null

    (1 rows)
    cqlsh> SELECT * from rawdata.test WHERE solr_query='content:我喜欢吃鱼';

     id | title      | content    | solr_query
    ----+------------+------------+------------
      1 | 我喜欢吃鱼 | 我喜欢吃鱼 |       null

A我也无法使用IK分析器重现该问题:


    automaton@ip-10-200-175-18:~$ cqlsh
    Connected to master at 127.0.0.1:9042.
    [cqlsh 5.0.1 | DSE 6.7.0 | CQL spec 3.4.5 | DSE protocol v2]
    Use HELP for help.
    cqlsh> describe active search index schema on rawdata.test2;

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <schema name="autoSolrSchema" version="1.5">
      <types>
        <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
        <fieldType name="text_ik" class="solr.TextField">
            <analyzer type="index" useSmart="false" >
                    <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
            </analyzer>
            <analyzer type="query" useSmart="true" >
                    <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
            </analyzer>
        </fieldType>
      </types>
      <fields>
        <field indexed="true" multiValued="false" name="title" type="StrField"/>
        <field indexed="true" multiValued="false" name="content" type="text_ik"/>
        <field indexed="true" multiValued="false" name="id" type="StrField"/>
      </fields>
      <uniqueKey>(id,title)</uniqueKey>
    </schema>



    cqlsh> SELECT * from rawdata.test2 WHERE solr_query='content:我喜欢吃鱼';

     id | title      | content    | solr_query
    ----+------------+------------+------------
     簇 | 我喜欢吃鱼 | 我喜欢吃鱼 |       null

    (1 rows)

也许是导致问题的数据还是集群/客户端上的语言环境? 可以以文本形式共享数据吗?

答案 2 :(得分:0)

我已尝试使用提供的数据,但无法复制。

我正在附加屏幕截图,因为SO编辑器存在错误(我已经报告了)。 enter image description here

请注意,在StrField前缀后面必须加一个星号,而使用IKT则没有必要。

因此,我担心这可能是您身边的一些环境问题,例如群集语言环境?很难说。