Sun Java System Portal Server 7.2 Developer's Guide

RDMHeader and RDMQuery Object Parameters

The list of RDMHeader and RDMQuery object parameters and their description are:

MY_CSID

ID of the search engine instance. This parameter specifies the specific search engine that you created in the search engine Administration Interface. You can find the exact value in /var/opt/SUNWportal/searchservers/search1/config/search.conf. For SSL enabled server instances, use x-catalogs instead of x-catalog in the CSID.

MY_SCOPE

Query string. The default is to search for documents containing the string varrius. For example, if you want to search for all documents containing the string style_sheets, then set MY_SCOPE to style_sheets.

MY_ATTR_VIEW

Attributes to be printed, such as URL, title and description.


Example 28–1 RDM API to Submit a Query Example

This example generates an RDM for querying a search engine database. You can pipe the output of the sample program to a temporary file and then use the sendrdm program to post it to the search engine.


/******* Example Use of the RDM API to submit a query *******/

#include <stdio.h>
#include “Search.h”
#include “rdm.h”

#define MY_SCOPE “varrius”
#define MY_CSID “x-catalog://budgie.siroe.com:6714/search1”
#define MY_ATTR_VIEW “title,content-type”

int main(int argc, char *argv)
{
    RDMQuery *myquery = NULL;
    CSID *csid = NULL;
    RDMHeader *myheader = NULL;
    SearchStream *out = Search_PrintInitFile(stdout);

    /* Create the RDMQuery and specify its scope */
    if(!(myquery = RDMQuery_Create(MY_SCOPE))) {
        perror(“RDMQuery_Create\\n”);
        exit(-1);
    }

    /* Set the view attributes of the RDMQuery */
    RDMQuery_SetViewAttr(myquery, MY_ATTR_VIEW);

    /* Create the CSID that points to your search engine instance */
    if(!(csid = CSID_Parse(MY_CSID))) {
        perror(“CSID_Parse\\n”);
        exit(-1);
    }

    /* Create the RDMHeader */
    if(!(myheader = RDMHeader_CreateRequest(RDM_RD_REQ, “search”,
    csid))) {
        perror(“RDMHeader_CreateRequest\\n”);
        exit(-1);
    }

    /* print the RDMHeader to the output Search stream */
    /* print the RDMQuery to the output Search stream */
    (*out->print)(out, myheader->search);
    (*out->print)(out, myquery->search);

    /* free the structures and exit */
    RDMHeader_Free(myheader);

    RDMQuery_Free(myquery);
    SearchStream_Finish(out);
    exit(0);
}
/*********** EOF ****************/