Sherlock is back!
If you remember back in the day when Apple was touting Sherlock indexing for webpages, this is for you. You can now do this with Spotlight, which should yield a more consistent experience.1.Prepare Mac OS X Server for Spotlight
- By default on OS X Server, Spotlight is off. To activate spotlight, modify /etc/hostconfig:
SPOTLIGHT=-YES-
- Then, start the metadata service
sudo SystemStarter start "MetaData Search"
- Verify that indexing is on for your Volume. You can use the ‘mdutil’ command:
usage: mdutil -pE volume ... mdutil can be used to manage the metadata stores used by Spotlight. -p publish metadata for the provided volumes. -i (on|off) set indexing status for the provided volumes. -E erase the master copy of the metadata stores for the provided volumes. -s print indexing status for the provided volumes. mdutil -s /Volumes/Data # show the status for volume : /Volumes/Data /Volumes/Data: Status: Indexing Disabled mdutil -i on /Volumes/Data # activate indexing for the volume : /Volumes/Data /Volumes/Data: Indexing enabled for volume. mdutil -p /Volumes/Data # publish index for the volume : /Volumes/Data /Volumes/Data: Index published Server is now ready for using spotlight
2. Prepare Apache for using Spotlight
- Check the Apache configuration for Spotlight. You can activate spotlight module with Server Admin ( in the web /modules tab) or modify /etc/httpd/httpd.conf, by uncommenting the lines :
LoadModule apple_spotlight_module libexec/httpd/mod_spotlight_apple.so
AddModule mod_spotlight_apple.c
- Restart Apache with apachectl graceful or Server Admin
-
Copy the file ‘/Library/WebServer/Documents/template.spotlight’ in the root directory of your website
-
You can search using spotlight on your website, by adding .spotlight to the end of the url
www.mydomaine.com/.spotlight
www.mydomaine.com/fr/xserve.spotlight
- Obviously this is just a bare bones example, to really use this you would integrate the search field into your site’s html.
3. Integrating the search module directly in the webpage
- just add the HTML code to your page :
<code> </HEAD> <BODY BGCOLOR="#FFFFFF"> <CENTER> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=600> <TR> <TD> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD> <FORM ACTION=".spotlight" METHOD="post"> <INPUT NAME="search" TYPE="text"> <INPUT TYPE="submit" VALUE="Search"> <!-- Limits the number of hits presented --> <INPUT TYPE="hidden" NAME="maxhits" VALUE="100"> </FORM> </TD> </TR> </TABLE> <BR> <IMG SRC="grayline.gif" WIDTH=600 HEIGHT=1 ALIGN=bottom><BR> <BR> <BR> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=600> <TR> <TD VALIGN=top> <BR> <FONT SIZE="+1" FACE="Arial" COLOR="#999999"><B>Spotlight Content Search Results</B></FONT> </TD> <TD> <!--Dynamic content will go here (no spaces before or after!)--> <SPOTLIGHTOUT> <!--End of dynamic content section--> </TD> </TR> </TABLE> <BR> <BR> <CENTER><IMG SRC="grayline.gif" WIDTH=600 HEIGHT=1 ALIGN=bottom><BR> <P>(c) Copyright 2004 Apple Computer, Inc.</P></CENTER> </TD> </TR> </TABLE> </CENTER> </BODY> </HTML> </code>
That’s just an example to get you started.