audleman wrote:
Hi,
in addition to the help and advice that you've gotten
already I'd like to provide some further guidance:
> I am struggling with searching on a custom content type. I could use some
> help understanding how to search on, let's say, first name. My SpeakerSchema
> has that field defined as:
>
> atapi.StringField('first_name',
> schemata='default',
> searchable=True,
This means you make it available via the full text search
(it's added to the 'SearchableText').
In order to create a dedicated index for that field you need
to provide the appropriate snippet in your products installation
profile as others have pointed out.
Note that Zope's catalog provides different index types
(Field-, Keyword-, TextIndex, etc.) that provide different
functionality. Read the chapter in the Zope book that you have
been pointed to to understand the differences. Then you can
make an informed decision.
Sometimes, it is necessary to index the same information
several times to support different use cases (like globbing
- aka wild card support - versus sorting). For that reason
you can usually define the name of the index to be different
from the attribute/method to call.
Doing a search for 'K*' on a (ZC)TextIndex(NG) and expecting
everything that starts with 'K' in return can be a bit too naive
depending on how you configured the index. Some index types
interpret non-ascii characters as stop characters for instance
so you might get false positives.
Finally, using a StringField with a MultiSelectWidget is usually
a bad idea as multiple selections should usually result in a
list-like data type (or a collection). While techically the
'string' type is a sequence (of characters) you might want
to consider using a lines field instead.
Also, when indexing such a field specifically, what you most
often want is a KeywordIndex. But only thinking
about your intended use cases will tell.
HTH
Raphael
> required=True,
> languageIndependent=True,
> widget = atapi.StringWidget(
> label=_(u'First Name'),
> description = _(u''),
> ),
> storage = atapi.AnnotationStorage(),
> ),
>
> I have tried several things, including searching on the getFirst_name
> function:
>
> self.catalog = getToolByName(context, 'portal_catalog')
> self.catalog.searchResults({'portal_type' :'Speaker', 'getFirst_name' :
> 'Kevin'})
>
> ...searching on the field name itself
>
> self.catalog = getToolByName(context, 'portal_catalog')
> self.catalog.searchResults({'portal_type':'Speaker',
> 'first_name':'Kevin'})
>
> In both cases the query returns all Speaker objects, totally ignoring the
> extra search parameter.
>
> Any suggestions?
>
> Thanks,
> Kevin Audleman
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users