Full text search including Tags (HABTM)

2009-08-06 Thread Mono

Hi!

I have Articles with Tags (HABTM-Relation)... Now I'm trying to create
a full text search and I need to be able to search through the Tags.

I have this and it works only for Article.title and Article.content:


$toSearch = Sanitize::escape ($this-params['url']['for']);

$options = array
(
'contain' = array ('Tag'),
'fields' = array
(
*, MATCH (Article.title, Article.content) 
AGAINST ('$toSearch' IN
BOOLEAN MODE) AS relevance
),
'conditions' = array
(
MATCH (Article.title, Article.content) AGAINST 
('$toSearch' IN
BOOLEAN MODE)
),
'order' = array (relevance DESC, Article.title ASC)
);

debug ($this-Article-find ('all', $options));
.

... but what I need, is something like this (see the 'Tag.name' into
the MATCH's - it doesn't work):

$options = array
(
'contain' = array ('Tag'),
'fields' = array
(
*, MATCH (Article.title, Article.content, 
Tag,name) AGAINST
('$toSearch' IN BOOLEAN MODE) AS relevance
),
'conditions' = array
(
MATCH (Article.title, Article.content, 
Tag.name) AGAINST
('$toSearch' IN BOOLEAN MODE)
),
'order' = array (relevance DESC, Article.title ASC)
);


I really would appreciate it if anyone could give me some hints.

Thanks a lot!
Claudio.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Article full text search including Tags (HABTM)

2009-08-06 Thread Mono

Hi!

I have Articles with Tags. The same Tags are used y many Articles
(HABTM-Relation)...
Now I'm trying to create a full text search and I need to be able to
search through the Article.title and Article.content, as well as
through the Tag.name.

At the moment I have this (it works only for Article.title and
Article.content):


$toSearch = Sanitize::escape ($this-params['url']['for']);

$options = array
(
'contain' = array ('Tag'),
'fields' = array
(
*, MATCH (Article.title, Article.content) 
AGAINST ('$toSearch' IN
BOOLEAN MODE) AS relevance
),
'conditions' = array
(
MATCH (Article.title, Article.content) AGAINST 
('$toSearch' IN
BOOLEAN MODE)
),
'order' = array (relevance DESC, Article.title ASC)
);

debug ($this-Article-find ('all', $options));
.

... but what I need, is something like this (see the 'Tag.name' into
the MATCH's - it doesn't work):

$options = array
(
'contain' = array ('Tag'),
'fields' = array
(
*, MATCH (Article.title, Article.content, 
Tag,name) AGAINST
('$toSearch' IN BOOLEAN MODE) AS relevance
),
'conditions' = array
(
MATCH (Article.title, Article.content, 
Tag.name) AGAINST
('$toSearch' IN BOOLEAN MODE)
),
'order' = array (relevance DESC, Article.title ASC)
);


I really would appreciate it if anyone could give me some hints.

Thanks a lot!
Claudio.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---