Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

5823

May 24th, 2012 08:00

Get DQL from IDfQuery builder dfc interface

Hi All,

I am implementing search programmatically using IDfSearchService and hence I am not using SearchInfo here.

Here is a piece of code for reference:

IDfSearchService searchService = localclient.newSearchService(sessmgr, "sample");

IDfQueryManager qMgr = searchService.newQueryMgr();

IDfQueryBuilder qBuilder = qMgr.newQueryBuilder();
qBuilder.addLocationScope("sample", "/sample", true);
qBuilder.addResultAttribute("title");
qBuilder.addResultAttribute("object_name");
qBuilder.setObjectType("dm_document");
IDfExpressionSet expSet = qBuilder.getRootExpressionSet();
expSet.addSimpleAttrExpression("title", IDfValue.DF_STRING, IDfSimpleAttrExpression.SEARCH_OP_CONTAINS, false, false, "txtdoc");
IDfQueryProcessor qProc = searchService.newQueryProcessor(qBuilder, true);
try{
IDfResultsSet results = qProc.blockingSearch(0);
if(results.next()){
IDfResultEntry res = results.getResult();
System.out.println(res.getString("object_name"));

Can anyone suggest me how can I get the dql query being executed above?

Regards,
SG

152 Posts

May 31st, 2012 08:00

heres how you can get query from IDfQueryBuilder object:

com.documentum.fc.client.search.impl.execution.data.ServerQuery serverQueryObj = new ServerQuery((DfQueryDefinition) IDfQueryBuilder_Object, 0, IDfSessionManager_Object);

String dql = serverQueryObj.getQuery().getDocbaseQueryDescription( , IDfSessionManager_Object).getQueryStatement();

May 31st, 2012 07:00

Any idea to suggest on this?

May 31st, 2012 12:00

Thanks a lot Tejraj. It worked

Meanwhile I was looking for the solution and came across this api. It gives you complete history (query start time, end time, docbase name, dql etc.) about the processing of the query by IdfQueryProcessor interface.

queryProcessor.getQueryStatus().getHistory()

152 Posts

June 2nd, 2012 09:00

Thanks for the info (I was not aware of this one).

12 Posts

November 27th, 2014 08:00

Hi Tejraj -

which version of DFC it is  .

Its not working for me ... any thoughts .pls let me know

++++++++++ This is my code +++++++++

private IDfQueryBuilder buildQuery(IDfSearchService m_searchService , IDfSessionManager sMgr ) throws DfException {

  IDfQueryBuilder queryBuilder = m_searchService.newQueryMgr().newQueryBuilder();

  queryBuilder.setObjectType("dm_document");

        String[] attrs = {"object_name", "r_creation_date", "title"};

        for (String attr : attrs)

        {

            queryBuilder.addResultAttribute(attr);

        }

        IDfExpressionSet rootExpressionSet = queryBuilder.getRootExpressionSet();

        rootExpressionSet.addFullText;

        IDfExpressionSet orExpressionSet = rootExpressionSet.addExpressionSet(IDfExpressionSet.LOGICAL_OP_OR);

        orExpressionSet.addSimpleAttr;

        orExpressionSet.addSimpleAttr;

      

        com.documentum.fc.client.search.impl.execution.data.ServerQuery serverQueryObj = new ServerQuery((DfQueryDefinition) queryBuilder, 0, sMgr);

        String dql = serverQueryObj.getQuery().getDocbaseQueryDescription(" ", sMgr).getQueryStatement(); /// I get the exception at this line.

        System.out.println(" dql fom Query service "+dql);

        return queryBuilder;

  }

+++++++++++++++++++++++++++++++++++++++++++++++++

I get the below exception

DfSearchException:: THREAD: main; MSG: No max result parameter available; ERRORCODE: ff; NEXT: null

  at com.documentum.fc.client.search.impl.generation.docbase.xquery.XQueryGenerator.appendReturnConstruct(XQueryGenerator.java:253)

  at com.documentum.fc.client.search.impl.generation.docbase.xquery.XQueryGenerator.getQueryStatement(XQueryGenerator.java:85)

  at com.documentum.fc.client.search.impl.generation.docbase.DocbaseQueryGeneratorManager.createXQueryDescriptionExecutor(DocbaseQueryGeneratorManager.java:190)

  at com.documentum.fc.client.search.impl.generation.docbase.DocbaseQueryGeneratorManager.generateQueryExecutor(DocbaseQueryGeneratorManager.java:165)

  at com.documentum.fc.client.search.impl.generation.docbase.DocbaseQueryGeneratorManager.generateQueryExecutor(DocbaseQueryGeneratorManager.java:87)

  at com.documentum.fc.client.search.impl.generation.docbase.DocbaseQueryGeneratorManager.generateQueryExecutor(DocbaseQueryGeneratorManager.java:63)

  at com.documentum.fc.client.search.impl.generation.docbase.DocbaseQueryGeneratorManager.generateQueryExecutor(DocbaseQueryGeneratorManager.java:52)

  at com.documentum.fc.client.search.impl.definition.query.DfQueryDefinition.getDocbaseQueryDescription(DfQueryDefinition.java:132)

January 12th, 2015 21:00

Hi,

Please change the error line to:

String dql = DocbaseQueryGeneratorManager.generateQueryExecutor(serverQueryObj.getQuery(), " ", sMgr, 350, -1, -1).getQueryStatement();

Thanks,

Winston

4 Posts

May 19th, 2015 05:00

Hi guys,

I wanted to do the reverse. I mean if i am executing DQL via IDfQuery, it will get converted to XQuery automatically.

So can i get that XQuery ?

Thanks

May 19th, 2015 17:00

Hi,

If you set DatabaseSearchRequested to true, DFC will generate DQL instead of xQuery.

queryBuilder.setDatabaseSearchRequested(true);

You can also change configuration in dfc.properties to generate DQL.

Thanks,

Winston

4 Posts

May 19th, 2015 20:00

Thanks Winston for response.

But i think you didn't get my question. Using code i am executing dql via IdfQuery interface. What i want to get is XQUERY for the particular dql which i am executing.

May 19th, 2015 22:00

Hi,

DFC sends the DQL to another compoment Query Plugin and Query Plugin will translate the DQL into xQuery.

Query Plugin is running on the Content Server.

DFC doesn't know the xQuery translated by Query Plugin.

You can find the xQuery in dsearch.log of xPlore manually.

Thanks,

Winston


4 Posts

May 19th, 2015 23:00

Thanks Winston.

Will check it.

No Events found!

Top