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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

FullTextSearchable does not work on custom fields


Go to End


12 Posts   4633 Views

Avatar
Juanitou

Community Member, 323 Posts

14 November 2011 at 12:55pm

Edited: 14/11/2011 12:55pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

25 November 2011 at 9:54pm

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.

Avatar
Juanitou

Community Member, 323 Posts

29 November 2011 at 3:37am

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!

Avatar
wilsonStaff

Community Member, 143 Posts

10 January 2012 at 8:56am

Edited: 10/01/2012 8:57am

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!

Avatar
Juanitou

Community Member, 323 Posts

10 January 2012 at 1:33pm

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

Avatar
wilsonStaff

Community Member, 143 Posts

10 January 2012 at 1:54pm

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!

Avatar
Juanitou

Community Member, 323 Posts

10 January 2012 at 9:44pm

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

Avatar
wilsonStaff

Community Member, 143 Posts

11 January 2012 at 12:31am

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!

Go to Top