开发者

How to search for ZCatalog object names

I want to Search for an Object n开发者_如何学运维ame. If i have this Structure: /de/myspace/media/justAnotherPdf.pdf

Then i want to Search for the name "justAnotherPdf" to find it or something like "justAnot" I have Indexed the pdf files.

But i cant search it with TextIndexNG2 or PathIndex.


Currently this is not supported out-of-the-box. Object identifiers (getId) are only indexed as field values and thus can only be looked up as whole strings.

You'd need to add separate index to the catalog to support your use-case. You could add a new TextIndexNG2 index with a new name indexing just the getId method. In the ZMI, find the portal_catalog, then it's 'Indexes' tab, then on the right-hand-side you'll find a drop-down menu for adding a new index. Pick a memorable name ('fullTextId' for example) and use getId as the indexed attribute.

You'll need to do a reindex, but only for that index. Once added, select it in on the Indexes tab (tick the check-box) and select 'Reindex' at the bottom of that page. Now you can use this index in your custom searches with a wildcard search.


import os.path
name = os.path.splitext(os.path.split(url)[1])[0]

explaining the code:

from os.path import split, splitext
url = '/de/myspace/media/justAnotherPdf.pdf'
path, name_with_ext = split(url)
name_without_ext, ext = splitext(name_with_ext)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