Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:55:25+00:00 2026-06-11T12:55:25+00:00

I am performing a search inside a folder. Unfortunately, it retrieves also the root

  • 0

I am performing a search inside a folder. Unfortunately, it retrieves also the root folder, and I do not want that.

An example is as follows. If I have a directory structure similar to the one below:

RootFolder
    ... SubFolder1
    ... SubFolder2

I expect to get the following when I search inside RootFolder directory:

SubFolder1
SubFolder2

But instead, this is what I get:

RootFolder
SubFolder1
SubFolder2

I do not want the root to be displayed. Below is the code that I use to fetch/search the items within a folder:

def queryItemRepository(self):
    """
    Perform a search
    """

    query = {}

    portal_catalog = getToolByName(self, 'portal_catalog')
    folder_path = '/'.join( self.context.getPhysicalPath() )

    query['path'] = {'query' : folder_path, 'depth' : 2 }
    query['sort_on'] = "sortable_title"
    query['sort_order'] = "ascending"

    return portal_catalog.searchResults(query)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:55:26+00:00Added an answer on June 11, 2026 at 12:55 pm

    The depth parameter in path searches limits the depth of the search, it does not set a minimal level. So, in your search, all paths starting at folder_path up to and including 2 nested levels of children are returned.

    Just filter out the root path; you already have the context so you can just compare URL of each item:

    for match in portal_catalog.searchResults(query):
        if match.getPath() == folder_path:
            continue
        yield match
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

assume that we are performing search using keywords: keyword1, keyword2, keyword3 there are records
While performing some upcoming maintenance, I'm going to have to redirect all site traffic
When performing many inserts into a database I would usually have code like this:
Im talking about performing a deep recursion for around 5+ mins, something that you
SELECT value FROM table WHERE id IN (1,2,3, ... 500000) Have a query that
Here is my problem: I have a sequence S of (nonempty but possibly not
I want to implement a search in my Android application. In this page, first
I am performing a AJAX call after dismissing a Sheet. The problem is that
We have a pair of strings for example such pair Accept-Language : RU ,
I have a stored procedure in my database that calculates the distance between two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.