Friday, October 17, 2014

Retrieve count of documents in Search Index - SharePoint 2013

To retrieve count of  documents in search index, save below script as .ps1 file and run it using powershell


<# 
.SYNOPSIS 
    Script to get the total number of indexed documents  
.DESCRIPTION 
    For the given Search Application, return the total number of indexed documents. 
    This will be the sum of indexed documents for all index partitions. 
.PARAMETER SearchApplication 
    Search application to use.   Multiple SSA's can be specified by 
    piping them in to the script.  In that case the result will be an array 
    of document counts, one for each SSA 
.EXAMPLE 
    Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchIndexedDocumentCount.ps1 
    88123 
.LINK 
http://gallery.technet.microsoft.com/ScriptCenter 
.NOTES 
  File Name : Get-SPEnterpriseSearchIndexedDocumentCount.ps1 
  Author    : Matthew King 
 
#> 
 
[CmdletBinding()] 
param([Parameter(ValueFromPipeline=$True)] 
      [Microsoft.Office.Server.Search.Cmdlet.SearchServiceApplicationPipeBind]$SearchApplication) 
 
Process { 
    $ssa = Get-SPEnterpriseSearchServiceApplication $SearchApplication 
    $topo = Get-SPEnterpriseSearchTopology -SearchApplication $ssa | ? { $_.State -eq 'Active'} 
    $count = 0 
    Get-SPEnterpriseSearchComponent -SearchTopology $topo | ` 
        ? { $_ -is [Microsoft.Office.Server.Search.Administration.Topology.IndexComponent] } | ` 
        Sort-Object IndexPartitionOrdinal -Unique | % { $component = $_ 
            [int]$c = $ssa | Get-SPEnterpriseSearchStatus –HealthReport –Component $component.Name | ` 
                ? { $_.name -match 'number of documents\[' } | % { $_.message } 
            Write-Verbose ("{0} {1} {2} " -$ssa.Name, $component.Name, $c) 
            $count +$c 
    } 
    $count 
}

Reference
https://gallery.technet.microsoft.com/office/Script-to-report-total-88056b1b

Delete Search Index - SharePoint 2013

To delete search index in SharePoint 2013, it can be done by Central Admin or by powershell. To delete it using powershell run below command

(Get-SPEnterpriseSearchServiceApplication).Reset($true,$true)

If it takes a long time to delete index and ultimatley if it gives time out error, follow below steps


  1. Stop the Windows SharePoint Services Timer service (Found in Windows Services)
  2. Navigate to the cache folder
  3. In Windows Server 2008, the configuration cache is in the following location:
  4. Drive:\ProgramData\Microsoft\SharePoint\Config
  5. In Windows Server 2003, the configuration cache is in the following location:
  6. Drive:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config
  7. Locate the folder that has the file "Cache.ini"
  8. (Note: The Application Data folder may be hidden. To view the hidden folder, change the folder options as required)
  9. Back up the Cache.ini file.
  10. Delete all the XML configuration files in the GUID folder. Do this so that you can verify that the GUID folder is replaced by new XML configuration files when the cache is rebuilt.
  11. Note When you empty the configuration cache in the GUID folder, make sure that you do not delete the GUID folder and the Cache.ini file that is located in the GUID folder.
  12. Double-click the Cache.ini file.
  13. On the Edit menu, click Select All. On the Edit menu, click Delete. Type 1, and then click Save on the File menu. On the File menu, click Exit.
  14. Start the Windows SharePoint Services Timer service
  15. Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
  16. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.



Reference
http://blogs.technet.com/b/maruntz/archive/2013/04/10/reset-the-content-index-of-sharepoint-server-2010-via-powershell.aspx
https://social.technet.microsoft.com/Forums/sharepoint/en-US/ede11fc6-59a7-47be-893d-dc1ea4c88879/cant-reset-index-sharepoint-2013




Thursday, March 20, 2014

Export GridView to excel in Visual Webpart in SharePoint

Declare GridView and Button as below

<asp:GridView ID="gridViewPermission"  runat="server" >
     </asp:GridView>

<asp:Button ID="buttonExportUsers" runat="server" Text="Export Users" onclick="ButtonExportUsers_Click" OnClientClick="window.setTimeout(function() { _spFormOnSubmitCalled = false; }, 10);"/>

Note the OnClientClick event for button

There are two approaches to export it

1. Export to csv file
2. Export to excel file



1. Export to csv file

            StringBuilder sb = new StringBuilder();
            GridViewRow grHeader = gridViewPermission.HeaderRow;
            int counter = 0;

            foreach (TableCell tc in grHeader.Cells)
            {
                sb.Append("" + tc.Text + " ,");
                counter++;
            }
            sb.AppendLine();

            foreach (GridViewRow gr in gridViewPermission.Rows)
            {
                foreach (TableCell tc in gr.Cells)
                {
                    sb.Append("" + tc.Text + " ,");
                }
                sb.AppendLine();
            }

            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AddHeader(" content-disposition", " attachment; filename=" + strSite + "_Users_" + strDate + ".csv");
            Response.ContentType = " text/csv";
         
            Response.AddHeader(" Pragma", " public");
            Response.Write(sb.ToString());
            Response.End();


2. Export to excel file

Response.ClearContent();
            Response.AddHeader("content-disposition", " attachment; filename=" + strSite + "_Users_" + strDate + ".xls");
            Response.ContentType = "application/vnd.ms-excel";
            string tab = string.Empty;
            GridViewRow grHeader = gridViewPermission.HeaderRow;
            foreach (TableCell headerCell in grHeader.Cells)
            {
               Response.Write(tab + headerCell.Text );
               tab = "\t";
            }

            Response.Write("\n");
            foreach (GridViewRow gridViewRow in gridViewPermission.Rows)
            {
                tab = string.Empty;
                foreach (TableCell dataCell in gridViewRow.Cells)
                {
                    Response.Write(tab + dataCell.Text.Replace(CommonFunctions.SpaceText,string.Empty) );
                    tab = "\t";
                }
                Response.Write("\n");
            }
            Response.End();

References - http://www.fewlines4biju.com/2011/11/export-gridview-data-to-excel-aspnet.html

Thursday, March 06, 2014

Configure ElasticSearch on Windows


2.      Download the latest java SDK if not installed on the system.

3.      Navigate to url http://www.elasticsearch.org/download/

4.      Download the zip version of elasticsearch for windows.

5.      Extract the files to a folder

6.      Set JAVA_HOME variable if not set

a.       Click on Start, right click on My Computer -> Properties
b.      Click on Advanced system settings



c.       In Advanced tab click on Environment variables



d.      If JAVA_HOME variable is not present here, click on New and enter details for Variable Name and Variable Value. Variable value will be path where java sdk is installed.



e.       Save the value

7.      Navigate to the folder where elastic search files were extracted.

8.      Navigate to bin folder and double click on elasticsearch.bat to run.



9.      Navigate to http://localhost:9200/ url and below screen should appear if successfully installed.





1.  Install Google Chrome plug-in Sense to run elasticsearch queries.

Thursday, August 30, 2012

Add words to spell check SharePoint 2010

1. Create a text file on your local machine and add each custom term on a seperate line, save the file as "Custom Dictionary.txt" 2. Create a library within the root of the site collection, call it "Spelling"; upload your "Custom Dictionary.txt" file to the library For more details refer to below blog http://www.rightpoint.com/community/blogs/viewpoint/archive/2011/10/28/how-to-add-words-the-spell-check-dictionary-in-sharepoint-2010.aspx

Wednesday, October 03, 2007

Champions League Highlights(2/10/07 - 3/10/07)

UEFA Champions League Highlights
For goals from all matches Click Here

Monday, October 01, 2007

Spahish LaLiga Highlights

Thiery Henry opened his scoring for Barcelona with a hattrick

Barclays Premier League Highlights(29/7/07 - 1/10/07)

The highest goals ever scored in a premier league match was recorded at Fratton Park where Portsmouth thrashed Reading 7-4
For more videos including 1-nil wins by MAN U and Arsenal Click Here

Thursday, September 27, 2007

Idea Star Singer Videos

Arun Gopan

for more vidoes Click Here

Wednesday, September 26, 2007

Carling Cup Highlights

Liverpool trashed Reading 4-2 courtse of a wonderful hattrick by new signing Fernando Torres

Tuesday, September 25, 2007

India Wins Final

Indian Team Celebrating
For More Videos Including India's Batting And Pakistan's Innings Click here

Monday, September 24, 2007

Thursday, September 20, 2007

Champions League Highlights


Manchester United had a winning start to this years champions league by beating Sporting lisbon by a goal to nil. to watch other highlights of champions league including victories of arsenal, barcelona Click Here

Friday, September 14, 2007

Twenty20 Highlights


Yuvraj was on a rampage here, hitting six sixes in an over proving once again that he can not only give but also hit sixes
For more videos including India v england highlights,Bret lee's hattrick , the first in twenty20 click here

Dravid resigns as India captain


The skipper's resignation has come as a surprise, with Team India Manager Chandu Borde saying that there was no prior indication of Dravid wanting to step down.

McLaren lose constructors points, fined $100m



Formula One leaders McLaren have been stripped of all their points in the 2007 constructors championship and fined $100 million as a result of a spying controversy, the governing body confirmed on Thursday.

Thursday, September 13, 2007

Zimbabve Stun Aussies


The world loves an underdog, and when the unthinkable happens, even the cynics applaud. Celebrations after Zimbabwe humbled world number one Australia in their opening match at the picturesque Newlands cricket ground went well into the night, but not for the Zimbabwean players themselves.

Euro Qualifiers Update


In one of the biggest upsets, Scotland beat France 1-0 to go to top on Euro Qualifiers

Comfortable win for england


Michael Owen scored twice as England took a huge stride towards the Euro 2008 finals with a 3-0 win against Russia at Wembley.Click here to see the video

Wednesday, September 12, 2007