mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 11:31:01 +00:00
paginate select when initializing search index
This commit is contained in:
parent
304fb740d8
commit
4f848ca278
1 changed files with 20 additions and 6 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue