<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "关于搜索，有问题求教~"]]></title>
		<link>https://forum.andowson.com/posts/list/7.page</link>
		<description><![CDATA[Latest messages posted in the topic "关于搜索，有问题求教~"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>关于搜索，有问题求教~</title>
				<description><![CDATA[ 搜索在后台是怎样实现的？我这边搜索的功能无法实现，英文中文都是不行，都是0个结果。search.htm的method已经改为post，请问还有可能是那方面原因？谢谢！]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/386.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/386.page</link>
				<pubDate><![CDATA[Thu, 29 May 2008 15:11:06]]> GMT</pubDate>
				<author><![CDATA[ wu_net2008]]></author>
			</item>
			<item>
				<title>回覆:关于搜索，有问题求教~</title>
				<description><![CDATA[ 1.檢查目錄權限是否正確 
<br>
JForum自2.1.8版起改用[url=http://lucene.apache.org/]Lucene[/url]作為搜尋引擎，會自動建立索引檔，產生的索引檔存放的預設目錄是$JFORUM_HOME/WEB-INF/jforumLuceneIndex，如果該目錄不存在JForum會自動建立，故需要將WEB-INF目錄設定為tomcat可寫入才行。 
<br>
<br>
在Unix-like系統上可做如下的設定 
<br>
chgrp tomcat WEB-INF 
<br>
chmod 775 WEB-INF 
<br>
<br>
2.檢查編碼設定是否正確 
<br>
資料庫使用的編碼建議設定為UTF-8，並注意jforum-custom.conf裡面的設定是否也設定正確： 
<br>
dbencoding=utf-8 
<br>
encoding=UTF-8 
<br>
<br>
3.檢查Tomcat系統設定是否正確 
<br>
請勿對Connector加上URIEncoding="UTF-8"的參數，這樣會造成二次轉碼，反而找不到。 
<br>
<br>
4.檢查作業系統預設編碼是否正確 
<br>
檢查/etc/sysconfig/i18n內容，例如： 
<br>
LANG="zh_TW.UTF-8" 
<br>
SUPPORTED="zh_TW.UTF-8:zh_TW:zh" 
<br>
SYSFONT="latarcyrheb-sun16" 
<br>
<br>
5.search.htm請維持原來的GET method，不要改成POST method。 
<br>
<br>
6.重建索引 
<br>
到系統管理控制台，點選Lucene統計功能，輸入以時間區間方式，重建一次索引，如果上方的文件數不為0即表示索引建立成功。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/388.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/388.page</link>
				<pubDate><![CDATA[Thu, 29 May 2008 20:36:21]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>关于搜索，有问题求教~</title>
				<description><![CDATA[ 项目进行得差不多了，现在搜索的问题还是没有解决，编码都已经进行了设置，还是搜不到中文，问题求解中。。。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/442.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/442.page</link>
				<pubDate><![CDATA[Mon, 25 Aug 2008 09:35:19]]> GMT</pubDate>
				<author><![CDATA[ wu_net2008]]></author>
			</item>
			<item>
				<title>回覆:关于搜索，有问题求教~</title>
				<description><![CDATA[ 最近一個案子是在Windows Server 2003上安裝JForum，也遇到了中文搜尋的問題，不過這次的問題是字元字編碼的問題。
<br>
<br>
首先在WebRequestContext.java中插入幾行輸出(System.out.println())以便提供除錯資訊
<br>
[code=java;first-line:82]
<br>
 /**
<br>
 * Default constructor.
<br>
 * 
<br>
 * @param superRequest Original &lt;code&gt;HttpServletRequest&lt;/code&gt; instance
<br>
 * @throws IOException
<br>
 */
<br>
 public WebRequestContext(HttpServletRequest superRequest) throws IOException
<br>
 {
<br>
 super(superRequest);
<br>
<br>
 this.query = new HashMap();
<br>
 boolean isMultipart = false;
<br>
<br>
 String requestType = superRequest.getMethod().toUpperCase();
<br>
 String contextPath = superRequest.getContextPath();
<br>
 String requestUri = this.extractRequestUri(superRequest.getRequestURI(), contextPath);
<br>
 String encoding = SystemGlobals.getValue(ConfigKeys.ENCODING);
<br>
 System.out.println("encoding=" + encoding);
<br>
 String servletExtension = SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION);
<br>
<br>
 boolean isPost = "POST".equals(requestType);
<br>
 boolean isGet = !isPost;
<br>
<br>
 boolean isQueryStringEmpty = (superRequest.getQueryString() == null 
<br>
 || superRequest.getQueryString().length() == 0);
<br>
<br>
 if (isGet &amp;&amp; isQueryStringEmpty &amp;&amp; requestUri.endsWith(servletExtension)) {
<br>
 superRequest.setCharacterEncoding(encoding); 
<br>
 this.parseFriendlyURL(requestUri, servletExtension);
<br>
 }
<br>
 else if (isPost) {
<br>
 isMultipart = ServletFileUpload.isMultipartContent(new ServletRequestContext(superRequest));
<br>
<br>
 if (isMultipart) {
<br>
 this.handleMultipart(superRequest, encoding);
<br>
 }
<br>
 }
<br>
<br>
 if (!isMultipart) {
<br>
 boolean isAjax = "XMLHttpRequest".equals(superRequest.getHeader("X-Requested-With"));
<br>
<br>
 if (!isAjax) {
<br>
 superRequest.setCharacterEncoding(encoding);
<br>
 System.out.println("request.encoding=" + encoding);
<br>
 }
<br>
 else {
<br>
 // Ajax requests are *usually* sent using application/x-www-form-urlencoded; charset=UTF-8.
<br>
 // In JForum, we assume this as always true.
<br>
 superRequest.setCharacterEncoding("UTF-8");
<br>
 }
<br>
<br>
 String containerEncoding = SystemGlobals.getValue(ConfigKeys.DEFAULT_CONTAINER_ENCODING); 
<br>
<br>
 if (isPost) { 
<br>
 containerEncoding = encoding;
<br>
 }
<br>
 System.out.println("containerEncoding=" + containerEncoding);
<br>
 for (Enumeration e = superRequest.getParameterNames(); e.hasMoreElements(); ) {
<br>
 String name = (String)e.nextElement();
<br>
<br>
 String[] values = superRequest.getParameterValues(name);
<br>
<br>
 if (values != null &amp;&amp; values.length &gt; 1) {
<br>
 for (int i = 0; i &lt; values.length; i++) {
<br>
 System.out.println("before: "+name+"["+i+"]="+values[i]);
<br>
 this.addParameter(name, new String(values[i].getBytes(containerEncoding), encoding)); 
<br>
 System.out.println("after: "+name+"["+i+"]="+new String(values[i].getBytes(containerEncoding), encoding));
<br>
 }
<br>
 }
<br>
 else {
<br>
 System.out.println("before: "+name+"="+superRequest.getParameter(name)); 
<br>
 this.addParameter(name, new String(superRequest.getParameter(name).getBytes(containerEncoding), encoding)); 
<br>
 System.out.println("after: "+name+"="+new String(superRequest.getParameter(name).getBytes(containerEncoding), encoding));
<br>
 }
<br>
 }
<br>
<br>
 if (this.getModule() == null &amp;&amp; this.getAction() == null) {
<br>
 int index = requestUri.indexOf('?');
<br>
<br>
 if (index &gt; -1) {
<br>
 requestUri = requestUri.substring(0, index);
<br>
 }
<br>
<br>
 this.parseFriendlyURL(requestUri, servletExtension);
<br>
 }
<br>
 }
<br>
 }
<br>
[/code]
<br>
然後在搜尋頁面上的關鍵字欄位輸入「中文」，然後按下搜尋，會出現下列的錯誤訊息：
<br>
[quote]An error has occurred.
<br>
<br>
For detailed error information, please see the HTML source code, and contact the forum Administrator.
<br>
<br>
org.apache.lucene.queryParser.ParseException: Cannot parse '': Encountered "EOF" at line 1, column 0.
<br>
Was expecting one of:
<br>
 NOT ...
<br>
 "+" ...
<br>
 "-" ...
<br>
 "(" ...
<br>
 "*" ...
<br>
 QUOTED ...
<br>
 TERM ...
<br>
 PREFIXTERM ...
<br>
 WILDTERM ...
<br>
 "[" ...
<br>
 "{" ...
<br>
 NUMBER ...
<br>
[/quote] 
<br>
在Tomcat的logs目錄下的stdout.log檔案內可以發現到下列的資訊：
<br>
[quote]encoding=UTF-8
<br>
request.encoding=UTF-8
<br>
containerEncoding=ISO-8859-1
<br>
before: search_keywords=中文
<br>
after: search_keywords=??
<br>
before: module=search
<br>
after: module=search
<br>
before: sort_by=relevance
<br>
after: sort_by=relevance
<br>
before: match_type=all
<br>
after: match_type=all
<br>
before: action=search
<br>
after: action=search
<br>
before: search_forum=
<br>
after: search_forum=[/quote]
<br>
可以發現，在做轉碼前我們get到的參數值是正確的，但在轉碼後就變成問號了，於是就變成Lucene剔除的符號字元，結果變成搜尋用的關鍵字串是空的。
<br>
修改方式就是在迴圈中判斷requestType是否為post，如果是(isPost == true)才轉碼，不然就用原來的值。
<br>
[code=java;first-line:140]
<br>
 for (Enumeration e = superRequest.getParameterNames(); e.hasMoreElements(); ) {
<br>
 String name = (String)e.nextElement();
<br>
<br>
 String[] values = superRequest.getParameterValues(name);
<br>
<br>
 if (values != null &amp;&amp; values.length &gt; 1) {
<br>
 for (int i = 0; i &lt; values.length; i++) { 
<br>
 if (isPost) {
<br>
 this.addParameter(name, new String(values[i].getBytes(containerEncoding), encoding));
<br>
 } else {
<br>
 this.addParameter(name, values[i]);
<br>
 } 
<br>
 }
<br>
 }
<br>
 else { 
<br>
 if (isPost) {
<br>
 this.addParameter(name, new String(superRequest.getParameter(name).getBytes(containerEncoding), encoding));
<br>
 } else {
<br>
 this.addParameter(name, superRequest.getParameter(name));
<br>
 }
<br>
 }
<br>
 }
<br>
[/code]
<br>
這樣再去搜尋就可以了。]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/674.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/674.page</link>
				<pubDate><![CDATA[Mon, 19 Oct 2009 16:05:57]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>关于搜索，有问题求教~</title>
				<description><![CDATA[ 请问一个JFORUM 搜索的问题：
<br>
我发表新的主题贴后，LUCENCE可以搜索到，但是我把jforumLuceneIndex的索引删掉之后，JFORUM就不把原来的主题贴做索引引擎了 ，也就是从启动后新发表的主题贴才做索引引擎,请问要怎么修改代码才能够全部重新都做索引引擎]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/678.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/678.page</link>
				<pubDate><![CDATA[Fri, 23 Oct 2009 12:05:08]]> GMT</pubDate>
				<author><![CDATA[ sudiliuxin]]></author>
			</item>
			<item>
				<title>回覆:关于搜索，有问题求教~</title>
				<description><![CDATA[ 您可以修改 net/jforum/search/LuceneReindexer.java 
<br>
將 
<br>
[code]luceneIndexer.batchCreate(post);[/code] 
<br>
替代為 
<br>
[code] 
<br>
luceneIndexer.create(post);[/code] 
<br>
<br>
然後到管理後台，再重新執行一次從無到有的重新索引即可。 
<br>]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/680.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/680.page</link>
				<pubDate><![CDATA[Fri, 23 Oct 2009 19:24:53]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>Re:关于搜索，有问题求教~</title>
				<description><![CDATA[ BTW just curious what is LuceneIndex functionality ? I search it on wiki and it states something like a backup. When i try to execute under Admin control panel i see some files created but when opened are all in ASCII characters. Whats the use of it ?]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/684.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/684.page</link>
				<pubDate><![CDATA[Wed, 28 Oct 2009 15:20:52]]> GMT</pubDate>
				<author><![CDATA[ acer123]]></author>
			</item>
			<item>
				<title>回复:关于搜索，有问题求教~</title>
				<description><![CDATA[ jforum的搜索选项起不作用，选一个版面，但是搜索出来的结果是所有版面的查询结果，是怎么回事？有办法解决么？同时如果设置了关联性和发表时间的参数也不是按照设置规则来查询，为什么？]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/249/1168.page</guid>
				<link>https://forum.andowson.com/posts/preList/249/1168.page</link>
				<pubDate><![CDATA[Thu, 3 Nov 2011 15:42:16]]> GMT</pubDate>
				<author><![CDATA[ sybell]]></author>
			</item>
	</channel>
</rss>