dse solr建议者状态403-未知命令“建议”

时间:2018-12-13 14:14:57

标签: solr cassandra datastax-enterprise

我至少跟踪了十二个不同的示例,所有这些示例看起来几乎都是相同的。我正在使用DSE 5.1和SOLR并尝试使用建议程序。这是我的配置(大部分来自示例):

  <searchComponent name="suggest" class="solr.SuggestComponent">
     <lst name="suggester">
       <str name="name">titleSuggester</str>
       <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
       <str name="dictionaryImpl">DocumentDictionaryFactory</str>
       <str name="suggestAnalyzerFieldType">TextField</str>
       <str name="field">title</str>
       <str name="weightField">rating</str>
       <str name="payloadField">description</str>
     </lst>
  </searchComponent>
  <requestHandler name="/suggest" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="suggest">true</str>
      <str name="suggest.count">10</str>
    </lst>
    <arr name="components">
       <str>suggest</str>
    </arr>
  </requestHandler>

当我尝试运行curl在本地主机上访问它时,我得到:

message Unknown command 'suggest' in request
   description Access to the specified resource has been forbidden

这是curl命令:

curl --user myuser:mypass \
 "http://localhost:8983/solr/test.movies/suggest?suggest=true&suggest.dictionary=titleSuggester&suggest.q=Po"

无法弄清楚我的一生为什么我的实现无法正常工作。有什么想法吗?

以下是用于描述配置的注释的输出:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
  <luceneMatchVersion>LUCENE_6_0_1</luceneMatchVersion>
  <dseTypeMappingVersion>2</dseTypeMappingVersion>
  <directoryFactory class="solr.StandardDirectoryFactory" name="DirectoryFactory"/>
  <indexConfig>
    <ramBufferSizeMB>512</ramBufferSizeMB>
    <rt>false</rt>
  </indexConfi`enter code here`g>
  <jmx/>
  <updateHandler>
    <autoSoftCommit>
      <maxTime>10000</maxTime>
    </autoSoftCommit>
  </updateHandler>
  <query>
    <filterCache class="solr.SolrFilterCache" highWaterMarkMB="2048" lowWaterMarkMB="1024"/>
    <enableLazyFieldLoading>true</enableLazyFieldLoading>
    <useColdSearcher>true</useColdSearcher>
    <maxWarmingSearchers>16</maxWarmingSearchers>
  </query>
  <requestDispatcher>
    <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048000"/>
    <httpCaching never304="true"/>
  </requestDispatcher>
  <requestHandler class="solr.SearchHandler" default="true" name="search"/>
  <requestHandler class="com.datastax.bdp.search.solr.handler.component.CqlSearchHandler" name="solr_query"/>
  <requestHandler class="solr.UpdateRequestHandler" name="/update"/>
  <requestHandler class="solr.UpdateRequestHandler" name="/update/csv" startup="lazy"/>
  <requestHandler class="solr.UpdateRequestHandler" name="/update/json" startup="lazy"/>
  <requestHandler class="solr.FieldAnalysisRequestHandler" name="/analysis/field" startup="lazy"/>
  <requestHandler class="solr.DocumentAnalysisRequestHandler" name="/analysis/document" startup="lazy"/>
  <requestHandler class="solr.admin.AdminHandlers" name="/admin/"/>
  <requestHandler class="solr.PingRequestHandler" name="/admin/ping">
    <lst name="invariants">
      <str name="qt">search</str>
      <str name="q">solrpingquery</str>
    </lst>
    <lst name="defaults">
      <str name="echoParams">all</str>
    </lst>
  </requestHandler>
  <requestHandler class="solr.DumpRequestHandler" name="/debug/dump">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <str name="echoHandler">true</str>
    </lst>
  </requestHandler>
  <searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
      <str name="name">titleSuggester</str>
      <str name="lookupImpl">FSTLookupFactory</str>
      <str name="dictionaryImpl">DocumentDictionaryFactory</str>
      <str name="field">title</str>
      <str name="weightField">rating</str>
      <str name="suggestAnalyzerFieldType">TextField</str>
      <str name="payloadField">description</str>
      <str name="buildOnStartup">true</str>
    </lst>
  </searchComponent>
  <requestHandler name="/suggest" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="suggest">true</str>
      <str name="suggest.count">10</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>
