paginate select when initializing search index

This commit is contained in:
trinity-1686a 2024-01-31 22:08:21 +01:00
parent 304fb740d8
commit 4f848ca278

View file

@ -289,13 +289,27 @@ Then try to restart Plume
} }
pub fn fill(&self, conn: &Connection) -> Result<()> { pub fn fill(&self, conn: &Connection) -> Result<()> {
for post in posts::table let mut writer = self.writer.lock().unwrap();
.filter(posts::published.eq(true)) let writer = writer.as_mut().unwrap();
.load::<Post>(conn)? writer.delete_all_documents().unwrap();
{
self.update_document(conn, &post)? const PAGE_SIZE: i64 = 1000;
let mut count = 0;
loop {
let posts = posts::table
.filter(posts::published.eq(true))
.order(posts::id.asc())
.limit(PAGE_SIZE)
.offset(count)
.load::<Post>(conn)?;
for post in posts.iter() {
self.add_document(conn, post)?
}
if posts.len() < PAGE_SIZE as usize {
break Ok(())
}
count += posts.len();
} }
Ok(())
} }
pub fn commit(&self) { pub fn commit(&self) {