共計 768 個字符,預計需要花費 2 分鐘才能閱讀完成。
這篇文章主要介紹“solr 怎么導入數(shù)據(jù)庫數(shù)據(jù)”,在日常操作中,相信很多人在 solr 怎么導入數(shù)據(jù)庫數(shù)據(jù)問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”solr 怎么導入數(shù)據(jù)庫數(shù)據(jù)”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學習吧!
注冊 DataImportHandler
在 solrconfig.xml 中增加下面代碼。在 solr5 中,在 server/solr/{core}/conf 目錄下。
requestHandler name= /dataimport > data-config.xml 文件可以放在 solrconfig.xml 一個目錄中。
2. 配置 data-config.xml 文件
首先配置數(shù)據(jù)源
dataSource type= JdbcDataSource driver= com.mysql.jdbc.Driver url= jdbc:mysql://localhost/dbname user= db_username password= db_password /
有多個數(shù)據(jù)源的話,再加上 name 屬性作為區(qū)分,比如 name= ds1
在 entity 中加上 datasource 屬性來指定從哪個數(shù)據(jù)源獲取數(shù)
.. entity name= one dataSource= ds-1 ... .. /entity entity name= two dataSource= ds-2 ... .. /entity
datasource 也可以配置在 solrconfig.xml 中
到此,關于“solr 怎么導入數(shù)據(jù)庫數(shù)據(jù)”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>