Monthly Archives: September 2011

PDF’s not opening in browser from a sharepoint 2010 site?

I had this problem enough times that I wanted to capture the solution.

First of all, credit goes to Craig Lussier on the Technet forms, his post has the full solution and background.

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/2f66404e-5193-46d3-b6b1-45cf72410432?prof=required

I used the above solution and it worked great.

I also found a script that I did not try. The script is described as being able to change this setting system wide by looping through each document library in each subsite of a given site – it could come in handy. (the script is by the same poster – Craig Lussier – Thanks Craig!

http://gallery.technet.microsoft.com/scriptcenter/Set-SPDocumentLibrary-0426781c

The code below is from the first link above, I’ve copied it here in case MS ever changes the link structure and the original post can’t be found. 

# SPAssignment
$gc = Start-SPAssignment

#Get Web
$web = $gc | Get-SPWeb "http://yourspweburl"

#Get Document Library
$docLib = $web.lists["Your Document Library Title"]

#View all properties/methods of the Document Library and you'll see that BrowserFileHandling is a property
$docLib | Get-Member

#See the current BrowserFileHandling setting for the Document Library
$docLib.BrowserFileHandling

#If you need to change it from Strict to Permissive
$docLib.BrowserFileHandling = "Permissive"
$docLib.Update()

# End SPAssgment
$gc | Stop-SPAssignment

Scope Sharepoint FAST search to a file share

Ok this took a bit of wrangling and some new understandings on my part to understand.

I was trying to index a file share of content, and create a FAST search page that would ONLY search that content. Since the FAST server had tons of other stuff on it, I needed to create a scope to narrow down the search. 

I used this powershell command to create the scope – this is key – you can’t do this from the sharepoint GUI (As of Sharepoint 2010 SP)

New-SPEnterpriseSearchQueryScope -SearchApplication “FAST Search Query SSA” -Name thisisthescopename -Description “A scope for a file share” -DisplayInAdminUI 1 -ExtendedSearchFilter “contentsource:nameofcontentsource”

Some explanation – the -SearchApplication is the name of our FAST query SSA – yours might be named differently

The -ExtendedSearchFilter nees some explanation,

First, the word contentsource needs to be in lower case – I had orignally tried it in mixed case (ContentSource) and that didn’t work

Next, the :nameofcontentsource – this is the artificial name you gave the content source over in your FAST Content SSA – it’s NOT the URL, UNC Path etc.. of the content!

for example, if in your FAST Content SSA, you created a content source on \server1files and called it myfiles

then your ExtendedSearchFilter would look like this: “contentsource:myfiles”

Ok so that’s the end of my explanation of the command itself.

After a few minutes the scope is created and we can test it in a normal FAST search site in sharepoint

Lets say that we indexed a bunch of content on monkeys and we want to see if it turns up in our new scope.

We would search for scope:thisisthescopename monkey

If we get the results we want, then we know the scope is working.

One step beyond this, we can create a special search page for this scope,

create a new FAST search site in sharepoint.

do a bogus search on the sites home page so that it shows you the results page

Edit the results page in the browser

find the web part at the bottom that displays the results

edit that web part

On the right hand side of the page, are the web parts properties, one of them is ‘scope’

put thisisthescopename in that web part and save the page (don’t forget to check in/publish if needed too)

now on your newly modified search page, when you enter a search for monkey, it will limit it to your scope.

Clear FAST Search Content Collection

I had a stubborn FAST Server installation that continued to return search results, even after the content source was removed from FAST!

After stumbling around, someone on the FAST forums at Microsoft suggested clearing the sp collection, but didn’t say how.

Here’s how:

On the fast server, there will be a shortcut to launch a FAST powershell prompt – open that

Enter the command

Clear-FastSearchContentCollection sp

That should clear it out – you’ll need to do full crawls on all your content sources after this is done to repopulate the index, so it’s best not to do this to a production box without understanding how long search will be down.

Also note that in FAST Search for Sharepoint, pretty much everything is stored in the SP collection – It’s my understanding that as of right now, you can only have one collection in FAST for SP.

Snippet of XSLT to create a link to the parent folder of an item in a search result

I wanted to add a link to the parent folder of an item in FAST search results.

I had found an article that said I could use the “SiteName” property.

Unfortunately, this content wasn’t from a SharePoint site, it was from a File Share.

The “SiteName” only returned \\Server\Sharename for each result, never the folder path

For example \\Server\ShareFolder1\SubFolderA\myfile.txt is where the file is

SiteName retured \\ServerShare

I wanted \\Server\Share\Folder1\SubFolderA

The following XSLT uses a few chained string commands to return the desired results

<xsl:if test="isdocument = 'True'">
   <br/>
   <a>
      <xsl:attribute name="href">
         <xsl:value-of select="substring(url,1,string-length(url) - string-length(title))"/>
      </xsl:attribute>
      <i>Link to Containing Folder</i>
   </a>
</xsl:if>

Snippet of XLST to dump the output of search results

This is one of those posts more to serve as a reminder to me than anything.

While watching a video on SharePoint-Videos.com about customizing search results with XSLT, the presenter showed how to use a small bit of XSL to dump all the search results returned by the search engine – the original video can be found here: http://www.sharepoint-videos.com/sp10-customize-search-results-using-xslt/

 

<?xml version=”1.0″ encoding=”UTF-8″>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xls:template match "/">
<textarea rows="20" cols="100">
 <xsl:copy-of select="*"/>
</textarea>
</xsl:template>
</xsl:stylesheet>