Skip to content

w32zhong/study-lucene

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Study Lucene

This repo shows how to successfully build and run Lucene versions from v1.9 to v2.9.4 and all the way to v3.4. The purpose of this repo is to let myself get hands dirty and to be able to actually run old code to gain a good sense in Lucene source code.

Although I fail to build earlier versions before v1.9, I find it helpful (with the help of gitk) to study Lucene source code by walking through history. The earliest point I suggest to start reading is the first time Doug Cutting shows up in commit history (b08e28c3838e7bcab1a198e2f6d0cef687ee50e3).

Setup (Use v1.9 as Example)

  1. Clone lucene-solr:
$ git clone https://gitee.com/t-k-/lucene-solr.git
$ export LUCENE_SRC=`pwd/lucene-solr`
$ (cd $LUCENE_SRC && git co releases/lucene/1.9)
  1. Download an old Ant distribution:
$ cd $LUCENE_SRC
$ wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.bz2
$ tar -xzf apache-ant-1.8.4-bin.tar.gz
  1. Pull and run in an old JDK environment: The earliest jdk environment I can find ...
$ docker pull maven:3-jdk-6
$ docker run -it \
	-v $LUCENE_SRC:/lucene \
	-e JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-amd64 \
	-e ANT_HOME=/lucene/apache-ant-1.8.4 \
	maven:3-jdk-6 bash
  1. Build and run Lucene demo In Docker environment,
$ export PATH=$PATH:${ANT_HOME}/bin
$ cd /lucene
$ rm -rf build index
$ ant jar-core jar-demo
$ export CLASSPATH=`pwd`/build
$ (cd $CLASSPATH && find -name '*.jar' -exec jar -xf {} \;)

Now, let's run the Lucene demo

$ java org.apache.lucene.demo.IndexFiles ./src/java/
$ java org.apache.lucene.demo.SearchFiles

Build and Run on Docker

$ sudo docker build -t study-lucene .
$ sudo docker run -it study-lucene java org.apache.lucene.demo.SearchFiles

You may want to attach live source code and build in container:

$ sudo docker run -it -v `pwd`/src/lucene-solr:/code/lucene study-lucene bash

Index a large corpus from container?

$ sudo docker run -it -v /home/tk/nvme0n1/corpus:/corpus study-lucene java org.apache.lucene.demo.IndexFiles /corpus

About

Study Lucene from old source code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published