<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>batchSize &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/batchsize/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Sat, 07 Nov 2020 15:17:47 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>batchSize &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Solr 教學 (5) – 建立新的 Core</title>
		<link>https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/</link>
					<comments>https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Wed, 08 Jan 2014 06:19:30 +0000</pubDate>
				<category><![CDATA[資料庫]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mariadb]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[solrconfig.xml]]></category>
		<category><![CDATA[DataImportHandler]]></category>
		<category><![CDATA[batchSize]]></category>
		<category><![CDATA[db-data-config.xml]]></category>
		<category><![CDATA[java.sql.SQLException: Illegal value for setFetchSize()]]></category>
		<category><![CDATA[schema.xml]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=3170</guid>

					<description><![CDATA[<p>這篇文章小蛙要記錄怎麼樣新建一個 Core 並且也加入 DataImportHandler 的方法。其他相關 Solr 系列文章請參考：Solr 教學 (1) – 安裝篇Solr 教學 (2) – t&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/" data-wpel-link="internal">Solr 教學 (5) – 建立新的 Core</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>這篇文章小蛙要記錄怎麼樣新建一個 Core 並且也加入 DataImportHandler 的方法。<br><span id="more-3170"></span>其他相關 Solr 系列文章請參考：<br><a href="https://noter.tw/3084/solr-%e6%95%99%e5%ad%b8-1-%e5%ae%89%e8%a3%9d%e7%af%87/" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Solr 教學 (1) – 安裝篇</a><br><a href="https://noter.tw/3082/solr-%e6%95%99%e5%ad%b8-2-tomcat-7-%e4%bb%a5%e5%b8%b3%e8%99%9f%e5%af%86%e7%a2%bc%e9%99%90%e5%88%b6%e5%ad%98%e5%8f%96%e9%a0%81%e9%9d%a2/" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Solr 教學 (2) – tomcat 7 以帳號密碼限制存取頁面</a><br><a href="https://noter.tw/3094/solr-%e6%95%99%e5%ad%b8-3-%e4%bb%a5-remote-address-filter-%e9%99%90%e5%88%b6%e5%ad%98%e5%8f%96/" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Solr 教學 (3) – 以 Remote Address Filter 限制存取</a><br><a href="https://noter.tw/3160/solr-%e6%95%99%e5%ad%b8-4-%e4%bd%bf%e7%94%a8-dataimport-%e5%8c%af%e5%85%a5%e8%b3%87%e6%96%99%e5%ba%ab%e8%b3%87%e6%96%99/" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Solr 教學 (4) – 使用 DataImport 匯入資料庫資料</a></p>
<p>上一篇記錄了怎麼透過 DataImportHandler 來將 MySQL 的資料匯入到 Solr 中，剛詢問了同事，一個 Core 可以大概看成資料庫中的一個 table，所以要匯入兩個不相關的 table 要用兩個 Core，雖然網路上好像有人提到可以將兩個不相干的 table 匯入到一個 Core 中，不過小蛙的 table 不多，就用簡單的做法就好。</p>
<p>小蛙的 index 環境是在 /opt/solr/example，最快的方法是直接把 example 資料夾複製一個新的並且改名字，這邊小蛙想要有一個 news 的 core， 使用自己建立必要資料夾的方法，建立以下資料夾</p>
<pre>/opt/solr/news/
/opt/solr/news/conf
/opt/solr/news/data</pre>
<p>再將原本 /opt/solr/example/conf/ 下的&nbsp;db-data-config.xml,&nbsp;schema.xml,&nbsp;solrconfig.xml 這三個檔案複製到&nbsp;/opt/solr/news/conf/ 目錄中。</p>
<p>接著修改 /opt/solr/solr.xml，加入新的 core</p>
<div>
<div id="highlighter_990520" class="syntaxhighlighter  xml">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
<div class="line number2 index1 alt1">2</div>
<div class="line number3 index2 alt2">3</div>
<div class="line number4 index3 alt1">4</div>
<div class="line number5 index4 alt2">5</div>
<div class="line number6 index5 alt1">6</div>
<div class="line number7 index6 alt2">7</div>
<div class="line number8 index7 alt1">8</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="xml plain">&lt;?</code><code class="xml keyword">xml</code> <code class="xml color1">version</code><code class="xml plain">=</code><code class="xml string">"1.0"</code> <code class="xml color1">encoding</code><code class="xml plain">=</code><code class="xml string">"UTF-8"</code> <code class="xml plain">?&gt;</code></div>
<div class="line number2 index1 alt1"><code class="xml plain">&lt;</code><code class="xml keyword">solr</code> <code class="xml color1">persistent</code><code class="xml plain">=</code><code class="xml string">"true"</code><code class="xml plain">&gt;</code></div>
<div class="line number3 index2 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">cores</code> <code class="xml color1">adminPath</code><code class="xml plain">=</code><code class="xml string">"/admin/cores"</code><code class="xml plain">&gt;</code></div>
<div class="line number4 index3 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">core</code> <code class="xml color1">name</code><code class="xml plain">=</code><code class="xml string">"example"</code> <code class="xml color1">instanceDir</code><code class="xml plain">=</code><code class="xml string">"example"</code> <code class="xml plain">/&gt;</code></div>
<div class="line number5 index4 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">core</code> <code class="xml color1">name</code><code class="xml plain">=</code><code class="xml string">"News"</code> <code class="xml color1">instanceDir</code><code class="xml plain">=</code><code class="xml string">"news"</code> <code class="xml plain">/&gt;</code></div>
<div class="line number6 index5 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">...</code></div>
<div class="line number7 index6 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;/</code><code class="xml keyword">cores</code><code class="xml plain">&gt;</code></div>
<div class="line number8 index7 alt1"><code class="xml plain">&lt;/</code><code class="xml keyword">solr</code><code class="xml plain">&gt;</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>重新啟動 tomcat。小蛙在這邊就遇到很多錯誤，因為資料夾是用 root 權限建立的，而 solr 並沒有這樣的權限可以存取，所以這邊要注意把 /opt/solr/news 下的檔案擁有權都改成 tomcat7 (看 tomcat user 叫什麼就改成那個)。</p>
<p>第二個要注意的事情是一切正常運作後，點選到 DataImport 頁面開始運行時，卻出現下面的錯誤</p>
<div>
<div id="highlighter_887532" class="syntaxhighlighter  text">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
<div class="line number2 index1 alt1">2</div>
<div class="line number3 index2 alt2">3</div>
<div class="line number4 index3 alt1">4</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="text plain">org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: select * from news Processing Document # 1</code></div>
<div class="line number2 index1 alt1"><code class="text plain">...</code></div>
<div class="line number3 index2 alt2"><code class="text plain">Caused by: java.sql.SQLException: Illegal value for setFetchSize().</code></div>
<div class="line number4 index3 alt1"><code class="text plain">...</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>參考資料 1,2 中提到在 db-data-config.xml 中的 &lt;dataSource 加上&nbsp;batchSize=&#8221;-1&#8243; 就可以解決這個問題囉！</p>


<p><strong>Solr 系列文章：</strong></p>



<ul class="my-li bg-darkblue wp-block-list"><li><a href="https://noter.tw/3084/solr-%e6%95%99%e5%ad%b8-1-%e5%ae%89%e8%a3%9d%e7%af%87/" data-wpel-link="internal">Solr 教學 (1) &#8211; 安裝篇</a></li><li><a href="https://noter.tw/3082/solr-%e6%95%99%e5%ad%b8-2-tomcat-7-%e4%bb%a5%e5%b8%b3%e8%99%9f%e5%af%86%e7%a2%bc%e9%99%90%e5%88%b6%e5%ad%98%e5%8f%96%e9%a0%81%e9%9d%a2/" data-wpel-link="internal">Solr 教學 (2) – tomcat 7 以帳號密碼限制存取頁面</a></li><li><a href="https://noter.tw/3094/solr-%e6%95%99%e5%ad%b8-3-%e4%bb%a5-remote-address-filter-%e9%99%90%e5%88%b6%e5%ad%98%e5%8f%96/" data-wpel-link="internal">Solr 教學 (3) – 以 Remote Address Filter 限制存取</a></li><li><a href="https://noter.tw/3160/solr-%e6%95%99%e5%ad%b8-4-%e4%bd%bf%e7%94%a8-dataimport-%e5%8c%af%e5%85%a5%e8%b3%87%e6%96%99%e5%ba%ab%e8%b3%87%e6%96%99/" data-wpel-link="internal">Solr 教學 (4) – 使用 DataImport 匯入資料庫資料</a></li><li><a href="https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/" data-wpel-link="internal">Solr 教學 (5) – 建立新的 Core</a></li></ul>



<h2 class="para wp-block-heading">參考資料</h2>



<ul class="wp-block-list"><li><a href="http://lucene.472066.n3.nabble.com/problem-on-running-fullimport-td1707206.html" target="_blank" rel="noreferrer noopener nofollow external" aria-label=" (在新分頁中開啟)" data-wpel-link="external" class="wpel-icon-right">Solr &#8211; User &#8211; problem on running fullimport<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li><li><a rel="noreferrer noopener nofollow external" aria-label=" (在新分頁中開啟)" href="http://wiki.apache.org/solr/DataImportHandler#Configuring_JdbcDataSource" target="_blank" data-wpel-link="external" class="wpel-icon-right">DataImportHandler &#8211; Solr Wiki<span class="wpel-icon wpel-image wpel-icon-6"></span></a></li></ul>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/" data-wpel-link="internal">Solr 教學 (5) – 建立新的 Core</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/3170/solr-%e6%95%99%e5%ad%b8-5-%e5%bb%ba%e7%ab%8b%e6%96%b0%e7%9a%84-core/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
