php - Any way to combine results from fulltext query -


i've got fulltext mysql query works -- except fact end duplicate results in cases. i've got several types of data i'm trying search: buildings, suites, assets, etc., each in own table. each type of data can have user-defined custom fields, data stored in different table. here structure.

create table `buildings` (  `bid` int(11) not null auto_increment,  `name` varchar(250) collate utf8_unicode_ci not null,  `status` enum('active','inactive') collate utf8_unicode_ci not null,  `source` enum('feed','manual') collate utf8_unicode_ci not null,  primary key (`bid`),  fulltext key `textsearch` (`name`) )  create table `customfields` (  `cfid` int(11) not null auto_increment,  `name` varchar(250) collate utf8_unicode_ci not null,  `datatype` enum('integer','date','smtext','lgtext','numeric','enum','linked') collate utf8_unicode_ci not null,  `options` longtext collate utf8_unicode_ci,  `did` int(11) not null comment 'datasheet id',  primary key (`cfid`),  key `did` (`did`) )  create table `customfield_data` (  `cfdid` int(11) not null auto_increment,  `data_int` int(11) default null,  `data_date` datetime default null,  `data_smtext` varchar(1000) collate utf8_unicode_ci default null,  `data_lgtext` longtext collate utf8_unicode_ci,  `data_numeric` decimal(20,2) default null,  `linkid` int(11) default null comment 'id value of specific item',  `cfid` int(11) not null comment 'custom field id',  primary key (`cfdid`),  key `data_smtext` (`data_smtext`(333)),  key `linkid` (`linkid`),  key `cfid` (`cfid`),  fulltext key `textsearch` (`data_smtext`,`data_lgtext`) ) 

so effectively, building can have customfield stores actual data in customfield_data. customfield identified building-specific field means of did (dataset id.) cfid field links customfield_data customfield , data linked specific building linkid field.

with in mind, here's fulltext query:

select * (   select (data_smtext + data_lgtext) data, linkid idvalue, did, match(data_smtext, data_lgtext) against (?) relevance   customfield_data   join customfields on customfield_data.cfid = customfields.cfid   match (data_smtext, data_lgtext) against (? in boolean mode)   union   select name data, bid idvalue, 2 did, 3 * (match(name) against (?)) relevance   buildings   status = ? , match (name) against (? in boolean mode)   union   select name data, bid idvalue, 2 did, 100 relevance   buildings   bid ? , status = ?   union   ) searchresults relevance > 0 order relevance desc 

as mentioned earlier, works alright. problem i'm running if, example, building named 123 north ave tower , has address (customfield) of 123 north ave, duplicate records -- 1 name , 1 address if search "123 north ave".

they're both pointing same did (dataset id) , linkid (building id, in case), know solve problem cycling through resulting array in php, looking matches, , throwing out duplicates. hand me performance hit , lower effectiveness of relevance scoring. ideally, i'd able have query add relevance of address match of name/id match give me more accurate score. right i'm multiplying name match 3x , leaving customfield match @ 1x in order weight more accurate matches more heavily adding 2 best option.

thanks can point me in right direction!

i have no solution specific problem, solved installing , configuring sphinx , letting dirty work.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -