Mysql 太阳黑子集合子句中未定义的字段错误
我有属于类别的产品详细信息表。产品详细信息包含id、名称、价格、折扣和类别id等字段,类别表包含id和名称等字段。我正在使用mysql数据库,我正在尝试根据类别id对产品进行分组。要进行分组,我参考了。但是我得到了以下错误Mysql 太阳黑子集合子句中未定义的字段错误,mysql,sunspot,sunspot-rails,sunspot-solr,rsolr,Mysql,Sunspot,Sunspot Rails,Sunspot Solr,Rsolr,我有属于类别的产品详细信息表。产品详细信息包含id、名称、价格、折扣和类别id等字段,类别表包含id和名称等字段。我正在使用mysql数据库,我正在尝试根据类别id对产品进行分组。要进行分组,我参考了。但是我得到了以下错误 RSolr::Error::Http - 400 Bad Request Error: undefined field category_id 我的模型看起来像这样 class ProductDetail < ActiveRecord::Base
RSolr::Error::Http - 400 Bad Request
Error: undefined field category_id
我的模型看起来像这样
class ProductDetail < ActiveRecord::Base
belongs_to :category
searchable do
text :name
integer :category_id
end
end
在我的日志文件中,我的
class ProductDetail < ActiveRecord::Base
belongs_to :category
searchable do
text :name
integer :category_id
end
end
RSolr::Error::Http
在ProductDetailsController#索引中
RSolr::Error::Http-400错误请求
错误:未定义的字段类别\u id
请求数据:“fq=type%3AProductDetail&fq=category\u id\u i%3A%281%29&start=0&rows=30&group=true&group.field=category\u id&group.format=simple&q=%2A%3A%2A”
回溯:/home/toshiba/.rvm/gems/ruby-1.9.2-p290/gems/rsolr-1.0.8/lib/rsolr/client.rb:230:在“适应\响应”中
/home/toshiba/.rvm/gems/ruby-1.9.2-p290/gems/rsolr-1.0.8/lib/rsolr/client.rb:167:in'execute'
/home/toshiba/.rvm/gems/ruby-1.9.2-p290/gems/rsolr-1.0.8/lib/rsolr/client.rb:161:in“发送和接收”
请帮帮我。谢谢。这里有两件事:
1.仅在string
字段上支持在太阳黑子中分组。因此,将可搜索的块更改为以下内容:
class ProductDetail < ActiveRecord::Base
belongs_to :category
searchable do
text :name
string :category_id_str do
category_id.to_s
end
end
end
在这里,我假设太阳黑子在索引属性时将额外的\u s
添加到属性中。可能在/usr/share/solr/conf的schema.xml中缺少一个整数类型
以下是我的例子:
<schema name="sunspot" version="1.0">
<types>
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
behavior of the fieldType.
Class names starting with "solr" refer to java classes in the
org.apache.solr.analysis package.
-->
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="string" class="solr.StrField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tdouble" class="solr.TrieDoubleField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="date" class="solr.DateField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sdouble" class="solr.SortableDoubleField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sfloat" class="solr.SortableFloatField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sint" class="solr.SortableIntField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="slong" class="solr.SortableLongField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tint" class="solr.TrieIntField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true"/>
</types>
def index
@search_res1=ProductDetail.search do
adjust_solr_params do |params|
params[:group] = true
params[:"group.field"] = "category_id_str_s"
params[:"group.format"] = "simple"
end
end.execute
@navurls=@search_res1.results
end
<schema name="sunspot" version="1.0">
<types>
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
behavior of the fieldType.
Class names starting with "solr" refer to java classes in the
org.apache.solr.analysis package.
-->
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="string" class="solr.StrField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tdouble" class="solr.TrieDoubleField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="date" class="solr.DateField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sdouble" class="solr.SortableDoubleField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sfloat" class="solr.SortableFloatField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="sint" class="solr.SortableIntField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="slong" class="solr.SortableLongField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tint" class="solr.TrieIntField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true"/>
<!-- *** This fieldType is used by Sunspot! *** -->
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true"/>
</types>