SilvaFind

SilvaFind is a powerful search feature to allow easy creation of search forms and result pages, both for users of the public site and for authors in the SMI. Simple schemas can be defined to indicate which fields should be searchable.

Authors can add a Silva Find object anywhere and define which fields to make searchable by end users of the public site, and/or which fields to limit to a preset value. Authors also can determine which fields should be displayed in the search results. All metadata set/fields are supported.

If you can't add the Silva Find object in the SMI you should make sure it's checked in the addables section of the publication. If Silva Find is not checked, check it and uncheck the inheritance checkbox (otherwise inheritance will overrule it and uncheck it again).

By default all possible custom search criterion fields and result fields are available in the SMI. Besides that, the elements of all metadata sets are also available as result fields. If these fields are indexed in the catalog, they can also be used as search criterion fields. All available fields can be enabled/disabled in the SMI.

Besides this behavior, SilvaFind also allows you to manually override the list of search criteria. This behavior is also intended for backwards compatibility, but can be used to add your own custom fields from within other products.

For example the default global schema that SilvaFind installs (globalschema.py) looks as follows:

from Products.Silva.i18n import translate as _

from Products.SilvaFind.schema import SearchSchema
from Products.SilvaFind.schema import ResultsSchema

from Products.SilvaFind.schema import ResultField
from Products.SilvaFind.schema import FullTextCriterionField
from Products.SilvaFind.schema import MetadataCriterionField
from Products.SilvaFind.schema import MetatypeCriterionField
from Products.SilvaFind.schema import DateRangeMetadataCriterionField

globalSearchSchema = SearchSchema([
    MetatypeCriterionField(),
    FullTextCriterionField(),
    MetadataCriterionField('silva-content', 'maintitle'),
    MetadataCriterionField('silva-content', 'shorttitle'),
    DateRangeMetadataCriterionField('silva-extra', 'publicationtime'),
    ])

globalResultsSchema = ResultsSchema([
    ResultField('get_title', _('Title')),
    ])

The result schema defines what fields get shown in the list of results, by default as columns in a results table. There are currently 3 types of result fields (plain vanilla, metatype and metadata), and it is not hard to make your own. See schema.py for how that is done.

The following SearchField types exist for now, and of course it is possible to roll your own:

MetatypeCriterionField
allows the content that is to be searched, to be restricted to certain (one or more) content types.
FulltextCriterionField
allows the fulltext of the content item to be searched.
MetadataCriterionField
allows a specific metadata field of a specific metadata set to be searched.
DateRangeMetadataCriterionField
allows a specific datetime based metadata field of a specific metadata set to be searched, using a date range.
PathCriterionField
allows the content that is to be searched, to be restricted to be below a certain path. The path of the found children will always start with the supplied path, which is a string starting from the site root.

Making your own is as simple as creating a different SearchSchema and ResultsSchema in your extension, and registering it in the install.py of your extension. You can replace the global default search schema as follows, assuming myOwnSearchSchema is a valid SearchSchema object:

def register_search_schema(root):
    root.service_find.search_schema = myOwnSearchSchema
    root.service_find.manage_delObjects(['default'])
    SilvaFind.manage_addSilvaFind(
        root.service_find, 'default', 'Default search')
    default = root.service_find.default
    for field in root.service_find.getSearchSchema().getFields():
        fieldName = field.getName()
        default.shownFields[fieldName] = True
    default._p_changed = True

If your extension defines its own metadata-set, making the fields in that set searchable by putting them in your schema is easy:

myOwnSearchSchema = SearchSchema([

    ...

    MetadataCriterionField('my-metadataset', 'my-field1'),
    MetadataCriterionField('my-metadataset', 'my-field2'),

    ...

    ])

Code repository

You can find the code of this extension in Mercurial: https://hg.infrae.com/Products.SilvaFind/.

Available releases

Release version Release date Release files
Silva Find 3.0.2 May 24, 2013 12:35:49 PM Products.SilvaFind-3.0.2.tar.gz
Silva Find 3.0.1 Mar 6, 2013 3:46:30 PM Products.SilvaFind-3.0.1.tar.gz
Silva Find 3.0 Dec 11, 2012 11:47:32 AM Products.SilvaFind-3.0.tar.gz
Silva Find 3.0c1 Sep 25, 2012 11:51:37 AM Products.SilvaFind-3.0c1.tar.gz
Silva Find 3.0b1 Nov 11, 2011 5:03:10 PM Products.SilvaFind-3.0b1.tar.gz
Silva Find 1.3.2 Feb 7, 2011 3:53:50 PM Products.SilvaFind-1.3.2.tar.gz
Silva Find 1.3.1 Dec 20, 2010 1:57:29 PM Products.SilvaFind-1.3.1.tar.gz
Silva Find 1.3 Oct 18, 2010 4:30:15 PM Products.SilvaFind-1.3.tar.gz
Silva Find 1.3b1 Jul 16, 2010 3:01:10 PM Products.SilvaFind-1.3b1.tar.gz
Silva Find 1.2.1 Nov 26, 2010 3:32:45 PM Products.SilvaFind-1.2.1.tar.gz
Silva Find 1.2 Mar 31, 2010 9:39:07 AM Products.SilvaFind-1.2.tar.gz
Silva Find 1.2b2 Feb 8, 2010 11:38:01 AM Products.SilvaFind-1.2b2.tar.gz
Silva Find 1.2b1 Feb 1, 2010 6:40:35 PM Products.SilvaFind-1.2b1.tar.gz
Silva Find 1.1.7 Nov 4, 2008 5:35:13 PM SilvaFind-1.1.7.tar.gz
Silva Find 1.1.6 Oct 29, 2008 5:15:36 PM SilvaFind-1.1.6.tgz
Silva Find 1.1.5 Nov 17, 2008 4:57:27 PM Products.SilvaFind-1.1.5-py2.4.egg
Products.SilvaFind-1.1.5.tar.gz
Silva Find 1.1.3 Mar 3, 2008 12:36:55 PM SilvaFind-1.1.3.tar.gz
Silva Find 1.1.2 Dec 6, 2007 4:36:56 PM SilvaFind-1.1.2.tar.gz
Silva Find 1.1.1.3 Nov 4, 2008 5:36:38 PM SilvaFind-1.1.1.3.tar.gz
Silva Find 1.1.1.2 Jan 8, 2008 10:54:08 AM SilvaFind-1.1.1.2.tar.gz
Silva Find 1.1.1 May 23, 2007 4:50:10 PM SilvaFind-1.1.1.tgz
Silva Find 1.1 Mar 27, 2007 5:44:11 PM SilvaFind-1.1.tgz
Silva Find 1.0 Mar 27, 2007 5:44:11 PM SilvaFind-1.0.tgz
Silva Find 0.1.2 Dec 13, 2006 12:15:44 PM SilvaFind-0.1.2.tgz
Silva Find 0.1.1 Nov 7, 2006 5:39:13 PM SilvaFind-0.1.1.tgz
Silva Find 0.1 Oct 6, 2006 6:59:09 PM SilvaFind-0.1.tgz

License: New BSD