[Grok-dev] Problems searching with the Catalog

Àlex Magaz Graça rivaldi8 at gmail.com
Wed Dec 14 17:20:57 UTC 2011


Hi Alex,

El 12/12/11 21:29, Alexandre Garel escribió:
> Le 12/12/2011 19:55, Àlex Magaz Graça a écrit :
>> Hi,
>>
>> I'm having some problems searching.
>>
>> The following fails, I guess, because "and" must be some kind of a 
>> keyword for searchResults() or something:
>>
>> catalog = getUtility(ICatalog)
>> catalog.searchResults(textattr="foo and")
>>
>> where textattr = grok.index.Text(). Is there some way to avoid this?
>
> Did you try 'foo "and"' ?
>
>

I was passing the search string entered by the user directly to 
searchResults() and didn't thought about trying this. I've resolved the 
problem quoting the words in the string.

>>
>> How do I match two non-consecutive values in an Field index? For 
>> example, objects which have 1 or 4 as a value in a given attribute.
> If you want to do this I think you'd better go with a Keyword index, 
> with FieldIndex you shall be able to ask for a range eg (1,4) for 1, 
> 2, 3, 4
>

It worked using grok.index.Value. By the way, I'm not sure, but it seems 
like the documentation of Value and Set should be exchanged.

>> It would help a lot if someone could point me to the API 
>> documentation of the catalog, I can't find it...
>
> You may look at zope/index/field/README.txt or 
> zope/index/text/textindex.txt even if its  low-level documentation
>

Oh! I missed the second one. I'm so desperate for documentation that I'm 
even looking at this kind of documentation through different eyes ;-)

Thanks a lot for the help!

Àlex


More information about the Grok-dev mailing list