Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » FulltextSearch module

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 1081 Views
  • Sphere
    Avatar
    Community Member
    44 Posts

    FulltextSearch module Link to this post

    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.

  • michito
    Avatar
    Community Member
    4 Posts

    Re: FulltextSearch module Link to this post

    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?

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: FulltextSearch module Link to this post

    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

  • michito
    Avatar
    Community Member
    4 Posts

    Re: FulltextSearch module Link to this post

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

  • michito
    Avatar
    Community Member
    4 Posts

    Re: FulltextSearch module Link to this post

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

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: FulltextSearch module Link to this post

    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

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: FulltextSearch module Link to this post

    bump ^^

  • Sphere
    Avatar
    Community Member
    44 Posts

    Re: FulltextSearch module Link to this post

    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!

    1081 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.