Skip to content

Apache Lucene open-source search software

LUCENE-4195: codec package documentation

Robert Muir1713e0bcc565
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9fe70feea4c..0bf9814d955 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -62,6 +62,11 @@ Build
* LUCENE-4115: JAR resolution/ cleanup should be done automatically for ant
clean/ eclipse/ resolve (Dawid Weiss)
+Documentation
+
+* LUCENE-4195: Added package documentation and examples for
+ org.apache.lucene.codecs (Alan Woodward via Robert Muir)
+
======================= Lucene 4.0.0-ALPHA =======================
More information about this release, including any errata related to the
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/package.html b/lucene/core/src/java/org/apache/lucene/codecs/package.html
index 78dcb95de64..ceccedb341b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/package.html
+++ b/lucene/core/src/java/org/apache/lucene/codecs/package.html
@@ -21,5 +21,46 @@
</head>
<body>
Codecs API: API for customization of the encoding and structure of the index.
+
+<p>
+ The Codec API allows you to customise the way the following pieces of index information are stored:
+<ul>
+ <li>Postings lists - see {@link org.apache.lucene.codecs.PostingsFormat}</li>
+ <li>DocValues - see {@link org.apache.lucene.codecs.DocValuesFormat}</li>
+ <li>Stored fields - see {@link org.apache.lucene.codecs.StoredFieldsFormat}</li>
+ <li>Term vectors - see {@link org.apache.lucene.codecs.TermVectorsFormat}</li>
+ <li>FieldInfos - see {@link org.apache.lucene.codecs.FieldInfosFormat}</li>
+ <li>SegmentInfo - see {@link org.apache.lucene.codecs.SegmentInfoFormat}</li>
+ <li>Norms - see {@link org.apache.lucene.codecs.NormsFormat}</li>
+ <li>Live documents - see {@link org.apache.lucene.codecs.LiveDocsFormat}</li>
+</ul>
+</p>
+
+<p>
+ Codecs are identified by name through the Java Service Provider Interface. To create your own codec, extend
+ {@link org.apache.lucene.codecs.Codec} and pass the new codec's name to the super() constructor:
+<pre class="prettyprint">
+public class MyCodec extends Codec {
+
+ public MyCodec() {
+ super("MyCodecName");
+ }
+
+ ...
+}
+</pre>
+You will need to register the Codec class so that the {@link java.util.ServiceLoader ServiceLoader} can find it, by including a
+META-INF/services/org.apache.lucene.codecs.Codec file on your classpath that contains the package-qualified
+name of your codec.
+</p>
+
+<p>
+ If you just want to customise the {@link org.apache.lucene.codecs.PostingsFormat}, or use different postings
+ formats for different fields, then you can register your custom postings format in the same way (in
+ META-INF/services/org.apache.lucene.codecs.PostingsFormat), and then extend the default
+ {@link org.apache.lucene.codecs.lucene40.Lucene40Codec} and override
+ {@link org.apache.lucene.codecs.lucene40.Lucene40Codec#getPostingsFormatForField(String)} to return your custom
+ postings format.
+</p>
</body>
</html>