[英]Why is mapping for spring data solr slow?
說我有以下課程的solrdocument
@SolrDocument(solrCoreName="some_core")
public class SolrProduct {
@Id
@Indexed(name="id")
private String id;
@Indexed(name="title_str")
private String title;
....
在數據訪問層中,代碼很簡單
public interface ProductRepository extends SolrCrudRepository <SolrProduct, Long> {
public Page<SolrProduct> findByTitle(String title, Pageable page);
public List<SolrProduct> findByTitle(String title);
}
在服務層,當我打電話時
productService.findByTitle("computer", new PageRequest(0, 10));
這很好,因為我只能得到10個結果。 但是,如果我打電話
productService.findByTitle("computer");
由於有10,000多種帶有computer
標題的Solr產品,因此加載需要一分鍾以上的時間。
我創建的solrdocument POJO類中不存在solr數據中存在的許多其他字段,因此我猜測字段的映射需要一些時間。 這個對嗎? 還是僅僅是由於在通話期間加載大量數據引起的? 有什么辦法可以加快速度嗎?
如果我正確理解的話,solr文檔中存儲了許多字段,但是只有一小部分被映射到Java文檔? 如果為s,則可以限制從solr返回的文件名:
query.addProjectionOnField("myfield1");
....
query.addProjectionOnField("myfieldn");
這應該保存從服務器傳輸的數據,不確定如何加快映射速度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.