Search engine Lucene ultra-fast entry

zhaozj2021-02-16  88

The latest version of Lucene is easy to support Chinese and can easily sort

Download the latest Lucene-1.4-final-src.tar.gz, unwounded with DOCS, LIB, SRC and other directories, and the JUnit-3.8.1.jar, which is required under lib, we can use Ant1.6 Build, you can also choose to use Eclipse to build.

There is a Demo package in the SRC, view the DOCS directory documentation to know that the two classes of IndexFiles and SearchFiles are used to build text Index, and Search Query.

IndexFiles needs to pass the parameters: the absolute path of the catalog of Build Index (all files in this directory will be traversed in build index). SearchFiles can run directly without passing any parameters, running when running, you will be entered what you need to query. Query :. Build generated Index files defaults in the index directory of the SRC.

These two only very simple demo, there is still a classic demo, which is indexhtml, which is more complicated, interested in friends can take care. Here are how to sort.

Searching Lucene in Google, almost all the work of the car Easant's study on Lucene Chinese, and also mentioned a class called Cjkanalyzer (Chinese, Japanese, Korea). This Analyzer is used to analyze Chinese, Japanese, Korean's two bytes of characters, this solution is later included in Lucene by Jakarta project, 嘿嘿 This car classmate can be famous.

Very confused, the current code we downloaded is found to find the CJKanalyzer, which does not see you said, no matter what, look for information on the official website of Lucene, see changes.txt, too long, see 1.3 ~ 1.4 version of this period of this period, carefully view, actually discovered that the 1.4 version can support Chinese (quickly find Ctrl F in Changes.txt CTRL F Enter CHINESE to quickly locate). Look again, find it casually? But let yourself look at Search # search Javadoc, have seen Javadoc, small experiment, as so so! ! You can also sort by multiple index, all sorting functions can only be applied to Index without storage.

Sort: Need Sort Sort = New Sort ("UserName", true);

Surrounded, see Search's documentation specific yourself.

Note: Lucene applies quite simple and convenient, someone has transplanted it to .NET, by reading this article, I hope everyone can quickly pick up Lucene, you can put your own document Build, and then easy to check, it is also very cool.

转载请注明原文地址:https://www.9cbs.com/read-11857.html

New Post(0)