短い質問は次のとおりです。
Solr 4.3.0 インデックスで格納されたフィールドの圧縮を無効にしたいと考えています。読んだあと :
http://blog.jpountz.net/post/35667727458/stored-fields-compression-in-lucene-4-1
http://wiki.apache.org/solr/SimpleTextCodecExample
http://www.opensourceconnections.com/2013/06/05/build-your-own-lucene-codec/
そこで説明されている道をたどり、独自のコーデックを作成することにしました。すべての手順に従っていると確信していますが、実際に自分のコーデック (愛情を込めて「UncompressedStorageCodec」という名前) を使用しようとすると、Solr ログに次のエラーが記録されます。
java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'UncompressedStorageCodec' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.
The current classpath supports the following names: [Pulsing41, SimpleText, Memory, BloomFilter, Direct, Lucene40, Lucene41]
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
出力から、Solr がカスタム コーデックで jar を取得していないことがわかりましたが、その理由がわかりません。
恐ろしい詳細は次のとおりです。
次のようなクラスを作成しました。
public class UncompressedStorageCodec extends FilterCodec {
private final StoredFieldsFormat fieldsFormat = new Lucene40StoredFieldsFormat();
protected UncompressedStorageCodec() {
super("UncompressedStorageCodec", new Lucene42Codec());
}
@Override
public StoredFieldsFormat storedFieldsFormat() {
return fieldsFormat;
}
}
パッケージ内: 「fr.company.project.solr.transformers.utils」
「FilterCodec」の FQDN は「org.apache.lucene.codecs.FilterCodec」です。
これから基本的なjarファイルを作成しました(Eclipseからjarとしてエクスポートしました)。
これをテストするために私が使用している Solr インストールは、解凍された基本的な Solr 4.3.0 であり、組み込みの Jetty サーバーを介して、サンプル コアを使用して開始されます。
[solrDir]\dist にコーデックを含む jar を配置しました
の:
[solrDir]\example\solr\myCore\conf\solrconfig.xml
次の行を追加しました。
<lib dir="../../../dist/" regex="myJarWithCodec-1.10.1.jar" />
次に、schema.xml ファイルで、このコーデックを使用する必要があるいくつかの fieldTypes を次のように宣言しました。
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" postingsFormat="UncompressedStorageCodec"/>
<fieldType name="string_lowercase" class="solr.TextField" positionIncrementGap="100" omitNorms="true" postingsFormat="UncompressedStorageCodec">
<!--...-->
</fieldType>
ここで、DataImportHandler コンポーネントを使用してデータを Solr にインポートすると、コミット時に次のように通知されます。
java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'UncompressedStorageCodec' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.
The current classpath supports the following names: [Pulsing41, SimpleText, Memory, BloomFilter, Direct, Lucene40, Lucene41]
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
私が奇妙だと思うのは、上記のコーデック jar には、DataImportHandler コンポーネント用のトランスフォーマーもいくつか含まれていることです。そして、それらはうまく拾われます。また、dist フォルダーに配置された (および solrconfig.xml で同じように宣言された) 他の jar ファイル (jdbc ドライバーなど) も正常に取得されます。コーデックには、異なる方法でロードするこの SPI があり、彼が欠けているものがあると思います...
また、コーデック jar を次の場所に配置しようとしました。
[solrDir]\example\solr-webapp\webapp\WEB-INF\lib\
solr.war ファイルの WEB-INF\lib フォルダー内と同様に、次の場所にあります。
[solrDir]\example\webapps\
しかし、私はまだ同じエラーが発生しています。
基本的に、私の質問は、Solr がコーデック jar を取得するために何が欠けているのでしょうか?
ありがとう