I have a table called indx_0 where I select all “pid” (product id) cominations with “wid” (word id) grouping them by products that match the most words. Now, since the actual words are stored within a different table called “windex” the table indx_0 only contains product ID matched with the ID of the word.
Here is the current query I use to get the results.
SELECT pid, count(*) WordMatchCount
FROM indx_0
WHERE wid in ( 294, 20591, 330 )
group by pid
order by WordMatchCount desc
limit 1000
Say I search for “ddr memory card” I will NOT get the result that contains “ddr3” prioritized over any other keyword since it searches for exact match. so “ddr memory card” and “phone memory card” would be treated as equal since neither “ddr3” nor “phone” equals to ddr.
I want to use join and LIKE (or any other preferable way) to allow “ddr” match against “ddr3” or “ddr2” very closely to prioritize it over other results where there is no close match.
Here are table structures:
CREATE TABLE IF NOT EXISTS `windex` (
`word` varchar(64) NOT NULL,
`wid` int(10) NOT NULL AUTO_INCREMENT
PRIMARY KEY (`wid`),
UNIQUE KEY `word` (`word`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=834922 ;
CREATE TABLE IF NOT EXISTS `indx_0` (
`wid` int(7) NOT NULL,
`pid` int(7) NOT NULL,
UNIQUE KEY `wid` (`wid`,`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Is this possible?
thank you!
If you’re filtering by word id, you’re obviously not getting close matches. Every ID has a specific word. What you want is to query the IDs directly from
windexand looking for the matches inindx_0.I’d make sure to run
EXPLAINand index the appropriate columns, though.