lucene7.3 official documentation
1. File index library
val docDir = Paths.get("index")
val directory=FSDirectory.open(Paths.get("index"))
The index library created in this way is to create an index folder on the local disk, and put the index in the index, also known as the file index library
Advantages: Persist the index to disk, which can be saved for a long time.
Disadvantages: Compared with the memory index library, the reading is slow
2. Memory index library
val directory = new RAMDirectory ()
Advantages: fast read
Disadvantages: No persistence capability, the memory index library will be deleted at the end
3. Combination of two index libraries
According to the characteristics of the two index libraries, we can combine the two indexes. The design idea is to copy the indexes in the file index library to the memory index library when the program starts.
Then let the program interact with the memory index library, and then persist the index of the memory index library to the file index library after the interaction is completed.
4. A small case
用scala编写的一个
lucene简单应用
下载好依赖jar包,
然后
直接运行TestLucene.scala即可,