プロジェクトで Lucene 4.3 を使用して全文検索機能を作成しています。データを追加するとすべて正常に動作しますが、クエリを実行すると、クエリの少なくとも 1 つの単語がフィールドの値の少なくとも 1 つの単語と一致する場合にのみヒットします。インデックス。
たとえば、追加した場合
private static StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
public static void addCustomerDoc(Map<String, String[]> parameters, String path, long customerId) throws IOException {
File file = new File(path + "/index/");
FSDirectory indexDir = FSDirectory.open(file);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, analyzer);
IndexWriter writer = new IndexWriter(indexDir, config);
Document doc = new Document();
doc.add(new TextField("email", parameters.get("email")[0].toString(), Field.Store.YES));
doc.add(new TextField("username", parameters.get("username")[0].toString(), Field.Store.YES));
doc.add(new TextField("phone", parameters.get("phone")[0].toString(), Field.Store.YES));
doc.add(new StringField("customerId", "" + customerId, Field.Store.YES));
addDoc(writer, doc);
writer.close();
}
private static void addDoc(IndexWriter writer, Document doc) throws IOException {
writer.addDocument(doc);
writer.commit();
}
のようなユーザーを追加する
- ユーザー名 = フーバー
- 電子メール = foobar@example.com
- 電話番号 = 0723123456
foo、fooba、または foobarx を検索してもヒットしません。f を入力したり、foobar という単語を超えたりしても結果が得られないのでしょうか?