Run lucene 1.9 Demo

Source: Internet
Author: User
See http://hedong.3322.org/archives/000206.html1. Download ghost First (these two support Chinese search ). 2. Put them under Classpath. 3. Run cmd to enable the command line. 4. Go to G:/JBuilder9/jdk1.4/lib. 5. run the command: G:/JBuilder9/jdk1.4/lib> java-classpath "G:/JBuilder9/jdk1.4/lib/lucene-1.2.jar; G:/JBuilder9/jdk1.4/lib/lucene-demos-1.2.jar" org. apache. lucene. demo. indexFiles "G:/My Documents/test" (G:/My Documents/test has several txt text files .) 6. The execution result is: adding G:/My Documents/test/[Post] ultimate 262.16.txt adding G:/My Documents/test/aunt's story-US education version .txt ...... (the following information is omitted ). 2294 total milliseconds (you can see that an index directory is generated under G:/JBuilder9/jdk1.4/lib. Index information created under the index DIRECTORY ). 7. Run the command: G:/JBuilder9/jdk1.4/lib> java-classpath "G:/JBuilder9/jdk1.4/lib/lucene-1.2.jar; G: /JBuilder9/jdk1.4/lib/lucene-demos-1.2.jar "org. apache. lucene. demo. searchFiles then enters the Query console starting with "Query". Then, enter the Query string "Love Letter" and obtain the returned results. As follows: Query: Love Letter Searching for: Love Letter 3 total matching documents0. G:/My Documents/test/share/ .txt 1. g:/My Documents/test/. txt 2. g:/My Documents/test/share/13,. txt Query: (Press enter to exit the Query console) 8. the following describes how to create an html query index. A. decompress the official website to download the latest e-1.2.zip file. obtain javaseweb. war. And then merge the web. use winrar to decompress war to D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/luceneweb (my Tomcat is here). The file is: D: /Program Files/Apache Group/Tomcat 5.0.7/webapps/luceneweb/results. jsp. B. Then copy the lucene-demos-1.9.jar and lucene-1.9.jar used in step 2 to the Directory D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/javaseweb/WEB-INF/lib. C. Create a folder test under D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/javaseweb. D. run the command: G:/JBuilder9/jdk1.4/lib> java-classpath "G:/JBuilder9/jdk1.4/lib/lucene-1.2.jar; G: /JBuilder9/jdk1.4/lib/lucene-demos-1.2.jar "org. apache. lucene. demo. indexHTML-create-index "D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/javaseweb/test" "H: /doc/my study notes "(the folder above indicates the place where the index information is to be stored, and the folder below is the place where the file to be indexed is located). The execution result is: adding H:/doc/my learning notes/eclipse.txt adding H:/doc/my learning notes/Jbuilder configuration .txt adding H:/doc /My learning notes/weblogic8.1configure and learn .txt adding H:/doc/my learning notes/java tips. txt adding ...... (The following information is omitted) Optimizing index... 1532 total millisecondse. use NotePad to open D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/luceneweb/configuration. jsp, locate: indexLocation, and change its value from the default value "/opt/lucene/index" to the folder "D: /Program Files/Apache Group/Tomcat 5.0.7/webapps/luceneweb/test "and save configuration. jsp. F. open D:/Program Files/Apache Group/Tomcat 5.0.7/webapps/luceneweb/results. jsp (and index. jsp ). add the following content at the beginning of the file: <% @ page contentType = "text/html; charset = GBK" %> <% response. setHeader ("Pragma", "No-cache"); // HTTP 1.1response.setHeader ("Cache-Control", "no-cache"); // HTTP 1.0response.setHeader ("Expires ", "0"); // prevents proxyrequest. setCharacterEncoding ("GB2312"); // set the encoding %> (this step is not required and can be skipped) g. start Tomcat and open http: // localhos in the browser T: 8080/luceneweb/enter the keyword you want to query to get the corresponding response. By now, the lunece demo has been fully run !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.