|
a/Allura/allura/lib/search.py |
|
b/Allura/allura/lib/search.py |
|
... |
|
... |
38 |
text = pformat(doc.values())
|
38 |
text = pformat(doc.values())
|
39 |
doc['text'] = text
|
39 |
doc['text'] = text
|
40 |
return doc
|
40 |
return doc
|
41 |
|
41 |
|
42 |
@try_solr
|
42 |
@try_solr
|
43 |
def add_artifacts(obj_iter):
|
|
|
44 |
artifact_iterator = ( o.dump_ref() for o in obj_iter)
|
|
|
45 |
while True:
|
|
|
46 |
artifacts = list(islice(artifact_iterator, 1000))
|
|
|
47 |
for aref in artifacts:
|
|
|
48 |
aname = pickle.loads(aref.artifact_type).__name__
|
|
|
49 |
h.log_action(log, 'upsert artifact').info(
|
|
|
50 |
'upsert artifact %s', aname,
|
|
|
51 |
meta=dict(
|
|
|
52 |
type=aname,
|
|
|
53 |
id=aref.artifact_id))
|
|
|
54 |
if not artifacts: break
|
|
|
55 |
g.publish('react', 'artifacts_altered',
|
|
|
56 |
dict(artifacts=artifacts),
|
|
|
57 |
serializer='pickle')
|
|
|
58 |
|
|
|
59 |
@try_solr
|
|
|
60 |
def remove_artifacts(obj_iter):
|
|
|
61 |
artifact_iterator = ( o.dump_ref() for o in obj_iter)
|
|
|
62 |
while True:
|
|
|
63 |
artifacts = list(islice(artifact_iterator, 1000))
|
|
|
64 |
for aref in artifacts:
|
|
|
65 |
aname = pickle.loads(aref.artifact_type).__name__
|
|
|
66 |
h.log_action(log, 'delete artifact').info(
|
|
|
67 |
'delete artifact %s', aname,
|
|
|
68 |
meta=dict(
|
|
|
69 |
type=aname,
|
|
|
70 |
id=aref.artifact_id))
|
|
|
71 |
if not artifacts: break
|
|
|
72 |
g.publish('react', 'artifacts_removed',
|
|
|
73 |
dict(artifacts=artifacts),
|
|
|
74 |
serializer='pickle')
|
|
|
75 |
|
|
|
76 |
@try_solr
|
|
|
77 |
def search(q,**kw):
|
43 |
def search(q,**kw):
|
78 |
return g.solr.search(q, **kw)
|
44 |
return g.solr.search(q, **kw)
|
79 |
|
45 |
|
80 |
def search_artifact(atype, q, history=False, rows=10, **kw):
|
46 |
def search_artifact(atype, q, history=False, rows=10, **kw):
|
81 |
"""Performs SOLR search.
|
47 |
"""Performs SOLR search.
|