【问题标题】:NoMethodError: undefined method `autocomplete' for SunspotNoMethodError:太阳黑子的未定义方法“自动完成”
【发布时间】:2014-06-20 12:39:41
【问题描述】:

嘿,我正在尝试将自动完成功能引入我的应用程序,但它给了我错误。
sunspot-2.1.1/lib/sunspot/dsl/fields.rb:93:in rescue in method_missing': undefined methodautocomplete' for #Sunspot::DSL::Fields:0x000001029b7cd0 (NoMethodError)
以下是我所做的更改。感谢您的帮助。

型号

def category_name
self.name
end

searchable do
text :name
autocomplete :category_name, :as => :name
end

Solr Schema.xml

    <fieldType name="autocomplete" class="solr.TextField" positionIncrementGap="100">
  <!-- The index analyzer adds parts of the field from 2 - 25 chars including whitespace etc. -->
  <analyzer type="index">
    <tokenizer class="solr.NGramTokenizerFactory" minGramSize="2" maxGramSize="25"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <!-- The query analyzer takes the whole input, whitespace and all -->            
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

<fieldType name="autosuggest" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
  <tokenizer class="solr.LetterTokenizerFactory"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="25" />
</analyzer>
<analyzer type="query">
  <tokenizer class="solr.LetterTokenizerFactory"/>
  <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>

HTML

<input id="category_name" name="search" size="30" type="text" /> <script>$('#category_name').autocomplete('http://127.0.0.1:8982/solr/', 'name', {});</script>
                <script>$('#search').autocomplete('http://127.0.0.1.120:8982/solr/', 'search', {});</script>

【问题讨论】:

    标签: ruby-on-rails-3 solr sunspot sunspot-solr


    【解决方案1】:

    我将 JRE 从 openJDK 更改为 Oracle 并重新安装了所有内容。现在可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多