|
a/Allura/allura/lib/solr.py |
|
b/Allura/allura/lib/solr.py |
|
... |
|
... |
14 |
# KIND, either express or implied. See the License for the
|
14 |
# KIND, either express or implied. See the License for the
|
15 |
# specific language governing permissions and limitations
|
15 |
# specific language governing permissions and limitations
|
16 |
# under the License.
|
16 |
# under the License.
|
17 |
|
17 |
|
18 |
import shlex
|
18 |
import shlex
|
|
|
19 |
|
|
|
20 |
from tg import config
|
|
|
21 |
from paste.deploy.converters import asbool
|
19 |
import pysolr
|
22 |
import pysolr
|
20 |
from pysolr import SolrError
|
23 |
|
|
|
24 |
|
|
|
25 |
def make_solr_from_config(push_servers, query_server=None, **kwargs):
|
|
|
26 |
"""
|
|
|
27 |
Make a :class:`Solr <Solr>` instance from config defaults. Use
|
|
|
28 |
`**kwargs` to override any value
|
|
|
29 |
"""
|
|
|
30 |
solr_kwargs = dict(
|
|
|
31 |
commit=asbool(config.get('solr.commit', True)),
|
|
|
32 |
commitWithin=config.get('solr.commitWithin'),
|
|
|
33 |
timeout=int(config.get('solr.long_timeout', 60)),
|
|
|
34 |
)
|
|
|
35 |
solr_kwargs.update(kwargs)
|
|
|
36 |
return Solr(push_servers, query_server, **solr_kwargs)
|
21 |
|
37 |
|
22 |
|
38 |
|
23 |
class Solr(object):
|
39 |
class Solr(object):
|
24 |
"""Solr interface that pushes updates to multiple solr instances.
|
40 |
"""Solr interface that pushes updates to multiple solr instances.
|
25 |
|
41 |
|
|
... |
|
... |
129 |
elif kwargs.get('id', None):
|
145 |
elif kwargs.get('id', None):
|
130 |
del self.db[kwargs['id']]
|
146 |
del self.db[kwargs['id']]
|
131 |
elif kwargs.get('q', None):
|
147 |
elif kwargs.get('q', None):
|
132 |
for doc in self.search(kwargs['q']):
|
148 |
for doc in self.search(kwargs['q']):
|
133 |
self.delete(id=doc['id'])
|
149 |
self.delete(id=doc['id'])
|
134 |
|
|
|