Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

FulltextSearch module


Go to End
Reply

12 Posts   1326 Views

Avatar
Sphere

25 January 2012 at 9:50am Community Member, 44 Posts

I just pushed my FulltextSearchable search-module to github.
https://github.com/Firesphere/silverstripe-searcher

Let me know if you run into any problems or have questions.

Avatar
michito

31 January 2012 at 8:42am Community Member, 4 Posts

Hi Sphere, thanks for sharing this module with us.

I installed it and it works fine. At the moment I just have one problem with searching DataObjects. They are found and displayed. The only thing that does not work ist the $Link, which is empty. Any ideas on that?

BTW: I am not using URLSegments, is that necessary?

Avatar
Juanitou

1 February 2012 at 3:34am Community Member, 323 Posts

Hi!

First, I’d like to thank Sphere for the module. I’ve not had an opportunity to test it, but it seems a worthy effort!

@Michito: DataObjects do not have Link() methods, you need to create them. I suggest you to follow this tutorial:
http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/

Best regards,
Juan

Avatar
michito

1 February 2012 at 4:38am Community Member, 4 Posts

Thanks Juanitou! Took the Link-function from the Tutorial and made it work for my DataObjects. Running perfect now.

Avatar
michito

1 February 2012 at 6:22am Community Member, 4 Posts

I got one more: How can I exclude Images from being searched (or shown in search results)?

Avatar
Pipifix

14 February 2012 at 4:33am (Last edited: 15 February 2012 12:31am), Community Member, 54 Posts

Hello.

According to my question, Juanito points me here. I wanna give the silverstripe-searcher module a try. So i downloaded it from github (repo5147578). did the usually things to get a module installed. Created a SearchResultPage in Backend and edited my _config to

//Enable Search, use $SearchForm in template
FulltextSearchable::enable();
DataObject::add_extension('DownloadPage', "FulltextSearchable('TabOneContent,TabTwoContent,TabThreeContent')");
DataObject::add_extension('Projekt',"FulltextSearchable('Title,Description')");
//DataObject::add_extension('AkteursPortrait',"FulltextSearchable('Name,Description')"); //Obviously a Title instead a Name is needed

..and got a sql error

518    function databaseError($msg, $errorLevel = E_USER_ERROR) {
519       // try to extract and format query
520       if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
521          $formatter = new SQLFormatter();
522          $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
523       }
524       
525       user_error($msg, $errorLevel);
526    }
527    
528    /**
529     * Return a boolean type-formatted string
530     *
531     * @param array $values Contains a tokenised list of info about this data type

-----------------------------------------------------------------------

[User Error] Couldn't run query: SELECT ClassName, "SiteTree_Live".ID, ParentID, Title, MenuTitle, URLSegment, Content, LastEdited, Created, _utf8'' AS Filename, _utf8'' AS Name, MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) AGAINST ('kontakt') + MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) AGAINST ('kontakt') AS Relevance, CanViewType FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) AGAINST ('kontakt*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) AGAINST ('kontakt*' IN BOOLEAN MODE) AND ShowInSearch 0) UNION SELECT ClassName, "File".ID, _utf8'' AS ParentID, Title, _utf8'' AS MenuTitle, _utf8'' AS URLSegment, Content, LastEdited, Created, Filename, Name, MATCH (Filename, Title, Content) AGAINST ('kontakt') AS Relevance, NULL AS CanViewType FROM "File" WHERE (MATCH (Filename, Title, Content) AGAINST ('kontakt*' IN BOOLEAN MODE) AND ClassName = 'File' AND ShowInSearch 0) ORDER BY "Relevance" DESC LIMIT 0, 3 Can't find FULLTEXT index matching the column list

Did i miss something? Whats wrong?

I use SS2.4.6 and Arams "Highlighting Query Text in Search Results" Tutorial.

Thanks for your help. Pipifix

Avatar
Pipifix

17 February 2012 at 4:37am Community Member, 54 Posts

bump ^^

Avatar
Sphere

6 August 2012 at 10:30am (Last edited: 6 August 2012 11:28am), Community Member, 44 Posts

Sorry, I've been away for a while, and also, I stupidly forgot to answer.

Michito:
The URLSegment-part is used to generate the link. To get the link, your DataObject needs to have the $this->Link() function.

Here's what I use:
   public function Link() {
      if ($Page = DataObject::get_one('SiteTree', "`ClassName` = '{ParentPageHere}'")) {
         return($Page->Link('{YourHandlerInThePage}').'/'.$this->URLSegment));
      }
   }

I know this is quite an old version, a modernized version should work too, but you do need to have a URLSegment. Offcourse, you can name it differently, or use the ID, that's up to you to program in your DO.

The exclude-feature is on the to-do list. The default "enable fulltextsearch" also includes files, which by default includes images.

Hello Pipifix, your problem lies in the error:
Can't find FULLTEXT index matching the column list
The problem here is, appearantly, the column-list generated is not the same as the column-list in MySQL.

If your MySQL structure is, for example:
"ID - Date - Title - Content"
But your FullText is:
"ID - Content - Title"

MySQL starts screaming.

Please check the sequence in which the fields are in the searchable-database created by the searcher, and see if they match the DO's table.

If you can confirm this is indeed the issue, please e-mail me with the details. I will take a look at it to fix it, or submit a patch ;)
Currently, I'm, with this module, busy updating to SS3.

I'm very sorry for not responding asap on this forum, I forgot to subscribe to the topic. My bad!

Go to Top