通过dataimport 建立solr索引
今天写错一个单词,忙会了,一下午,因为本人也是刚接触,所以对一对多,多对多,等关系建立solr索引也比较陌生,不知道哪儿错了,最后发现是单词写错了,真是郁闷啊。
data-config.xml代码如下:
<dataConfig>?
? <dataSource type="JdbcDataSource"???
????????????? driver="com.mysql.jdbc.Driver"?
???????????? url="jdbc:mysql://localhost:3306/cms?characterEncoding=gbk"???
????????????? user="root"???
????????????? password="lijian"/>?
? <document name="products">?
??? <entity? name="item"
??????? query="select * from lsoba_product where pro_prop_system_status='A' limit 0,1000">?
????<field column="pro_id" name="pro_id"/>
????<field column="pro_name" name="pro_name"/>
????<field column="pro_site_price" name="pro_site_price"/>
????<field column="pro_desc" name="pro_desc"/>
????<field column="pro_address" name="pro_address"/>
????<field column="pro_pic_url" name="pro_pic_url"/>
????<field column="pro_src_url" name="pro_src_url"/>
????<field column="pro_brand_id" name="pro_brand_id" />
????<field column="pro_mall_id" name="pro_mall_id" />
//这个单词写错了,写成了entiey 呵呵,浪费了老多时间。
????<entity name="itemcat" query="select itemCat_cid,itemCat_name from lsoba_itemcat where itemCat_cid='${item.pro_id}'">
??????<field column="itemCat_cid" name="pro_cid"/>
??????<field column="itemCat_name" name="pro_cat_name"/>
????</entity>
????<entity query="select mall_name from lsoba_mall where mall_id='${item.pro_mall_id}'">
??????<field column="mall_name" name="pro_mall_name"/>
????</entity>
????<entity query="select BRAND_NAME from lsoba_brand where BRAND_ID='${item.pro_brand_id}'">
??????<field column="BRAND_NAME" name="pro_brand_name"/>
????</entity>
??</entity>?
? </document>?
</dataConfig>
?
?
schema.xml 部分配置如下:
<fields>
?? <!-- add product infomation -->
?<field name="pro_id" type="text" indexed="true" stored="true" required="false"/>
?<field name="pro_name" type="text" indexed="true" stored="true"/>
?<field name="pro_site_price" type="float" indexed="true" stored="true"/>
?<field name="pro_desc" type="text" indexed="true" stored="true"/>
?<field name="pro_address" type="text" indexed="true" stored="true"/>
?<field name="pro_pic_url" type="text" indexed="true" stored="true"/>
?<field name="pro_src_url" type="text" indexed="true" stored="true"/>
?<!-- add categoryName -->
? <field name="pro_cid" type="text" indexed="true" stored="true" multiValued="true"/>
?<field name="pro_cat_name" type="text" indexed="true" stored="true"/>
?
?<!-- add brand -->
?<field name="pro_brand_id" type="text" indexed="true" stored="true"/>
?<field name="pro_brand_name" type="text" indexed="true" stored="true" multiValued="true"/>
?
?<!-- add mall -->
?<field name="pro_mall_id" type="text" indexed="true" stored="true"/>
?<field name="pro_mall_name" type="text" indexed="true" stored="true" multiValued="true"/>
??
?</fields>
?<!-- Field to use to determine and enforce document uniqueness.
????? Unless this field is marked with required="false", it will be a required field
?? -->
?<uniqueKey>pro_id</uniqueKey>
?<!-- field for the QueryParser to use when an explicit fieldname is absent -->
?<defaultSearchField>pro_name</defaultSearchField>
?<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
?<solrQueryParser defaultOperator="OR"/>
?
?
查询结果就ok了,
http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on
?
- <doc>? <str<span cla