This discussion is archived
10 Replies Latest reply: Sep 1, 2008 7:30 AM by 655069 RSS

Search in Content DB

94551 Newbie
Currently Being Moderated
When searching for content, there is a hit only if the "Look in" field is set to the
folder where the document is located. It seems like "search in subfolders" does
not work.
And there is no a control to choose if the user wants to search in the current
folder, or also in the subfolders.

Regards
Gerard De Maeyer
  • 1. Re: Search in Content DB
    mshannon Newbie
    Currently Being Moderated
    Hi Gerard,

    I'm not sure if I agree. Have you viewed the Content DB developer samples specific to search?

    See the SearchAttributes example.

    When performing a search, one has the option to limit the results to a specific parent folder, and optionally, whether to include sub-folders of the parent or not.
            // restrict search to items under specific folder
            ClientUtils.newNamedValue(Options.FOLDER_RESTRICTION,
              new Long(workspace.getId())),
             // include subfolders
            ClientUtils.newNamedValue(Options.MULTILEVEL_FOLDER_RESTRICTION,
              Boolean.TRUE)
    thanks
    Matt.
  • 2. Re: Search in Content DB
    94551 Newbie
    Currently Being Moderated
    Matt

    thanks for your response.
    But my question was for a search with the search tool provided by a "out of the box" install , without any code.

    regards

    Gérard
  • 3. Re: Search in Content DB
    534136 Newbie
    Currently Being Moderated
    Dear Friends,
    I have a different question about searching the Content DB…

    The Java API Documentation informs us that the allowable attributes in a search expression are:
    •     Attributes.CREATE_DATE (data type is Date)
    •     Attributes.DESCRIPTION (data type is String)
    •     Attributes.LAST_MODIFIED_DATE (data type is Date)
    •     Attributes.MIME_TYPE (data type is String)
    •     Attributes.NAME (data type is String)
    •     Attributes.SIZE (data type is Long, only applies to Documents)
    •     Attributes.CREATED_BY:Attributes.ID (data type is Long)
    •     Attributes.CREATED_BY:Attributes.NAME (data type is String)
    •     Attributes.LAST_MODIFIED_BY:Attributes.ID (data type is Long)
    •     Attributes.LAST_MODIFIED_BY:Attributes.NAME (data type is String)
    •     Attributes.LOCK_EXCEPTED_USER:Attributes.ID (data type is Long)
    •     Attributes.LOCK_EXCEPTED_USER:Attributes.NAME (data type is String)
    •     Attributes.LOCK_TYPE (data type is Integer)

    If one needs to query for other document attributes, like CHECKED_OUT_BY, IS_RECORD, etc is there a way to retrieve the required documents?
    Thank you in advance,

    Max
  • 4. Re: Search in Content DB
    mshannon Newbie
    Currently Being Moderated
    Hi Max

    Checkout LockManager.listLockedDocuments
    You can supply it FdkConstants.LOCKTYPE_CHECKOUT

    You could also try using SearchManager search expression for Attributes.LOCK_TYPE (FdkConstants.LOCKTYPE_CHECKOUT) and Attributes.LOCK_EXCEPTED_USER (..john doe..)

    As far as restricting the search only for records, you can provide an option to SearchManager.search() ...

    Options.SEARCH_RECORDS - A Boolean specifying if the search should search records instead of documents. Default is FALSE, the search should perform a regular search for documents and folders.

    cheers

    Matt.
  • 5. Re: Search in Content DB
    534136 Newbie
    Currently Being Moderated
    Hi Matt!

    Just being curious...
    What does the syntax Attributes.CREATED_BY:Attributes.ID mean?
    Is the SearchExpression syntax different from others?
    I mean, for example, for a search by document name you would use something like

    SearchExpression nameExpr = new SearchExpression();

    nameExpr.setOperator(FdkConstants.OPERATOR_EQUAL);
    nameExpr.setLeftOperand(Attributes.NAME);
    nameExpr.setRightOperand("test");

    Would a search for Attributes.CREATED_BY for example have any differences?

    Thanx!

    Max
  • 6. Re: Search in Content DB
    mshannon Newbie
    Currently Being Moderated
    Attributes.CREATED_BY is of type "Item".

    To submit a search, it is unrealistic to expect a client to provide an Item instance as the value in a SearchExpression.

    Rather, the client can instead provide the ID of a USER item instance, or alternatively, the NAME of a USER item instance, in place of the actual item instance itself.

    On the server-side, Content DB will lookup the ID value or NAME value to locate the appropriate user item instance and process the search accordingly.

    ManagersFactory session = ...
    UserManager userM = session.getUserManager();
    Item user = userM.getUser("max", null);

    SearchExpression docsCreatedByMax = new SearchExpression();
    docsCreatedByMax.setOperator(FdkConstants.OPERATOR_EQUAL);
    docsCreatedByMax.setLeftOperation(Attributes.CREATED_BY + FdkConstants.SEPARATOR + Attributes.ID);
    docsCreatedByMax.setRightOperand(new Long(user.getId());

    NamedValue[] options = ...
    AttributeRequest[] requestedAttributes = ....
    NamedValue[] searchResults = searchM.search(docsCreatedByMax, options, requestedAttributes);


    or alternatively ....

    SearchExpression docsCreatedByMax = new SearchExpression();
    docsCreatedByMax.setOperator(FdkConstants.OPERATOR_EQUAL);
    docsCreatedByMax.setLeftOperation(Attributes.CREATED_BY + FdkConstants.SEPARATOR + Attributes.NAME);
    docsCreatedByMax.setRightOperand("max");

    NamedValue[] options = ...
    AttributeRequest[] requestedAttributes = ....
    NamedValue[] searchResults = searchM.search(docsCreatedByMax, options, requestedAttributes);
    cheers

    Matt.
  • 7. Re: Search in Content DB
    655069 Newbie
    Currently Being Moderated
    Hello,

    I'm searching a SearchExpression for "the folders created these day".What attributes should i have to use ?

    Thanks

    Message was edited by:
    orchloeve
  • 8. Re: Search in Content DB
    654954 Newbie
    Currently Being Moderated
    Hi orchloeve!

    I am not sure - because I'm not an expert -, but you should try this:

    SearchManager searchManager = managerFactory.SearchManager;

    AttributeRequest[] requestedAttributes = new AttributeRequest[]
    {
    ...
    };

    NamedValue[] searchOptions = new NamedValue[]
    {
    ClientUtils.newNamedValue(Options.SEARCH_FOR_DOCUMENTS, false),
    ClientUtils.newNamedValue(Options.SEARCH_FOR_FOLDERS, true) // true value is the default...
    };

    SearchExpression searchExpression = new SearchExpression();

    searchExpression.setLeftOperand(Attributes.CREATE_DATE);
    searchExpression.setOperator(FdkConstants.OPERATOR_EQUALS);
    searchExpression.setRightOperand( /* Here You specify the date you want to search - with type of DATE; e.g. DateTime.Today in C#... */ );

    And so on...
    I hope that helps You!

    Tamas
  • 9. Re: Search in Content DB
    654954 Newbie
    Currently Being Moderated
    Excuse me,
    "true" means Boolean.TRUE and
    "false" means Boolean.FALSE...

    Tamas
  • 10. Re: Search in Content DB
    655069 Newbie
    Currently Being Moderated
    Hi Tamas,

    Thanks for your help !

    Your code is very helpful.

    Orchloeve