### Build and Install JCC Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Standard commands to build and install JCC using Python's setup.py script. ```python python setup.py build sudo python setup.py install ``` -------------------------------- ### Install setuptools for Python 2.3 Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Instructions for installing setuptools on Python 2.3, which involves editing the setuptools egg file to ensure compatibility with Python 2.3. ```bash # Download setuptools # Edit the downloaded setuptools egg file to use python2.3 instead of python2.4 $ sudo sh setuptools-0.6c7-py2.4.egg ``` -------------------------------- ### PyLucene Build Steps (Impatient) Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/install.md Quick steps for building PyLucene, involving navigating to the JCC directory, editing setup.py, building and installing JCC, editing the Makefile, and then building and installing PyLucene. ```bash pushd jcc edit _setup.py_ to match your environment python setup.py build sudo python setup.py install popd edit _Makefile_ to match your environment make make test (look for failures) sudo make install ``` -------------------------------- ### Get JCC Source Code Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Command to download the JCC source code from the Apache Lucene SVN repository. ```bash svn co https://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc ``` -------------------------------- ### Install GCC, G++, and Make on Debian Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Installs the GCC C++ compiler (x86-64-linux-gnu), G++ compiler, and Make utility on Debian-based systems using apt. ```bash sudo apt install gcc-x86-64-linux-gnu g++-x86-64-linux-gnu make ``` -------------------------------- ### Install Python 3.9 Development Packages on Debian Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Installs Python 3.9 with development headers, virtual environment support, and setuptools on Debian-based systems using apt. ```bash sudo apt install python3.9-dev python3-venv python3-setuptools ``` -------------------------------- ### Install Pelican Dependencies Source: https://github.com/apache/lucene-site/blob/main/README.md Installs the necessary Python packages for the Pelican static site generator using pip and a requirements file. ```shell pip3 install -r requirements.txt ``` -------------------------------- ### Configure and Build JCC on Solaris 11.1 with GCC 4.5 Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Configures and builds JCC on Solaris 11.1 with GCC 4.5. This involves editing the setup.py file to specify the correct JDK path and CFLAGS for Solaris, then building and installing. ```python # Inside setup.py: # Change JDK entry for sunos5 to: 'sunos5': '/usr/jdk/instances/jdk1.7.0' # Change CFLAGS entry for sunos5 to: 'sunos5': ['-fno-strict-aliasing', '-Wno-write-strings'] # Build and install: python setup.py build su python setup.py install ``` -------------------------------- ### Install Temurin Java 17 on Debian 11 Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Installs Temurin Java 17 (Adoptium) on Debian 11 using apt package manager. This involves adding the Adoptium repository and then installing the JDK package. ```bash sudo -s apt install wget apt-transport-https gnupg wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list apt update apt install temurin-17-jdk ``` -------------------------------- ### Solaris 11.1 GCC 4.5 Build Commands Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/install.md Commands to build and install PyLucene on Solaris 11.1 with GCC 4.5 using GNU Make after configuring the Makefile. ```bash gmake su gmake install ``` -------------------------------- ### JCC Command-Line Usage Example Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Demonstrates the typical command-line arguments used with JCC for wrapping Java libraries, including specifying JAR files, packages, classes to include/exclude, Python module name, version, and custom mapping protocols. ```bash python -m jcc \ --jar lucene.jar \ --jar analyzers.jar \ --jar snowball.jar \ --jar highlighter.jar \ --jar regex.jar \ --jar queries.jar \ --jar extensions.jar \ --package java.lang \ --package java.util \ --package java.io \ java.lang.System \ java.lang.Runtime \ java.lang.Boolean \ java.lang.Byte \ java.lang.Character \ java.lang.Integer \ java.lang.Short \ java.lang.Long \ java.lang.Double \ java.lang.Float \ java.text.SimpleDateFormat \ java.io.StringReader \ java.io.InputStreamReader \ java.io.FileInputStream \ java.util.Arrays \ --exclude org.apache.lucene.queryParser.Token \ --exclude org.apache.lucene.queryParser.TokenMgrError \ --exclude org.apache.lucene.queryParser.ParseException \ --python lucene \ --version 2.4.0 \ --mapping org.apache.lucene.document.Document \ 'get:(Ljava/lang/String;)Ljava/lang/String;' \ --mapping java.util.Properties \ 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' \ --sequence org.apache.lucene.search.Hits \ 'length:()I' \ 'doc:(I)Lorg/apache/lucene/document/Document;' ``` -------------------------------- ### Apache Lucene Contribution Guide Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/developer.md This Markdown link points to the CONTRIBUTING.md file within the Apache Lucene GitHub repository, which details how to contribute to the project. ```markdown [Wiki][1] [1]: https://github.com/apache/lucene/blob/main/CONTRIBUTING.md ``` -------------------------------- ### Build JCC with Sun Studio C++ Compiler on Solaris Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/install.md Builds JCC on Solaris 11 using Sun Studio C++ 12 by specifying the CC environment variable to point to the correct C++ compiler. ```bash $ CC=CC python setup.py build ``` -------------------------------- ### Build and Preview Lucene Site Locally Source: https://github.com/apache/lucene-site/blob/main/README.md This script builds the Apache Lucene website locally and provides a live preview. It uses Pelican and can be run with options for live reloading and help. ```shell # Usage: ./build.sh [-l] [] # -l Live build and reload source changes on localhost:8000 # --help Show full help for options that Pelican accepts ./build.sh -l ``` -------------------------------- ### JCC File Splitting Options Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/install.md Demonstrates how to use the --files command line argument with JCC to control the number of generated C++ files, which can help overcome compiler limits. ```bash jcc --files 2 jcc --files 10 jcc --files separate ``` -------------------------------- ### Set Up Python Virtual Environment for Pelican Source: https://github.com/apache/lucene-site/blob/main/README.md Creates and activates a Python virtual environment to manage Pelican dependencies, preventing conflicts with system-wide packages. ```shell python3 -m venv env source env/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Lucene Release Link Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/core/quickstart.html Provides a link to the latest Lucene release demo. ```html {% extends "lucene/core/page.html" %} {% block content %} {{ super() }} The most recent versions can also be found online: * [Lucene {{ LUCENE_LATEST_RELEASE }} Demo]({{ SITEURL }}/core/{{ LUCENE_LATEST_RELEASE | replace() {% endblock %} ``` -------------------------------- ### LimitTokenOffsetFilter Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2015-06-07-5-2-0-available.md Limits tokens to those before a configured maximum start offset. This filter is useful for controlling the processing of tokens based on their position within a document. ```Java LimitTokenOffsetFilter ``` -------------------------------- ### Checkout Latest PyLucene Trunk Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/version_control.md This command checks out the latest development version (trunk) of the PyLucene project from the Apache Subversion repository. It requires the Subversion client to be installed. ```shell svn checkout https://svn.apache.org/repos/asf/lucene/pylucene/trunk/ pylucene_trunk ``` -------------------------------- ### Download Verification Instructions Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/core/downloads.html Explains how to verify downloaded Apache Lucene release files using PGP signatures and SHA checksums. Links to project release KEYS and verification instructions are provided. ```html The above release files should be verified using the PGP signatures and the [project release KEYS](https://downloads.apache.org/lucene/KEYS). See [verification instructions](https://www.apache.org/dyn/closer.cgi#verify) for a description of using the PGP and KEYS files for verification. SHA checksums are also provided as alternative verification method. ``` -------------------------------- ### PyLucene API Mapping from Java Lucene Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/features.md PyLucene exposes Java Lucene classes in a flat Python namespace. For example, `org.apache.lucene.index.IndexReader` in Java becomes `from lucene import IndexReader` in Python. ```python # Java: import org.apache.lucene.index.IndexReader; from lucene import IndexReader # Java: import org.apache.lucene.analysis.standard.StandardAnalyzer; from lucene import StandardAnalyzer ``` -------------------------------- ### Clone Lucene Main Repository Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/developer.md This command clones the latest main branch of the Apache Lucene project from GitHub using Git. It's the starting point for accessing the project's source code. ```git git clone https://github.com/apache/lucene.git ``` -------------------------------- ### Solaris 11.1 GCC 4.5 Makefile Configuration Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/install.md Configuration snippet for the Makefile on Solaris 11.1 with GCC 4.5, specifying Python prefix, Ant path, Python executable, JCC command, and number of files. ```makefile # Solaris (Solaris 11.1, Python 2.6, 32-bit, Java 1.7) PREFIX_PYTHON=/usr ANT=/usr/bin/ant PYTHON=$(PREFIX_PYTHON)/bin/python JCC=$(PYTHON) -m jcc.__main__ --reserved DEFAULT_TYPE NUM_FILES=4 ``` -------------------------------- ### Lucene 8.3.1 Bugfix Example Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2019-12-03-8-3-1-available.md This snippet illustrates a bug fix in Lucene 8.3.1 where MultiTermIntervalsSource.visit() was not correctly calling back to its visitor. This fix ensures proper visitor pattern implementation for interval sources. ```Java /* * Fix for MultiTermIntervalsSource.visit() not calling visitor. * Ensures that the visitor pattern is correctly applied. */ // Original (buggy) implementation might have omitted the visitor call: // public void visit(IntervalSelector selector) { /* ... */ } // Corrected implementation: public void visit(IntervalSelector selector) { // ... existing logic ... selector.visit(this); // Ensure the visitor is called // ... more logic ... } ``` -------------------------------- ### Initializing the Java VM in PyLucene Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/features.md Before calling most PyLucene APIs that interact with the Java Virtual Machine (JVM), you must initialize it. This function requires specifying the classpath. ```python from lucene import initVM # Example classpath (may vary based on your installation) classpath = "path/to/lucene.jar:path/to/pylucene.jar" vm = initVM(classpath=classpath) ``` -------------------------------- ### PyLucene Source Distributions Source: https://github.com/apache/lucene-site/blob/main/content/pylucene/pylucene_news/2011-06-09-3-2-0-1-available.md Provides a link to the Apache archive for downloading PyLucene source distributions. ```text https://archive.apache.org/dist/lucene/pylucene/ ``` -------------------------------- ### Lucene 10.0.0 API Changes: KNN Vector Access Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2024-10-14-10-0-0-available.md Highlights changes in the KNN vector API for Lucene 10.0.0, introducing a random-access API for vector values. Consult the migration guide for detailed information on deprecated APIs and necessary adjustments. ```Java API changes * KNN vector values now have a random-access API. * Deprecated APIs have been removed and a number of API changes have been made. Please consult the migrate guide for an extensive list and actions to take to migrate to 10.0. ``` -------------------------------- ### Instantiating Java Arrays from Python Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Shows the different ways to create Java arrays from Python using the `JArray` wrapper. This includes initializing arrays with a specific size or populating them from a Python sequence. ```Python >>> array = JArray('int')(size) # the resulting Java int array is initialized with zeroes >>> array = JArray('int')(sequence) # the sequence must only contain ints # the resulting Java int array contains the ints in the sequence ``` -------------------------------- ### Java 19 Foreign Memory Access (Project Panama) Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2022-09-30-9-4-0-available.md Enables Lucene to use Java 19's foreign memory API for accessing indexes on disk via MMapDirectory when started with the '--enable-preview' flag. This is an opt-in feature that requires explicit Java command line parameters. When enabled, MMapDirectory maps Lucene indexes in 16 GiB chunks, and indexes closed during query execution will not crash the JVM. ```Java System.setProperty("lucene.mmap.use_native_sun_misc_unsafe", "true"); // Or pass "--enable-preview" as a JVM argument ``` -------------------------------- ### PyLucene Navigation Links Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/pylucene/page.html Provides navigation links for the PyLucene project, including its documentation, news, JCC, issue tracker, mailing lists, and the main Lucene TLP. ```html {% extends "lucene/base.html" %} {% block headtitle %}{{page.title}}{% endblock %} {% block css %} {% endblock %} {% block nav_items %}* [PyLucene]({{ SITEURL}}/pylucene/index.html) * [News]({{ SITEURL}}/pylucene/news.html) * [JCC]({{ SITEURL}}/pylucene/jcc/index.html) * [Issue Tracker](https://issues.apache.org/jira/browse/PYLUCENE) * [Mailing Lists]({{ SITEURL}}/pylucene/mailing-lists.html) * [Lucene TLP]({{ SITEURL }}/ {% endblock %} ``` -------------------------------- ### Initializing and Managing Embedded Python VM in Java Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Demonstrates the Java API calls for initializing, acquiring thread state, releasing thread state, and instantiating Python objects from a Java VM using JCC. This involves interacting with the `org.apache.jcc.PythonVM` class. ```Java import org.apache.jcc.PythonVM; // ... inside a Java method ... // Initialize the embedded Python VM // 'python_program_name' is informational, sys.argv[0] in Python // {'arg1', 'arg2'} are optional startup arguments for Python PythonVM pythonVM = PythonVM.start("my_python_app", new String[]{"arg1", "arg2"}); // Get the singleton PythonVM instance if already started // PythonVM pythonVM = PythonVM.get(); // Acquire thread state before calling into Python from a Java thread pythonVM.acquireThreadState(); try { // Instantiate a Python object (e.g., from module 'my_module', class 'MyClass') // The Java extension class for 'MyClass' must be defined and available Object pythonObject = pythonVM.instantiate("my_module", "MyClass"); // Downcast to the specific Java extension class // MyJavaExtensionClass instance = (MyJavaExtensionClass) pythonObject; // ... interact with the Python object via its Java extension class ... } finally { // Release the thread state when done with Python calls in this thread pythonVM.releaseThreadState(); } ``` -------------------------------- ### Initialize Java VM with JCC Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Initializes the Java Virtual Machine (JVM) for use with JCC. It allows configuration of classpath, heap size, stack size, and VM arguments. The classpath defaults to the module's exported CLASSPATH if not specified. ```python import lucene lucene.initVM(classpath=lucene.CLASSPATH) ``` ```python import lucene lucene.initVM(initialheap='32m') lucene.Runtime.getRuntime().totalMemory() ``` ```python import lucene lucene.initVM(vmargs='-Xcheck:jni,-verbose:jni,-verbose:gc') ``` -------------------------------- ### Solaris 11 C++ Compiler Configuration Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/install.md Shell command to specify the Sun Studio C++ compiler (CC) when building PyLucene on Solaris 11 using GNU Make. ```bash $ CC=CC gmake ``` -------------------------------- ### JCC Build and Distribution Options Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Options for building Python extensions using JCC, including forcing the use of distutils and distributing the output as a Python egg. ```python jcc --use-distutils # Forces JCC to use distutils instead of setuptools if both are available. jcc --bdist # Invokes distutils or setuptools to build a distribution (e.g., an egg). ``` -------------------------------- ### JavaScript Slide Control Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/main.html Initializes a new Slides instance for controlling presentation slides. This script is typically executed once the DOM is fully loaded. ```javascript function StartSlides() { new Slides('mantleSlides'); } document.observe('dom:loaded', StartSlides); ``` -------------------------------- ### IndexWriter Initialization from Reader Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2015-08-24-5-3-0-available.md IndexWriter can now be initialized from an already open near-real-time or non-NRT reader. This allows for more flexible index merging and updates. ```Java import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.IndexReader; // Example: // IndexWriterConfig config = new IndexWriterConfig(analyzer); // IndexWriter writer = new IndexWriter(directory, config); // IndexReader reader = writer.getReader(); // IndexWriter newWriter = new IndexWriter(newDirectory, config, reader); ``` -------------------------------- ### Download Lucene Main Artifacts Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/developer.md This link allows downloading the build artifacts from the last successful nightly build of the 'main' version of the Apache Lucene code, managed by Jenkins. ```markdown [Download main Artifacts][5] [5]: https://ci-builds.apache.org/job/Lucene/job/Lucene-Artifacts-main/lastSuccessfulBuild/ ``` -------------------------------- ### Instantiating Generic Java Classes with Type Parameters Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/features.md Demonstrates how to create instances of Java generic classes with specific type parameters using the `of()` method in JCC. This allows for type-safe operations on generic collections. ```Python >>> a = ArrayList().of_(Document) >>> a >>> a.parameters_ (,) >>> a.add(Document()) True >>> a.get(0) > ``` -------------------------------- ### Generate Lucene Site with Pelican Source: https://github.com/apache/lucene-site/blob/main/README.md Generates the static HTML files for the Lucene website using the Pelican command. The output is saved in the 'output/' folder. ```shell pelican ``` -------------------------------- ### JCC Requirements Source: https://github.com/apache/lucene-site/blob/main/content/pages/pylucene/jcc/index.md JCC supports multiple operating systems including Mac OS X, Linux, Solaris, and Windows. It requires Python versions 2.x (>= 2.3) or 3.x (>= 3.0) and Java versions 1.x (>= 1.4). A C++ compiler is necessary for building JCC. ```APIDOC JCC Requirements: Operating Systems: Mac OS X, Linux, Solaris, Windows Python Versions: 2.x (>= 2.3), 3.x (>= 3.0) Java Versions: 1.x (>= 1.4) Build Dependencies: C++ compiler Recommended Build Tool: setuptools ``` -------------------------------- ### PyLucene Link Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/tlp/page.html Provides a link to the PyLucene documentation. ```html * [PyLucene]({{ SITEURL }}/pylucene/index.html) ``` -------------------------------- ### Pelican Autoreload and Live Server Source: https://github.com/apache/lucene-site/blob/main/README.md Configures Pelican to automatically regenerate the site upon detecting file changes and serve it via a built-in webserver for live preview. ```shell pelican --autoreload --listen ``` -------------------------------- ### Lucene Utility Tools (Luke) Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/features.md Lucene includes integrated utility tools, such as the desktop GUI tool 'Luke', which allows for browsing, searching, and maintaining indexes and documents. It can be launched using the command 'bin/luke.{sh|cmd}'. ```Java Utility Tool: Luke (desktop GUI) Functionality: Browse, search, and maintain indexes and documents Launch Command: bin/luke.{sh|cmd} ``` -------------------------------- ### ASF Snapshot Repository for Lucene Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/developer.md This link directs to the Apache Software Foundation (ASF) snapshot repository where Maven artifacts for Lucene are available, including nightly builds. ```markdown [the ASF snapshot repository][6] [6]: https://repository.apache.org/snapshots/org/apache/lucene/ ``` -------------------------------- ### CHANGES.txt Reference Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2015-08-24-5-3-0-available.md Provides a link to the CHANGES.txt file for a comprehensive list of all changes, bug fixes, and optimizations included in the release. ```APIDOC See the [CHANGES.txt](/core/5_3_0/changes/Changes.html) file included with the release for a full list of changes and further details. ``` -------------------------------- ### PyLucene Sidebar Inclusion Source: https://github.com/apache/lucene-site/blob/main/themes/lucene/templates/lucene/pylucene/page.html Includes the PyLucene sidebar content into the main page structure. ```html {% block sidebar %} {% include "lucene/pylucene/_sidebar.html" %} {% endblock %} ``` -------------------------------- ### Java - BlendedInfixSuggester for Boosting Suggestions Source: https://github.com/apache/lucene-site/blob/main/content/core/core_news/2014-02-26-4-7--available.md Introduces BlendedInfixSuggester, an enhancement over AnalyzingInfixSuggester. It boosts suggestions that match tokens appearing at lower positions in the query, providing more relevant results by prioritizing early matches. ```Java import org.apache.lucene.search.suggest.analyzing.BlendedInfixSuggester; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import java.io.IOException; // ... // Directory directory = new RAMDirectory(); // Analyzer analyzer = new StandardAnalyzer(); // Or any other suitable analyzer // BlendedInfixSuggester suggester = new BlendedInfixSuggester(directory, "suggest", analyzer, analyzer, 1000, false); // Add suggestions with weights // suggester.add("suggestion1", 10); // suggester.add("another suggestion", 5); // suggester.build(); // Query for suggestions // Collection results = suggester.lookup("sugg", true, 5); // for (Lookup.LookupResult result : results) { // System.out.println("Suggestion: " + result.key + ", Score: " + result.value); // } ``` -------------------------------- ### Jenkins CI for Lucene Source: https://github.com/apache/lucene-site/blob/main/content/pages/core/developer.md This link directs to the Jenkins CI website, the platform used by the Lucene project for continuous integration, including nightly builds, tests, and reports. ```markdown [Jenkins][2] [2]: https://www.jenkins.io/ ```