休止状態のドキュメントから非常に基本的な休止状態の検索を作成しました。結果を制限するのに苦労しています。私が間違っていることについて少しアドバイスをお願いします。
シナリオ
そのような説明タイトルを持つ1つのエンティティを使用しているとしましょう
@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
private String name;
次のデータをインデックスに追加
1. Dell Laptop
2. Dell Desktop
3. HP Desktop
私の検索はそのように見えます、
FullTextSession fullTextSession = Search.getFullTextSession(sessionManager.getSession());
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(Computer.class).get();
Query luceneQuery = queryBuilder.keyword().onFields("name").matching(keyword).createQuery();
org.hibernate.search.FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, Computer.class);
以下を使用してキーワード検索を行うと、すべてが正常に機能するようになりました。
Dell returns Dell Laptop, Dell Desktop
Desktop returns Dell, HP
ただし、そのように検索すると、結果が適切に制限されません
Dell Desktop returns Dell Laptop, Dell Desktop, HP Desktop.
単一の一致のみを返すように結果を制限するにはどうすればよいですか?