213 lines
6.7 KiB
Plaintext
213 lines
6.7 KiB
Plaintext
Solr control panel
|
|
==================
|
|
|
|
First some initial setup code:
|
|
|
|
We need to patch the dispatcher because we want to test *setting* solr to
|
|
active without *having* it active.
|
|
>>> from collective.solr import dispatcher
|
|
>>> _save_isActive = dispatcher.isActive
|
|
>>> dispatcher.isActive = lambda:False
|
|
|
|
>>> self.loginAsManager()
|
|
>>> from zope.component import getUtility
|
|
>>> from collective.solr.interfaces import ISolrConnectionConfig
|
|
>>> config = getUtility(ISolrConnectionConfig)
|
|
>>> config.active
|
|
False
|
|
>>> config.host
|
|
'127.0.0.1'
|
|
>>> config.port
|
|
8983
|
|
>>> config.base
|
|
'/solr'
|
|
>>> config.async
|
|
False
|
|
>>> config.auto_commit
|
|
True
|
|
>>> config.commit_within
|
|
0
|
|
>>> config.index_timeout
|
|
0.0
|
|
>>> config.search_timeout
|
|
0.0
|
|
>>> config.max_results
|
|
0
|
|
>>> config.required
|
|
('SearchableText',)
|
|
>>> config.facets
|
|
('portal_type', 'review_state')
|
|
>>> config.filter_queries
|
|
('portal_type',)
|
|
>>> config.slow_query_threshold
|
|
0
|
|
>>> config.effective_steps
|
|
1
|
|
>>> config.exclude_user
|
|
False
|
|
>>> config.highlight_fields
|
|
()
|
|
>>> config.highlight_formatter_pre
|
|
'['
|
|
>>> config.highlight_formatter_post
|
|
']'
|
|
>>> config.highlight_fragsize
|
|
100
|
|
>>> config.field_list
|
|
[]
|
|
>>> config.levenshtein_distance
|
|
0.0
|
|
|
|
|
|
Viewing the site control panel
|
|
------------------------------
|
|
|
|
>>> self.browser.open('http://nohost/plone/@@solr-controlpanel')
|
|
>>> self.browser.url
|
|
'http://nohost/plone/@@solr-controlpanel'
|
|
|
|
Click the cancel button:
|
|
|
|
>>> self.browser.getControl(name="form.actions.cancel").click()
|
|
>>> self.browser.url.endswith('plone_control_panel')
|
|
True
|
|
|
|
There should be still no changes:
|
|
|
|
>>> 'Changes canceled.' in self.browser.contents
|
|
True
|
|
|
|
|
|
Make some changes
|
|
-----------------
|
|
|
|
>>> self.browser.open('http://nohost/plone/@@solr-controlpanel')
|
|
>>> self.browser.url.endswith('solr-controlpanel')
|
|
True
|
|
|
|
>>> self.browser.getControl(name='form.active').value = True
|
|
>>> self.browser.getControl(name='form.host').value = 'foo.bar'
|
|
>>> self.browser.getControl(name='form.port').value = '1234'
|
|
>>> self.browser.getControl(name='form.base').value = '/solr'
|
|
>>> self.browser.getControl(name='form.async').value = True
|
|
>>> self.browser.getControl(name='form.auto_commit').value = False
|
|
>>> self.browser.getControl(name='form.commit_within').value = '10000'
|
|
>>> self.browser.getControl(name='form.index_timeout').value = '7'
|
|
>>> self.browser.getControl(name='form.search_timeout').value = '3.1415'
|
|
>>> self.browser.getControl(name='form.max_results').value = '23'
|
|
>>> self.browser.getControl(name='form.required.0.').value = 'foo'
|
|
>>> self.browser.getControl(name='form.required.add').click()
|
|
>>> self.browser.getControl(name='form.required.1.').value = 'bar'
|
|
>>> self.browser.getControl(name='form.search_pattern').value = '(Title:{value})'
|
|
>>> self.browser.getControl(name='form.facets.0.').value = 'type'
|
|
>>> self.browser.getControl(name='form.facets.1.').value = 'state'
|
|
>>> self.browser.getControl(name='form.filter_queries.0.').value = 'portal_type'
|
|
>>> self.browser.getControl(name='form.slow_query_threshold').value = '50'
|
|
>>> self.browser.getControl(name='form.effective_steps').value = '300'
|
|
>>> self.browser.getControl(name='form.exclude_user').value = True
|
|
>>> self.browser.getControl(name='form.highlight_fields.add').click()
|
|
>>> self.browser.getControl(name='form.highlight_fields.0.').value = 'SearchableText'
|
|
>>> self.browser.getControl(name='form.highlight_formatter_pre').value = '>'
|
|
>>> self.browser.getControl(name='form.highlight_formatter_post').value = '<'
|
|
>>> self.browser.getControl(name='form.highlight_fragsize').value = '150'
|
|
>>> self.browser.getControl(name='form.field_list.add').click()
|
|
>>> self.browser.getControl(name='form.field_list.0.').value = 'Title'
|
|
>>> self.browser.getControl(name='form.field_list.add').click()
|
|
>>> self.browser.getControl(name='form.field_list.1.').value = 'effective'
|
|
>>> self.browser.getControl(name='form.levenshtein_distance').value = '0.1'
|
|
|
|
Click the save button:
|
|
|
|
>>> self.browser.getControl(name="form.actions.save").click()
|
|
>>> self.browser.url.endswith('solr-controlpanel')
|
|
True
|
|
|
|
We should be informed that something has changed:
|
|
|
|
>>> 'Changes saved.' in self.browser.contents
|
|
True
|
|
|
|
Make sure the changes have been applied correctly to the tool:
|
|
|
|
>>> config.active
|
|
True
|
|
>>> config.host
|
|
u'foo.bar'
|
|
>>> config.port
|
|
1234
|
|
>>> config.base
|
|
'/solr'
|
|
>>> config.async
|
|
True
|
|
>>> config.auto_commit
|
|
False
|
|
>>> config.commit_within
|
|
10000
|
|
>>> config.index_timeout
|
|
7.0
|
|
>>> config.search_timeout
|
|
3.1415...
|
|
>>> config.max_results
|
|
23
|
|
>>> config.required
|
|
[u'foo', u'bar']
|
|
>>> config.search_pattern
|
|
'(Title:{value})'
|
|
>>> config.facets
|
|
[u'type', u'state']
|
|
>>> config.slow_query_threshold
|
|
50
|
|
>>> config.effective_steps
|
|
300
|
|
>>> config.exclude_user
|
|
True
|
|
>>> config.highlight_fields
|
|
[u'SearchableText']
|
|
>>> config.highlight_formatter_pre
|
|
u'>'
|
|
>>> config.highlight_formatter_post
|
|
u'<'
|
|
>>> config.highlight_fragsize
|
|
150
|
|
>>> config.field_list
|
|
[u'Title', u'effective']
|
|
>>> config.levenshtein_distance
|
|
0.1
|
|
|
|
Now that the connection is active we can also select more filter query
|
|
parameters from the complete list of Solr indexes, provided that we use the
|
|
correct host and port:
|
|
|
|
>>> self.browser.getControl(name='form.host').value = '127.0.0.1'
|
|
>>> self.browser.getControl(name='form.port').value = '8983'
|
|
>>> self.browser.getControl(name="form.actions.save").click()
|
|
|
|
>>> self.browser.getControl(name='form.filter_queries.add').click()
|
|
>>> self.browser.getControl(name='form.filter_queries.0.').value = 'Subject'
|
|
>>> self.browser.getControl(name='form.filter_queries.1.').value = 'review_state'
|
|
>>> self.browser.getControl(name="form.actions.save").click()
|
|
>>> sorted(config.filter_queries)
|
|
[u'Subject', u'review_state']
|
|
|
|
|
|
Required query parameters
|
|
-------------------------
|
|
|
|
Lastly, let's make sure the "Required query parameters" setting can be set
|
|
to an empty list (please see `issue #18`__ for more infos):
|
|
|
|
.. __: http://plone.org/products/collective.solr/issues/18
|
|
|
|
>>> self.browser.getControl(name='form.required.remove_0').value = True
|
|
>>> self.browser.getControl(name='form.required.remove_1').value = True
|
|
>>> self.browser.getControl(name='form.required.remove').click()
|
|
>>> self.browser.getControl(name="form.actions.save").click()
|
|
>>> 'Changes saved.' in self.browser.contents
|
|
True
|
|
|
|
>>> config.required
|
|
[]
|
|
|
|
Clean up.
|
|
>>> dispatcher.isActive = _save_isActive
|