我无法让ngrams工作。这是我的schema.xml:
<!-- partial-match text search -->
<fieldType class="solr.TextField" name="autosuggest" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="25" side="front"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<!-- partial-match text search -->
<dynamicField name="*_autosuggest" stored="false" type="autosuggest" multiValued="true" indexed="true"/>
<dynamicField name="*_autosuggests" stored="true" type="autosuggest" multiValued="true" indexed="true"/>
可搜索阻止
searchable do
integer :id, :multiple => true
text :username_lower, as: :username_lower_autosuggest
end
但是当我用捆绑exec rake sunspot:solr:reindex 重新索引此代码时,它会给我一个错误,如下所示
Error - RSolr::Error::Http - 500 Internal Server Error - retrying...
Error - RSolr::Error::Http - 500 Internal Server Error - ignoring...
rake aborted!
RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>129},'error'=>{'msg'=>'ERROR: [doc=User 3] unknown field \'username_autosuggest\'','code'=>400}}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">User 3</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"id_im\">3</field><field name=\"confirmed_at_d\">2014-02-19T13:50:57Z</field><field name=\"username_autosuggest\">jeet</field><field name=\"email_lower_autosuggest\">jeet.desai@softwebsolutions.com</field><field name=\"first_name_autosuggest\">Jeet</field><field name=\"last_name_autosuggest\">Desai</field><field name=\"about_me_text\">ROR Developer</field><field name=\"location_text\">Ahmedabad</field><field name=\"education_text\">BE</field><field name=\"occupation_text\">Developer</field></doc><doc><field name=\"id\">User 5</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"id_im\">5</field><field name=\"confirmed_at_d\">2014-02-24T04:39:08Z</field><field name=\"username_autosuggest\">mehul</field><field name=\"email_lower_autosuggest\">mehul@softwebsolutions.com</field><field name=\"first_name_autosuggest\">Mehul</field><field name=\"last_name_autosuggest\">Javia</field><field name=\"about_me_text\">ROR developer</field><field name=\"location_text\">Ahmedabad</field><field name=\"education_text\">BE</field><field name=\"occupation_text\">Service</field></doc><doc><field name=\"id\">User 6</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"id_im\">6</field><field name=\"confirmed_at_d\">2014-03-26T07:34:40Z</field><field name=\"username_autosuggest\">mayankjani</field><field name=\"email_lower_autosuggest\">mayank.jani@softwebsolutions.com</field><field name=\"first_name_autosuggest\">Mayank</field><field name=\"last_name_autosuggest\">Jani</field><field name=\"about_me_text\">technical analyst</field><field name=\"location_text\">Bhavnagar</field><field name=\"education_text\">MCA</field><field name=\"occupation_text\">Software Developer</field></doc><doc><field name=\"id\">User 7</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"id_im\">7</field><field name=\"confirmed_at_d\">2014-03-26T09:24:18Z</field><field name=\"username_autosuggest\">dharajoshi</field><field name=\"email_lower_autosuggest\">dhara.joshi@softwebsolutions.com</field><field name=\"first_name_autosuggest\">Dhara</field><field name=\"last_name_autosuggest\">Joshi</field><field name=\"about_me_text\">Technical Analyst</field><field name=\"location_text\">Surat</field><field name=\"education_text\">French Expert</field><field name=\"occupation_text\">Software developer</field></doc></add>"
Backtrace: /home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:268:in `adapt_response'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications.rb:123:in `block in instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications.rb:123:in `instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:87:in `add'/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:268:in `adapt_response'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications.rb:123:in `block in instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activesupport-3.2.14/lib/active_support/notifications.rb:123:in `instrument'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/rsolr-1.0.9/lib/rsolr/client.rb:87:in `add'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/indexer.rb:106:in `add_documents'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/indexer.rb:30:in `add'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/session.rb:91:in `index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb:17:in `method_missing'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot.rb:184:in `index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/newrelic_rpm-3.7.1.182/lib/new_relic/agent/method_tracer.rb:524:in `block in index_with_trace_SolrClient_Sunspot_index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/newrelic_rpm-3.7.1.182/lib/new_relic/agent/method_tracer.rb:276:in `trace_execution_scoped'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/newrelic_rpm-3.7.1.182/lib/new_relic/agent/method_tracer.rb:519:in `index_with_trace_SolrClient_Sunspot_index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:257:in `block (2 levels) in solr_index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:360:in `solr_benchmark'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:256:in `block in solr_index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/activerecord-3.2.14/lib/active_record/relation/batches.rb:72:in `find_in_batches'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:254:in `solr_index'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:203:in `solr_reindex'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/tasks.rb:57:in `block (4 levels) in <top (required)>'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/class_set.rb:16:in `each'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot-2.1.0/lib/sunspot/class_set.rb:16:in `each'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/tasks.rb:56:in `block (3 levels) in <top (required)>'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/tasks.rb:68:in `with_session'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/gems/sunspot_rails-2.1.0/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/bin/ruby_executable_hooks:15:in `eval'
/home/jeet/.rvm/gems/ruby-2.0.0-p451@yostalgia/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
(See full trace by running task with --trace)
我无法追踪问题,因为我也在关注太阳黑子文档。
请提出一个正确的方向,因为我从最近1天起被吸收了
由于