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.

Customising the CMS /

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

Search custom fields


Go to End


7 Posts   3160 Views

Avatar
inCharge

Community Member, 102 Posts

21 October 2010 at 10:30am

Edited: 21/10/2010 10:33am

What I like most about SilverStripe is that it's easy to create templates with more than one content field, and for the site owner to edit that content.

If your page has custom fields on it the search currently cannot handle searching these. It will only search the default title, content fields
http://www.silverstripe.org/archive/show/196669#post196669

How can the site search find the content of custom fields? This is surely something most SilverStripe developers need to implement at some point?

things like the forum have got there own custom search forms with their own querying engines.
http://www.silverstripe.org/form-questions/show/256689

I looked at the forum search, then had to lie down. It'll take days to unravel that lot. I'd be most grateful if someone could post an example, or link to a recipe.

Thanks,
Jules

Avatar
Willr

Forum Moderator, 5523 Posts

21 October 2010 at 8:06pm

If you can set up sphinx search. It's designed to be extended much more and has a bunch of nice features (like searching custom fields and file content)

http://silverstripe.org/sphinx-module

Avatar
Carbon Crayon

Community Member, 598 Posts

24 October 2010 at 12:43pm

I used a *hack* on a site recently that amalgamated the contents of my custom fields and stuck them in the MetaDescription field onBeforeWrite, which is searched by the default search.

I then created a custom db field to hold the actual meta description and replaced the field under the metadata tab with my own, as well a overriding the MetaTags fucntion to use my replacment field in it's return value.

I know this is a bit of a dirty hack, but if it's quick implentation you are after then it works well with very little overhead.

Aram

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

www.ssbits.com - Your one stop SilverStripe learning resource

Avatar
swaiba

Forum Moderator, 1899 Posts

26 October 2010 at 12:05am

I've got a basic recipe that I've posted in this thread, hope it helps...

http://www.silverstripe.org/customising-the-cms/show/288544#post288544

Avatar
inCharge

Community Member, 102 Posts

27 October 2010 at 1:10am

Thanks guys. That gives me 3 options

1 - Sphinx
2 - Concatonate searchable fields into MetaDescription
3 - Custom search

I'd call 2 a 'quick fix' rather than a 'dirty hack'. It's probably more efficient than 3 because only one field is searched. You'd probably want to use an XML parser to strip the HTML tags out of the searchable content though.

If I was going to do one SilverStripe site then move on, I'd use 2. If I used shared hosting so couldn't install Sphinx then I'd use 3. But Sphinx has to be the way to go.

Avatar
swaiba

Forum Moderator, 1899 Posts

27 October 2010 at 2:00am

I have been wanting to get round to sphinx module for some time, please let us know how you get on. I'd like to upgrade all my search so that it includes search pdfs and dynamically created pages... so as I say I'd be very interested in your results...

Avatar
inCharge

Community Member, 102 Posts

27 October 2010 at 10:45am

Edited: 27/10/2010 10:48am

> please let us know how you get on
Sure, will do, when I get around to setting it up :)

The other bespoke CMS I work with uses Xapian, which is very fast + flexible + scalable and doesn't require a separate daemon. So it'll be interesting to see how Sphinx compares.