</config>

这是表格上的describe的输出:

CREATE TABLE test.movies (
    title text PRIMARY KEY,
    author text,
    description text,
    rating float,
    release_date timestamp,
    solr_query text
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';
CREATE CUSTOM INDEX test_movies_solr_query_index ON test.movies (solr_query) USING 'com.datastax.bdp.search.solr.Cql3SolrSecondaryIndex';

describe active search index schema on test.movies;

<?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="org.apache.solr.schema.TrieDateField" name="TrieDateField"/>
    <fieldType class="org.apache.solr.schema.TrieFloatField" name="TrieFloatField"/>
    <fieldType class="org.apache.solr.schema.TextField" name="TextField">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>
  </types>
  <fields>
    <field indexed="true" multiValued="false" name="title" stored="true" type="StrField"/>
    <field docValues="true" indexed="true" multiValued="false" name="release_date" stored="true" type="TrieDateField"/>
    <field docValues="true" indexed="true" multiValued="false" name="rating" stored="true" type="TrieFloatField"/>
    <field indexed="true" multiValued="false" name="author" stored="true" type="TextField"/>
    <field indexed="true" multiValued="false" name="description" stored="true" type="TextField"/>
  </fields>
  <uniqueKey>title</uniqueKey>
</schema>

1 个答案:

答案 0 :(得分:0)

我无法完全重现此问题-当我使用FSTLookupFactory实现时,DSE 5.1.11抛出NullPointerException。但是我使它可以与AnalyzingInfixLookupFactory实现并遵循以下配置一起使用:

  <searchComponent class="solr.SuggestComponent" name="suggest">
    <lst name="suggester">
      <str name="name">titleSuggester</str>
      <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
      <str name="dictionaryImpl">DocumentDictionaryFactory</str>
      <str name="suggestAnalyzerFieldType">TextField</str>
      <str name="field">title</str>
      <str name="weightField">rating</str>
      <str name="buildOnCommit">true</str>
      <str name="exactMatchFirst">true</str>
      <str name="payloadField">description</str>
    </lst>
  </searchComponent>
通过遵循CQL生成的

(比使用XML文件更可取):

CREATE SEARCH INDEX ON test.movies WITH OPTIONS { reindex : false };
ALTER SEARCH INDEX SCHEMA ON test.movies SET field[@name='title']@type='StrField';
ALTER SEARCH INDEX SCHEMA ON test.movies SET field[@name='description']@type='TextField';

// create suggestion component & corresponding request handler.
ALTER SEARCH INDEX CONFIG ON test.movies ADD searchComponent[@name='suggest',@class='solr.SuggestComponent'] 
WITH  $$ {"suggester":[{"name":"titleSuggester"}, {"lookupImpl":"AnalyzingInfixLookupFactory"}, {"dictionaryImpl":"DocumentDictionaryFactory"},
{"suggestAnalyzerFieldType":"TextField"}, {"field":"title"}, {"weightField":"rating"}, {"buildOnCommit":"true"}, {"exactMatchFirst":"true"}, {"payloadField": "description"}]} $$;
ALTER SEARCH INDEX CONFIG ON test.movies ADD requestHandler[@name='/suggest',@class='solr.SearchHandler'] 
WITH  $$ {"defaults":[{"suggest":"true"}, {"suggest.count":"10"}],"components":["suggest"]} $$;
RELOAD SEARCH INDEX ON test.movies;

它有效:

>curl 'http://localhost:8983/solr/test.movies/suggest?suggest=true&suggest.dictionary=titleSuggester&suggest.q=best&wt=json'
{"responseHeader":{"status":0,"QTime":1},
   "suggest":{"titleSuggester":{"best":{"numFound":1,
   "suggestions":[{"term":"the <b>best</b> movie","weight":1,
      "payload":"super movie"}]}}}}