Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » FullTextSearchable does not work on custom fields

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

Page: 1 2
Go to End
Author Topic: 1791 Views
  • Juanitou
    Avatar
    Community Member
    323 Posts

    FullTextSearchable does not work on custom fields Link to this post

    Hi!

    I’m getting crazy: in the FulltextSearchable class, it’s clearly stated that we can use…

    FulltextSearchable::enable();
    Object::add_extension('HomePage',"FulltextSearchable('HomeCol1,HomeCol2')");

    …for something as simple as adding two custom fields of a custom page extending the Page class (here, from the common Simplestripe theme).

    But the index for those fields is never being added to the data base, as the only classes allowed are SiteTree and File.

    Does it means that the documentation of the FulltextSearchable class is wrong and the whole functionality is half-baked? Should I implement a custom search for extended pages?

    Thanks in advance,
    Juan

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    So Object::add_extension('HomePage',"FulltextSearchable('HomeCol1,HomeCol2')"); isn't adding the indexes? You should still be able to add the decorator manually. Fulltextsearchable::enable() is restricted to SiteTree and file but I don't think that limits the use of the extension on other records.

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    Hi Will!

    No, no indexes, that’s why I’m asking here: it seems that there is an error somewhere on the FullTextSearchable code… but I have not been able to debug it. I really need to extend the Search to custom fields for a current project, I don’t know what else to do, bu well I’ll keep trying!

  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    I am having the extact same problem. But i might add this.

    In that line below, where Nom, Prenom eand Entreprise are custom textFields

    Object::add_extension('MyObject', "FulltextSearchable('Nom','Prenom', 'Entreprise')");

    What is 'MyObject' refers to?

    I tried Page, no change.
    I tried HomePage, error.
    I tried MemberPage (name of the page where customs fields ae added), no change i.e. no results found from customs textFields..

    Thanks!

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    Hi!

    I finished using this old hack:
    http://www.silverstripe.org/all-other-modules/show/6641?start=24#post290089

    It works, at least here.

    Hope it helps,
    Juan

  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    Hi Juanito, funny i learned that i am gonna spend a month in France next summer: either Montpellier or Les Herbiers. Long way from Canada!

    - - -

    Back to the thread: on the link you provided, do i start from page 1 or solution is a the section/page you highligted?

    Better, give me a hint on how to solve this?

    Thanks!

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    Hi!

    I wish you a nice séjour in France.

    I used the solution posted by Aram. Get the ZIP file, install the module custom_search and use the example provided in a folder sibling folder to understand how does it work. Don’t forget to provide your DataObjects with Link, Title and canView functions, or you’ll see nothing in the search results.

    A side note: This didn’t worked for me with a has_many object, I couldn’t get Links and Titles for it in the search results, so I had to change it to a many_many. I don’t know if there is a problem with the code or, more probably, if I overlooked something in my code. I’m not a good programmer.

    Hope it helps,
    Juan

  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: FullTextSearchable does not work on custom fields Link to this post

    Bonjour Juan, je ferai de mon mieux!

    - - -

    Ill try custom_search. But ive read on another posts that one could possibly have SS search thru customs textfields by populating $Metatags and $Description with its content. As those later two are looked over by the standard search engine, it supposely works.

    Back to my AS3 days, it would like this.

    var $Metatags.text = $Nom.text + $Prenom.text + $Entreprise.text

    where the later three are my custom textfields.

    Any idea?

    Thanks!

    1791 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.