This discussion is archived
2 Replies Latest reply: May 11, 2010 3:37 PM by frank.closheim RSS

Search using Content DB  API"s

694620 Newbie
Currently Being Moderated
Hi,

I am developing an application using Content DB API's. I am using SearchManager API to perform a search in my application. I have to develop a search expression using CDB API's that excludes the Trash Results in my Search results.

I am new to CDB. Please help me in solving this issue.

This is very urgent for me. Thanks in advance.

Thank You,
Ravi kumar
  • 1. Re: Search using Content DB  API"s
    694620 Newbie
    Currently Being Moderated
    Hi,
    I am trying to build a search expression that should return the files last modified since specified date and exclude the files from Trash.

    //Expression to retrieve files since the specified date
    firstexpr = new SearchExpression();
    firstexpr.setLeftOperand(Attributes.LAST_MODIFIED_DATE);
    firstexpr.setOperator(FdkConstants.OPERATOR_GREATER_THAN_EQUAL);
    firstexpr.setRightOperand(dt);

    //Expression to exclude files from Trash.
    secexpr = new SearchExpression();
    secexpr.setLeftOperand(Attributes.IS_IN_TRASH);
    secexpr.setOperator(FdkConstants.OPERATOR_EQUAL);
    secexpr.setRightOperand(false);

    //Expression to combine above two expressions.
    thirdexpr = new SearchExpression();
    thirdexpr.setLeftOperand(firstexpr);
    thirdexpr.setOperator(FdkConstants.OPERATOR_AND);
    thirdexpr.setRightOperand(secexpr);

    when i run my application i am getting the Error saying Invalid Search expression.
  • 2. Re: Search using Content DB  API"s
    frank.closheim Newbie
    Currently Being Moderated
    Hi,

    the javadoc for SearchExpression does not list Attributes.IS_IN_TRASH as an allowed attribute to search for, hence the error.

    There is no specific search option to prevent items being returned from trash.

    Possible workarounds are to restrict search to a particular set of folders within a Library, or perform post processing (most likely option).

    Post processing:
    Depending on how many results the search is likely to return, you could either request up front (as part of the AttributeRequest[] in SearchManager.search() )the Attributes.IS_IN_TRASH option for the full set of search results (if result set likely to be small), or, perform this on demand for a page of results at a time (when dealing with a potentially unbounded result set which is unlikely to be viewed in total).

    Hope that helps.

    Frank

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points