#7 — Unable to add criteria on a collection after installing solr index

by Lucie Lejard last modified Aug 10, 2011 09:48 PM
State Confirmed
Version: 1.1.1
Area Functionality
Issue type Bug
Severity Important
Submitted by Lucie Lejard
Submitted on Dec 20, 2010
Responsible David Blewett
Target release: 1.1.1
Since alm.solrindex removes the indexes Title and Description, it makes the collection "criteria" tab error out with :

2010-12-13 17:05:43 ERROR Zope.SiteErrorLog 1292277943.380.545058921698 http://localhost:51081/[…]/criterion_edit_form
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in _call
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 51, in FSPT_pt_render
  Module Products.PTProfiler.ProfilerPatch, line 83, in __patched_render__
  Module Products.CacheSetup.patch_cmf, line 126, in PT_pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.NameError: name 'criterion' is not defined
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 824, in do_loop_tal
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 854, in do_condition
  Module Products.PageTemplates.Expressions, line 213, in evaluateBoolean
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/Users/thomas/.buildout/eggs/Products.ATContentTypes-1.3.4-py2.4.egg/Products/ATContentTypes/skins/ATContentTypes/criterion_edit_form.cpt
   - Line 164, Column 20
   - Expression: <PythonExpr here.allowedCriteriaForField(field[0])>
   - Names:
      {'container': <PloneSite at /myproject>,
       'context': <ATTopic at /myproject/collec/foo>,
       'default': <object object at 0x100315200>,
       'here': <ATTopic at /myproject/collec/foo>,
       'loop': {u'field': <Products.PageTemplates.Expressions.PathIterator object at 0x1136d7910>},
       'nothing': None,
       'options': {'args': (),
                   'state': <Products.CMFFormController.ControllerState.ControllerState object at 0x112e83850>},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x1137090e0>,
       'request': <HTTPRequest, URL=http://localhost:51081/[…]/criterion_edit_form>,
       'root': <Application at >,
       'template': <FSControllerPageTemplate at /myproject/criterion_edit_form used for /myproject/collec/foo>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>}
  Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: here.allowedCriteriaForField(field[0])
  Module PythonExpr, line 1, in <expression>
  Module Products.ATContentTypes.content.topic, line 369, in allowedCriteriaForField
  Module Products.ATContentTypes.content.topic, line 196, in validateAddCriterion
  Module Products.ATContentTypes.content.topic, line 201, in criteriaByIndexId
  Module OFS.ObjectManager, line 754, in __getitem__
KeyError: 'Description'
Steps to reproduce:
 * log in as admin
 * create a collection with just a title and save
 * click on the "criteria" tab and you get the error above
Added by Clayton Parker on May 10, 2011 02:57 PM
Issue state: UnconfirmedConfirmed
Severity: MediumImportant
The collection cannot find the indexes that were removed by alm.solrindex. This could be worked around by adding the indexes back into the catalog (this just means the catalog will be more bloated than it should be).
Added by Maurits van Rees on Aug 10, 2011 09:48 PM
It seems wrong to me to remove the Title and Description indexes as this has unwanted results. For example, when I search for Description 'foobar' on the advanced search form I should get no results (on most sites anyway), but when alm.solrindex is installed all brains in the catalog are returned. When I manually add a Description index (just a standard ZCTextIndex) search results are back to normal.

Alternatively, if we really want to remove these two indexes, then we can fix the reported error by also removing (or disabling) these indexes from portal_atct. This can be done with the following portal_atct.xml::

  <?xml version="1.0"?>
  <atcttool
      xmlns:i18n="http://xml.zope.org/namespaces/i18n">
   <topic_indexes i18n:domain="plone">
    <!-- Since we remove the Title and Description portal_catalog
         indexes, we must remove them here as well (or at least disable
         them), else we get an error when adding/editing a
         Collection. -->
    <index name="Title" description="Text search of an item's title"
       enabled="False" friendlyName="Title"
       remove="True"
       i18n:attributes="description; friendlyName">
     <criteria>ATSimpleStringCriterion</criteria>
    </index>
    <index name="Description" description="" enabled="False" friendlyName="Description"
       remove="True"
       i18n:attributes="description; friendlyName">
     <criteria>ATSimpleStringCriterion</criteria>
    </index>
    </topic_indexes>
  </atcttool>

No responses can be added.