内に含まその他のドキュメントサポート リソース | PDF 文書ファイルをダウンロードする (1107 KB)
Chapter 24 Example of Submitting a QueryThis chapter contains the following sections: Overview of Submitting a QueryTo send the RDMHeader and RDMQuery objects to the search engine to perform a query request, you can use the pre-built sendrdm program (located in PortalServer-base/lib directory). This program takes an RDM request (which is a message in SOIF format), sends it to the search engine, and outputs the results as a SOIF stream. You can also use HTTP to post an RDM stream directly to the server through its URL http://server:port/search-ID/search). The program must be run in a search-enabled Sun Java System Portal Server software instance directory such as the default PortalServer-DataDir/searchservers/search1/ directory. You should also change the definitions for MY_CSID, MY_SCOPE and MY_ATTR_VIEW to suit your needs. RDMHeader and RDMQuery Object ParametersThe following table describes the RDMHeader and RDMQuery object parameters in the first (left) column and provides a description of the corresponding parameter in the second (right) column
Example 24–1 RDM API to Submit a Query ExampleThis 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.
Running the ExampleTo run the example described in Example 24–1, follow these steps.
|
# Makefile for SOIF/RDM SDK examples
# Use make and cc.
CC = cc
SDKDIR = ..
SDKLIB = $(SDKDIR)/lib/librdm.a
SDKINC = $(SDKDIR)/include/
CFLAGS = -I$(SDKINC) -DXP_UNIX
CFLAGS += -DSOLARIS
#CFLAGS += -DIRIX
#CFLAGS += -DHPUX
#CFLAGS += -DAIX
EXAMPLES = example1 example2 example3
example4
all: $(EXAMPLES)
example1:example1.o
$(CC) -o $@ $@.o $(SDKLIB)
example2:example2.o
$(CC) -o $@ $@.o $(SDKLIB)
example3:example3.o
$(CC) -o $@ $@.o $(SDKLIB)
example4:example4.o
$(CC) -o $@ $@.o $(SDKLIB)
|
From the PortalServer-base/sdk/rdm/examples directory, build the example as follows:
Solaris:gmake |
From the PortalServer-base/sdk/rdm/examples directory, run the example4.c program to generate the RDM file.
example4.c > rdm.soif |
The file rdm.soif will look like the following example:
@RDMHEADER { -
catalog-service-id{40}:x-catalog://budgie.siroe.com:6714/budgie
rdm-version{3}: 1.0
rdm-type{10}: rd-request
rdm-query-language{6}: search
}
@RDMQUERY { -
view-attributes{18}: title,content-type
scope{5}: varrius
}
|
The file rdm.soif created in must be placed into the server instance directory.
Send the SOIF contained in rdm.soif to the program sendrdm. For example, type:
./run-cs-cli sendrdm -u /portal/search rdm.soif |
The current directory should be the server instance directory. If rdm.soif is not in the server instance directory, reference the file from where is was created. For example:
Change directories to server_instace_dir.
Type ./run-cs-cli sendrdm -u /portal/search sdk_dir/rdm.soif.
The results of the sendrdm program will be a SOIF stream containing the results of the query, such as the following example:
@RDMHEADER { - catalog-service-id{41}:x-catalog://budgie.siroe.com:6714/budgie rdm-version{3}: 1.0 rdm-type{11}: rd-response rdm-response-interpret{51}:20 results out of 36281 hits across 88985 documents } @DOCUMENT { http://fury.sesta.com:999/it/newsref/pr/newsrelease417.html content-type{9}: text/html score{3}: 100 title{17}: Comunicato stampa } @DOCUMENT { http://fury.sesta.com:999/it/newsref/pr/newsrelease374.html content-type{9}: text/html score{3}: 100 title{17}: Comunicato stampa }
|
You can pipe the output of sendrdm (which is a SOIFStream) to another program to print the results of the query.