Hi all

 

I'm having problems with using the FTS NEAR/n operator and I'm really not
sure why.

 

Code below, any help gratefully received, the 'product NEAR announcement'
produces a hit but 'product NEAR/20 announcement ' doesn't.  Using 3.6.2

 

Thanks in advance

 

Mike

 

 

sqlite3* pHandle;

                

                sqlite3_open(":memory:",&pHandle);

 

 

                char* acErrorMsg;

                int nError;

                char* acSQL = sqlite3_mprintf("CREATE virtual TABLE
fulltext_test USING fts3 (contents)");

                nError = sqlite3_exec(pHandle,acSQL,NULL,NULL,&acErrorMsg);

                sqlite3_free(acSQL);

                sqlite3_free(acErrorMsg);

 

                char* acText = "This is the text,product should be within a
few words of announcement.  We'll just see if it works shall we!";

                acSQL = sqlite3_mprintf("INSERT INTO fulltext_test
(contents) VALUES ('%q')",acText);

                nError = sqlite3_exec(pHandle,acSQL,NULL,NULL,&acErrorMsg);

                sqlite3_free(acSQL);

                sqlite3_free(acErrorMsg);

 

                char* acQuery = sqlite3_mprintf("SELECT * FROM fulltext_test
WHERE contents MATCH 'product NEAR announcement'");

                sqlite3_stmt* pStatement;

                nError =
sqlite3_prepare_v2(pHandle,acQuery,-1,&pStatement,NULL);              

                if (sqlite3_step(pStatement) == SQLITE_ROW)

                {

                                printf("Hit\n");

                }

                sqlite3_finalize(pStatement);

                sqlite3_free(acQuery);

 

                acQuery = sqlite3_mprintf("SELECT * FROM fulltext_test WHERE
contents MATCH 'product NEAR/20 announcement'");

                nError =
sqlite3_prepare_v2(pHandle,acQuery,-1,&pStatement,NULL);              

                if (sqlite3_step(pStatement) == SQLITE_ROW)

                {

                                printf("Hit\n");

                }

                sqlite3_finalize(pStatement);

                sqlite3_free(acQuery);

 

 

                sqlite3_close(pHandle); 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to