Showing posts with label Enterprise Search. Show all posts
Showing posts with label Enterprise Search. Show all posts

Monday, April 22, 2013

Stemming in SharePoint 2013 Search

Stemming essentially performs searches for words that share the same stem. Stemming in SharePoint 2013 is enabled by default and although it can be disabled, there is no UI option in the Search Results Web Part anymore. In addition, the EnableStemming property in the object model is also deprecated.

To disable stemming you need to:
  1. Export a Search Results Web Part
  2. Open the file in a text editor
  3. Set the EnableStemming property to false ("EnableStemming":false)
  4. Save the file
  5. Import the web part back onto the search results page
  6. Remove the existing web part from the search results page

While classic examples of stemming are explained as “run” and “ran” as well as “writes” and “wrote”, the results I am seeing are not so. The behavior I am experiencing in SharePoint 2013 is mostly plural and singular versions of words. For example “party” also presents results for “parties” (and vice-versa). “Search” is providing hits on “search” and “searches” but not “searcher”. I am not seeing "wrote" hits when I search for "write" nor do I see "ran" results when I search for "run".
Since there is no longer support for third-party stemming tools (and thus the previous registry entries are no longer used), the workaround to all of this is to include any additional stemming as synoynyms in a thesaurus file which may be loaded into SharePoint via PowerShell commands.

I have crawled 100GB of content so I should have a great sampling of words. Has anyone seen anything different with stemming?






Tuesday, October 2, 2012

SharePoint 2013: PDF Preview in Search Results


Check out the whole SharePoint 2013 Solution Series
New Titles Added Weekly!

Introduction
One of the enhancements in SharePoint 2013 Enterprise Search results is the ability to preview documents using Office Web Apps Server. I am in the process of seeing what that looks like and will post an Office Web Apps server entry soon. UPDATE: Here is the post.

Anyway, the issue is that if you have Office Web Apps configured, the only documents that show previews are Microsoft Office documents (e.g. Word, Excel, etc.). The preview of PDF documents is not implemented or supported using Office Web Apps.

Therefore, I created my own PDF preview for Enterprise Search results by customizing the new search Display Templates. This works for local site search results too which I explain at the bottom of this post.

To understand overall PDF functionality and behaviors, read the whole story here.

Prerequisites
Here are some things you need in place before implementing this solution:

  • Enterprise Search Application configured and running
  • Crawled content that includes PDF documents
  • Enterprise Search Center site collection
  • SharePoint Designer 2013


Modifying the PDF Search Result Template
This is the main effort and is fairly easy. I found it better to modify the templates using SharePoint Designer 2013 although they are accessible through the SharePoint master page UI.

Step 1: Fire up SharePoint Designer 2013 and Open the Search Center Site

 
 
Step 2: Click on All Files from the left-hand navigation
If you attempt to get the files from the Master Pages, you will not see any items once you get to the Display Templates folders.


You will see the list of all files in the main window.

Step 3: Double-click on the _catalogs folder in the main window
This action displays the _catalogs structure under the left-hand navigation.


Expand the _catalogs folder, then the masterpage folder, and then the Display Templates folder.

Step 4: Click on the Search folder under Display Templates

 
The list of Search display templates is shown in the main window area.

Step 5: Right-click on Item_PDF_HoverPanel.html and select Edit File in Advanced Mode

 
 
Step 6: Paste the following code within the most inner <div>


    <object data="_#= ctx.CurrentItem.Path =#_" type="application/pdf" width="500px" height="630px" >
       <p>It appears you don't have a PDF plugin for this browser/device.
      You can <a href="_#= ctx.CurrentItem.Path =#_">click here to
       download the PDF file.</a></p>
    </object>


Note: You may find it better to use the following for width and height: width="100%" height="500px"


I actually replaced the Render Header and Render Body divs with the object code.

Step 7: Save the file
When saving the file, you may get a warning about breaking from the site definition. Click OK.
What happens behind the scenes is that the HTML changes are incorporated into the javascript version of the template (Item_PDF_HoverPanel.js).

Step 8: Test results
Perform a search from your search center that produces PDF document results. Hover over the PDF document to see the preview:


Currently the object tag uses hard-coded widths and heights. It is not using any responsive design styles. Me and my designer will be working on producing a more consistent respresentation for the PDF preview.

Local Search Implementation
There is still local site search results using the OSSSearchResults.aspx. You may implement the PDF Preview for these results as well but the modification is slightly different.

You open the site in SharePoint Designer 2013 and navigate to the Display Templates in the same fashion. However, for local (non Enterprise Search sites) there are no HTML templates - only the javascript files. You may simply copy the javascript that was created in your Enterprise Search Center site collection (when you modified the HTML) or paste the following code:

,'    <object data="', ctx.CurrentItem.Path ,'" type="application/pdf" width="280px" height="430px">'
,'       <p>It appears you don\'t have a PDF plugin for this browser/device.'
,'       No biggie... you can <a href="', ctx.CurrentItem.Path ,'">click here to'
,'       download the PDF file.</a></p>'
,'    </object>'

Save the file and preview the results by performing a local search in the SharePoint site.

It appears that the hover container in this case is being constrained in regards to its size. Therefore  I needed to use 280px for width and 430px for height. I will be working on making this more flexible.



To see what Office Web Apps server does for previewing of documents, see this post.
For Installation steps, see this post.

 

Matched Content