How to create index with virtual fields using Texis Direct API?
Texis Direct API
Texis Direct API
The same way you create any other index. Just put the backslash between the fields (\).
Texis Direct API
I have trouble using the createindex() API to create a Metamorph index table after creating the content table.
This code fragment:
char ftbname[1024];
char *tbname="product"; /* content table name */
char findname[1024];
char *indname="prodbod"; /* index table name */
char *fldname = "Title\\LongDesc"; /* virtual field */
dic = ddopen(qp->files);
if(dic!=(DDIC *)NULL && permstexis(dic,qp->user,"")!=-1)
{
strcpy(ftbname, tbname);
dd = opendd();
if ((dd == DDPN ||
!putdd(dd, "id", "counter", 1, 1) ||
!putdd(dd, "Title", "varchar", 300, 1) ||
!putdd(dd, "LongDesc", "varchar", 10000, 1) ||
(tb = createdbtbl(dic, dd, ftbname, tbname, "Index database.", 'T')) == (DBTBL *)NULL))
{
... /* error handler */
}
else
{
strcpy(findname, indname);
if(createindex(dic,findname,indname,tbname,fldname,1,'3')==-1)
{
... /* error handler */
}
}
}
It produces "Access Violation" error at createindex() API call.
This code fragment:
char ftbname[1024];
char *tbname="product"; /* content table name */
char findname[1024];
char *indname="prodbod"; /* index table name */
char *fldname = "Title\\LongDesc"; /* virtual field */
dic = ddopen(qp->files);
if(dic!=(DDIC *)NULL && permstexis(dic,qp->user,"")!=-1)
{
strcpy(ftbname, tbname);
dd = opendd();
if ((dd == DDPN ||
!putdd(dd, "id", "counter", 1, 1) ||
!putdd(dd, "Title", "varchar", 300, 1) ||
!putdd(dd, "LongDesc", "varchar", 10000, 1) ||
(tb = createdbtbl(dic, dd, ftbname, tbname, "Index database.", 'T')) == (DBTBL *)NULL))
{
... /* error handler */
}
else
{
strcpy(findname, indname);
if(createindex(dic,findname,indname,tbname,fldname,1,'3')==-1)
{
... /* error handler */
}
}
}
It produces "Access Violation" error at createindex() API call.
Texis Direct API
In general if you are doing things that can be accomplished with SQL it is easier to use one of the SQL level APIs, and compile with NCGDIRECT. You could use the n_texis call to issue the SQL directly.
If you are using the API you have above there are defines for the various index types that you might find more useful than the '3' which is the old style Metamorph index that is no longer supported.
INDEX_FULL: same as CREATE METAMORPH INVERTED INDEX
INDEX_MM: same as CREATE METAMORPH INDEX
INDEX_BTREE: same as CREATE INDEX
INDEX_UNIQUE: same as CREATE UNIQUE INDEX
INDEX_INV: same as CREATE INVERTED INDEX
If you are using the API you have above there are defines for the various index types that you might find more useful than the '3' which is the old style Metamorph index that is no longer supported.
INDEX_FULL: same as CREATE METAMORPH INVERTED INDEX
INDEX_MM: same as CREATE METAMORPH INDEX
INDEX_BTREE: same as CREATE INDEX
INDEX_UNIQUE: same as CREATE UNIQUE INDEX
INDEX_INV: same as CREATE INVERTED INDEX
John Turnbull
Thunderstone Software
Thunderstone Software
Texis Direct API
Hi,
Thanks for your help. I replaced '3' (INDEX_3DB) with INDEX_FULL and INDEX_MM, and got the same "Access Violation" error. The INDEX_BTREE and INDEX_UNIQUE worked fine but they are not for Metamorph index. Is there another way I could use createindex() to build Metamorph index instead of using n_texis?
Thanks for your help. I replaced '3' (INDEX_3DB) with INDEX_FULL and INDEX_MM, and got the same "Access Violation" error. The INDEX_BTREE and INDEX_UNIQUE worked fine but they are not for Metamorph index. Is there another way I could use createindex() to build Metamorph index instead of using n_texis?
Texis Direct API
Yes. It seems that the APICP that is used to determine the noise list is not initialized before you call createindex. You should add the following code before you call createindex().
extern APICP *globalcp;
if(globalcp == (APICP *)NULL) globalcp = TXopenapicp();
extern APICP *globalcp;
if(globalcp == (APICP *)NULL) globalcp = TXopenapicp();
John Turnbull
Thunderstone Software
Thunderstone Software