Jump to content

Parameterized FullText Proximity Search


dave1950
Go to solution Solved by Barand,

Recommended Posts

I have a MySql database (Server Version 5.6.12) with a fulltext index on the SectionText field in the FD table with this structure:

CREATE TABLE `FD` (

  `FTS_DOC_ID` bigint(20) unsigned NOT NULL,

  `ReadingNo` int(11) DEFAULT NULL,

  `SequenceNo` int(11) DEFAULT NULL,

  `SectionTypeID` int(11) DEFAULT NULL,

  `SectionText` longtext,

  `FullDocNo` varchar(11) CHARACTER SET utf8 NOT NULL,

  `DocType` varchar(11) CHARACTER SET utf8 DEFAULT NULL,

  UNIQUE KEY `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I am able to do a very accurate fulltext proximity search (92 documents found) in PHPMyAdmin using this syntax:

SELECT SectionText

FROM fd

WHERE DocType = "text" AND

MATCH (SectionText) AGAINST ('"liver hepatic" @3' IN BOOLEAN MODE)

ORDER BY FTS_DOC_ID

But when I try to use this query on a webpage I get this error message:

 

Parse error: syntax error, unexpected 'liver' (T_STRING) in C:\wamp\www\ecr\proximity.php on line 77

 

When I remove the quotes like this:

MATCH (SectionText) AGAINST ('liver hepatic @3' IN BOOLEAN MODE)

There is no error, but there are no documents found.

 

Realistically, to do searches on the web, I need to use search variables provided via an input form (and preferably a parameterized query) such as:

MATCH (SectionText) AGAINST (':search1 :search2 @:proximity' IN BOOLEAN MODE)

But this also returns no documents found.

 

I need help getting this implemented on a web page.  If this needs to be posted in another forum (PHP), please advise.  But since the proximity search feature seems to be relatively new and somewhat obscure (couldn’t find anything about implementing it on a webpage via Google), I thought it best to start here.  Any help in solving this is greatly appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.