Skip to content

Commit

Permalink
Soft commit on reindexes
Browse files Browse the repository at this point in the history
Allow data to be saved and ready to be used by Solr.

Note that at the end of reindex a hard commit is done which will save
the changes on the disk.

See:
http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22
  • Loading branch information
gforcada committed Dec 14, 2015
1 parent d9dff54 commit a8025f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Changelog
- Add zopectl.command for reindexing. Do not rely on positional arguments in _get_site.
[tschorr]

- Soft commit changes while reindexing.
This allows to get results on searches while reindexing is taking place.
[gforcada]

4.1.0 (2015-02-19)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/collective/solr/browser/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def reindex(self, batch=1000, skip=0, limit=0, ignore_portal_types=None,
schema = manager.getSchema()
key = schema.uniqueKey
updates = {} # list to hold data to be updated
flush = lambda: conn.flush()
flush = lambda: conn.commit(soft=True)
flush = notimeout(flush)

def checkPoint():
Expand Down
5 changes: 3 additions & 2 deletions src/collective/solr/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,13 @@ def add(self, boost_values=None, **fields):
xstr = ''.join(lst)
return self.doUpdateXML(xstr)

def commit(self, waitSearcher=True, optimize=False):
def commit(self, waitSearcher=True, optimize=False, soft=False):
data = {
'committype': optimize and 'optimize' or 'commit',
'nowait': not waitSearcher and ' waitSearcher="false"' or '',
'soft': soft and ' softCommit="true"' or '',
}
xstr = '<%(committype)s%(nowait)s/>' % data
xstr = '<%(committype)s%(soft)s%(nowait)s/>' % data
self.doUpdateXML(xstr)
return self.flush()

Expand Down

0 comments on commit a8025f0

Please sign in to comment.