Commit e71cd2dd155eb585224956b89a84f151e7f62b9a
1 parent
e0db3da9
Exists in
master
and in
39 other branches
Adding solr commands to fabfile
-Add rebuild inde -Add update index -Add build schema
Showing
1 changed file
with
30 additions
and
0 deletions
Show diff stats
fabfile.py
@@ -283,5 +283,35 @@ def solr(port=8983): | @@ -283,5 +283,35 @@ def solr(port=8983): | ||
283 | """Start Solr""" | 283 | """Start Solr""" |
284 | with cd('~/solr-4.6.1/colab'), settings(user='colab'): | 284 | with cd('~/solr-4.6.1/colab'), settings(user='colab'): |
285 | run('java -jar start.jar -Djetty.port={}'.format(port)) | 285 | run('java -jar start.jar -Djetty.port={}'.format(port)) |
286 | + | ||
287 | + | ||
288 | +@task | ||
289 | +def rebuild_index(age=None, batch=None): | ||
290 | + """Rebuild the solr index""" | ||
291 | + age_arg = '' | ||
292 | + if age: | ||
293 | + age_arg = '--age={}'.format(age) | ||
294 | + | ||
295 | + batch_arg = '' | ||
296 | + if batch: | ||
297 | + batch_arg = '--batch-size={}'.format(batch) | ||
298 | + | ||
299 | + manage('rebuild_index {} {}'.format(age_arg, batch_arg)) | ||
300 | + | ||
301 | + | ||
302 | +@task | ||
303 | +def update_index(): | ||
304 | + """Update solr index""" | ||
305 | + manage('update_index') | ||
306 | + | ||
307 | + | ||
308 | +@task | ||
309 | +def build_schema(): | ||
310 | + """Build solr schema""" | ||
311 | + solr_schema_file = '~/solr-4.6.1/colab/solr/collection1/conf/schema.xml' | ||
312 | + manage('build_solr_schema -f {}'.format(solr_schema_file)) | ||
313 | + run(r'sed -i "s/<fields>/<fields>\n<field name=\"_version_\" type=\"long\" indexed=\"true\" stored =\"true\"\/>/" {}'.format(solr_schema_file)) | ||
314 | + | ||
315 | + | ||
286 | # Main | 316 | # Main |
287 | environment() | 317 | environment() |