コードをLucene3.6からLucene4.1に変換した後の奇妙なテストの失敗
public void testIndexPuid() throws Exception {
addReleaseOne();
RAMDirectory ramDir = new RAMDirectory();
createIndex(ramDir);
IndexReader ir = IndexReader.open(ramDir);
Fields fields = MultiFields.getFields(ir);
Terms terms = fields.terms("puid");
TermsEnum termsEnum = terms.iterator(null);
termsEnum.next();
assertEquals("efd2ace2-b3b9-305f-8a53-9803595c0e38", termsEnum.term());
}
戻り値:
予想:efd2ace2-b3b9-305f-8a53-9803595c0e38実際:[65 66 64 32 61 63 65 32 2d 62 33 62 39 2d 33 30 35 66 2d 38 61 35 33 2d 39 38 30 33 35 39 35 63 30 65 33 38 ]
フィールドをテキストフィールドではなくバイナリフィールドとして追加しているようですが、確認したところ、非推奨のフィールドを使用してフィールドが追加されています。
new Field( "puid"、value、Field.Index.NOT_ANALYZED_NO_NORMS、new KeyboardAnalyzer())
それで、それは以前と同じように機能するべきではありませんか?