Points we need to make sure before using Search Option
Open the project "SharePoint.Search".
Go to the method "ExecuteFullTextSqlQuery" In SearchResults.ascx.cs page, where we can see query which retrieves data
"SELECT FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument FROM SCOPE()"
Go to Central Administration,
Shared Services Administration: SharedServices1 > Search Settings > Managed Properties
Open Metadata Property Mappings page
Check All the fields which is specified in the query exist or not .
If the fields doesn't exist, go to New Managed Property at the top and add the field.
Check the checkbox "Use in Scope"
Common errors which may occur are :
Property doesn't exist or is used in a manner inconsistent with schema settings.
Possible reason : Field doesn't exist in Metadata Property Mappings
Your query is malformed. Please rephrase your query
Possible reason : Query is nor formatted properly
After doing this, again if the data is not coming, Comment the line
//sbFullTextSqlQuery.Append(" \"Scope\" = '" + _scope + "' ");
Because this may give error as "Scope in your query does not exist"
To know more about how this works, check this links
http://msdn2.microsoft.com/en-us/library/bb608305.aspx
http://www.ureader.com/msg/12294188.aspx
The code below says about how we can customize sharepoint search option
protected void btnSearch_Click(object sender, EventArgs e)
{
ResultTableCollection resultTableCollection = FetchRelevantSearchResults();
ResultTable relevantResultsResultTable = resultTableCollection[ResultType.RelevantResults];
DataTable relevantResultsDataTable = new DataTable();
relevantResultsDataTable.Load(relevantResultsResultTable, LoadOption.OverwriteChanges);
if (relevantResultsDataTable != null)
{
grdSearch.DataSource = relevantResultsDataTable;
grdSearch.DataBind();
}
}
// Fetch search result
private ResultTableCollection FetchRelevantSearchResults()
{
ResultTableCollection resultTableCollection = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
try
{
ExecuteFullTextSqlQuery(out resultTableCollection);
}
catch (Exception ex)
{
}
});
return resultTableCollection;
}
// Call CAML query
private void ExecuteFullTextSqlQuery(out ResultTableCollection resultTableCollection)
{
// Guid _currentSiteGuid = SPContext.Current.Site.ID;
//using (SPSite _SPSite = new SPSite(_currentSiteGuid))
//http://mossdev:6076
//http://mossdev:35643/
using (SPSite _SPSite = new SPSite("http://mossdev:35643"))
{
using (FullTextSqlQuery _FullTextSqlQuery = new FullTextSqlQuery(_SPSite))
{
_FullTextSqlQuery.StartRow = 0;
_FullTextSqlQuery.RowLimit = 2;
_FullTextSqlQuery.HighlightedSentenceCount = 3;
_FullTextSqlQuery.EnableStemming = true;
_FullTextSqlQuery.TrimDuplicates = true;
_FullTextSqlQuery.Culture = CultureInfo.CurrentCulture;
_FullTextSqlQuery.KeywordInclusion = KeywordInclusion.AnyKeyword;
if (SPSecurity.AuthenticationMode != AuthenticationMode.Windows)
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
}
else
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;
}
_FullTextSqlQuery.ResultTypes = ResultType.RelevantResults;
StringBuilder sbFullTextSqlQuery = new StringBuilder(string.Empty);
sbFullTextSqlQuery.Append("SELECT ");
sbFullTextSqlQuery.Append(" FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument ");
sbFullTextSqlQuery.Append("FROM ");
sbFullTextSqlQuery.Append(" SCOPE() ");
sbFullTextSqlQuery.Append("WHERE ");
sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'raj') ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" \"Scope\" = 'Knowledge Objects' ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" ( ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
sbFullTextSqlQuery.Append(" ) ");
sbFullTextSqlQuery.Append("ORDER BY ");
sbFullTextSqlQuery.Append(" Rank DESC ");
// sbFullTextSqlQuery = new StringBuilder();
//sbFullTextSqlQuery.Append("SELECT Title, Abstract, Rank FROM scope() WHERE scope='All Sites' ");
//sbFullTextSqlQuery.Append("SELECT Account,CreatedBy FROM scope() ");
// fields needs mapping Title,Abstract,
// sbFullTextSqlQuery.Append("SELECT FileExtension, Rank, contentclass, Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company') AND Scope = 'Knowledge Objects' AND ( (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') OR (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') OR (ContentClass = 'STS_Web') ) ORDER BY Rank DESC") ;
//sbFullTextSqlQuery.Append("SELECT FileExtension,contentclass,Rank,Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company')");
//sbFullTextSqlQuery.Append("AND ");
//sbFullTextSqlQuery.Append(" ( ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
//sbFullTextSqlQuery.Append(" ) ");
//sbFullTextSqlQuery.Append("ORDER BY ");
//sbFullTextSqlQuery.Append(" Rank DESC ");
//sbFullTextSqlQuery.Append("SELECT ");
//sbFullTextSqlQuery.Append("Title,Abstract, FileExtension, Rank, ContentClass, Path,IsDocument ");
//sbFullTextSqlQuery.Append("FROM ");
//sbFullTextSqlQuery.Append(" SCOPE() ");
//sbFullTextSqlQuery.Append("WHERE ");
//sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'company') ");
_FullTextSqlQuery.QueryText = sbFullTextSqlQuery.ToString();
resultTableCollection = _FullTextSqlQuery.Execute();
}
_SPSite.RootWeb.Dispose();
}
}
Tuesday, April 7, 2009
Wednesday, February 25, 2009
Dooly's Domain: Publishing InfoPath Forms - Updating Content Type Failed
I'm also getting the same issue. Can u help me, how to fix this issue.
Monday, January 12, 2009
Configure MOSS 2007 Site Usage Reports
Three Quick Steps to Configure Site Usage Reporting
Enable Usage Logging in Central Administration
A. On the Central Administration home page, click Operations.
B. On the Operations page, in the Logging and Reporting section, click Usage analysis processing.
C. On the Usage Analysis Processing page, in the Logging Settings section, select Enable logging.
D. Type a log file location and number of log files to create.
E. In the Processing Settings section, select Enable usage analysis processing, and then select a time to run usage processing.
Enable Usage Reporting on SSP Admin Page
A. On the SSP home page, in the Portal Usage Reporting section, click Usage reporting.
B. On the Configure Advanced Usage Analysis Processing page, in the Processing Settings section, click Enable advanced usage analysis processing.
C. In the Search Query Logging section, select Enable search query logging.
Activate the Reporting Feature for the Site Collection
A. On the Site Actions menu, click Site Settings.
B. On the Site Settings page, in the Site Collection Administration section, click Site collection features.
C. On the Site Collection Features page, click the Activate button for the Reporting feature.
After site usage reporting is enabled the site administrators and site collection administrators will be able to view reports detailing:
Requests and queries in the last day and the last 30 days
Average number of requests per day over the last 30 days
Requests per day over the last 30 days
Top page requests over the last 30 days
Top users over the last 30 days
Top referring hosts over the last 30 days
Top referring pages over the last 30 days
Top destination pages over the last 30 days
Top search queries for the last 30 days
Search results top destination pages
Number of search queries per day over the previous 30 days
Number of search queries per month over the previous 12 months
Top search queries over the previous 30 days
Search Queries per search scope over the previous 30 days
Site collection administrators will be able to view reports detailing:
Total amount of storage used by the site collection
Percent of storage space used by Web Discussions
Maximum storage space allowed
Number of users for all sites in the hierarchy
Total hits and recent bandwidth usage across all sites
Enable Usage Logging in Central Administration
A. On the Central Administration home page, click Operations.
B. On the Operations page, in the Logging and Reporting section, click Usage analysis processing.
C. On the Usage Analysis Processing page, in the Logging Settings section, select Enable logging.
D. Type a log file location and number of log files to create.
E. In the Processing Settings section, select Enable usage analysis processing, and then select a time to run usage processing.
Enable Usage Reporting on SSP Admin Page
A. On the SSP home page, in the Portal Usage Reporting section, click Usage reporting.
B. On the Configure Advanced Usage Analysis Processing page, in the Processing Settings section, click Enable advanced usage analysis processing.
C. In the Search Query Logging section, select Enable search query logging.
Activate the Reporting Feature for the Site Collection
A. On the Site Actions menu, click Site Settings.
B. On the Site Settings page, in the Site Collection Administration section, click Site collection features.
C. On the Site Collection Features page, click the Activate button for the Reporting feature.
After site usage reporting is enabled the site administrators and site collection administrators will be able to view reports detailing:
Requests and queries in the last day and the last 30 days
Average number of requests per day over the last 30 days
Requests per day over the last 30 days
Top page requests over the last 30 days
Top users over the last 30 days
Top referring hosts over the last 30 days
Top referring pages over the last 30 days
Top destination pages over the last 30 days
Top search queries for the last 30 days
Search results top destination pages
Number of search queries per day over the previous 30 days
Number of search queries per month over the previous 12 months
Top search queries over the previous 30 days
Search Queries per search scope over the previous 30 days
Site collection administrators will be able to view reports detailing:
Total amount of storage used by the site collection
Percent of storage space used by Web Discussions
Maximum storage space allowed
Number of users for all sites in the hierarchy
Total hits and recent bandwidth usage across all sites
Wednesday, January 7, 2009
Adding a 'Save site as template' Link to Site Settings in WSS v3/MOSS 2007 using a CustomAction Feature
The SaveSiteAsTemplate feature will consist of a Feature.xml and an Elements.xml file.
Feature.xml declares the Feature itself, and Elements.xml further defines the CustomAction for the Look and Feel menu on a Site Settings page.
To get started, create a folder named SaveSiteAsTemplate below the Features folder located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES on your WSS v3 server. Create Feature.xml and Elements.xml from the code below and place each file in the SaveSiteAsTemplate folder you just created.
Feature.xml
Note the Scope attribute in the Feature element of Feature.xml. Scope can be set to either Farm, WebApplication, Site or Web. Also notice that the ElementManifest element points to Elements.xml.
Elements.xml
Setting the Location of the CustomAction to Microsoft.SharePoint.Settings and the GroupId to Customization is what decides where the link will be render in the UI.
Next, install the feature into WSS v3 by using the stsadm tool. Stsadm.exe is located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on your WSS v3 server.
stsadm -o installfeature -name SaveSiteAsTemplate
Finally, activate the new feature on your WSS Site by going to Site Settings > Site Features and clicking the Activate button for the new Save Site As Template feature.
Feature.xml declares the Feature itself, and Elements.xml further defines the CustomAction for the Look and Feel menu on a Site Settings page.
To get started, create a folder named SaveSiteAsTemplate below the Features folder located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES on your WSS v3 server. Create Feature.xml and Elements.xml from the code below and place each file in the SaveSiteAsTemplate folder you just created.
Feature.xml
Note the Scope attribute in the Feature element of Feature.xml. Scope can be set to either Farm, WebApplication, Site or Web. Also notice that the ElementManifest element points to Elements.xml.
Elements.xml
Setting the Location of the CustomAction to Microsoft.SharePoint.Settings and the GroupId to Customization is what decides where the link will be render in the UI.
Next, install the feature into WSS v3 by using the stsadm tool. Stsadm.exe is located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on your WSS v3 server.
stsadm -o installfeature -name SaveSiteAsTemplate
Finally, activate the new feature on your WSS Site by going to Site Settings > Site Features and clicking the Activate button for the new Save Site As Template feature.
You should now see a “Save site as template” link under the Look and Feel menu of the Site Settings page.
Apply top level site UI to all the Sub sites
1. Create the Top Level Sites as per the requirement
2. Change the UI as per the requirement
3. Save the Changed UI as Custom Template
Site Action --> Site Settings --> Save “Site as Template”
A) Enter the FileName: CustomTemplate (Change the file name as per the requirement)
B) Template Name: CustomTemplate (Change the template name as per the requirement)
C) Template Description: CustomTemplate (Change the Description as per the requirement)
D) Finally click ok
4. Active on "Office SharePoint Server Publishing Infrastructure" features.
Site Action --> Site Settings --> Site Collection Administration --> Site Collection Features --> Activate "Office SharePoint Server Publishing Infrastructure" features
5. Activate "Office SharePoint Server Publishing" features
Site Action --> Site Settings --> Site Administration --> Site Features --> Activate "Office SharePoint Server Publishing" features
6. Create the Sub site and inherit the UI from Top Level Site
Site Action --> Create or Create Site
A) Title: As per the requirement
B) Description: As per the requirement
C) URL name: As per the requirement
D) Select a Template: Click the Custom Tab --> Must Select the "CustomTemplate".
E) User Permission: As per the requirement
F) Finally click "Create" option.
7. Apply Top Level site header to sub site
Go to Top Level Site --> Site Action --> Modify All Site Settings --> Look and feel --> Master Page
A) Site Master Page --> Select Default.master --> Check "Reset all sub sites to inherit this Site Master Page setting" check box
B) System Master Page --> Select Default.master --> Check "Reset all sub sites to inherit this system master page setting" check box
C) Finally click ok
2. Change the UI as per the requirement
3. Save the Changed UI as Custom Template
Site Action --> Site Settings --> Save “Site as Template”
A) Enter the FileName: CustomTemplate (Change the file name as per the requirement)
B) Template Name: CustomTemplate (Change the template name as per the requirement)
C) Template Description: CustomTemplate (Change the Description as per the requirement)
D) Finally click ok
4. Active on "Office SharePoint Server Publishing Infrastructure" features.
Site Action --> Site Settings --> Site Collection Administration --> Site Collection Features --> Activate "Office SharePoint Server Publishing Infrastructure" features
5. Activate "Office SharePoint Server Publishing" features
Site Action --> Site Settings --> Site Administration --> Site Features --> Activate "Office SharePoint Server Publishing" features
6. Create the Sub site and inherit the UI from Top Level Site
Site Action --> Create or Create Site
A) Title: As per the requirement
B) Description: As per the requirement
C) URL name: As per the requirement
D) Select a Template: Click the Custom Tab --> Must Select the "CustomTemplate".
E) User Permission: As per the requirement
F) Finally click "Create" option.
7. Apply Top Level site header to sub site
Go to Top Level Site --> Site Action --> Modify All Site Settings --> Look and feel --> Master Page
A) Site Master Page --> Select Default.master --> Check "Reset all sub sites to inherit this Site Master Page setting" check box
B) System Master Page --> Select Default.master --> Check "Reset all sub sites to inherit this system master page setting" check box
C) Finally click ok
Tuesday, December 2, 2008
Create a Managed Path Embedded Site Collection
Create a Managed Path Embedded Site Collection
Have you ever want to create a site collection in the root of a managed path?
For example, create a site collection at http://portal.foo.bar/sitecollection.
It can be done and is particularly useful on publishing sites when you don't
want a managed path like sites in the URL. It can also be used for division
portals like http://portal.foo.bat/HR and http://portal.foo.bar/IT
To create an embedded managed path site collection, do the following:
1. Open Central Administration > Application Management > SharePoint Web Application Management > Define Managed Paths.
2. Select the Web application in which you wish to create the managed path.
3. In the Add A New Path field, enter the name you wish for the embedded managed path site collection.
In the earlier example, the name is accounting.
4. You must select Explicit Inclusion as the Type .
5. Open Central Administration > Application Management > SharePoint Site Management > Create Site Collection.
This action must be performed from Central Administration.
You cannot create an embedded managed path site collection using self-service site management.
6. Select the correct Web application from the list.
7. Select the Explicit Inclusion you created earlier as the URL path.
Have you ever want to create a site collection in the root of a managed path?
For example, create a site collection at http://portal.foo.bar/sitecollection.
It can be done and is particularly useful on publishing sites when you don't
want a managed path like sites in the URL. It can also be used for division
portals like http://portal.foo.bat/HR and http://portal.foo.bar/IT
To create an embedded managed path site collection, do the following:
1. Open Central Administration > Application Management > SharePoint Web Application Management > Define Managed Paths.
2. Select the Web application in which you wish to create the managed path.
3. In the Add A New Path field, enter the name you wish for the embedded managed path site collection.
In the earlier example, the name is accounting.
4. You must select Explicit Inclusion as the Type .
5. Open Central Administration > Application Management > SharePoint Site Management > Create Site Collection.
This action must be performed from Central Administration.
You cannot create an embedded managed path site collection using self-service site management.
6. Select the correct Web application from the list.
7. Select the Explicit Inclusion you created earlier as the URL path.
Tuesday, November 4, 2008
Custom Advanced Search Code
1. Add code to Button Click Event
Microsoft.Office.Server.Search.Query.FullTextSqlQuery kwQuery = new Microsoft.Office.Server.Search.Query.FullTextSqlQuery(new SPSite("Top Level Site Name"));
kwQuery.QueryText = "SELECT Title, URL FROM Scope() WHERE FREETEXT(Contents, '" + Custom Text Values + "') and Competitor='"+Custom Values+"'";
kwQuery.ResultTypes = Microsoft.Office.Server.Search.Query.ResultType.RelevantResults; Microsoft.Office.Server.Search.Query.ResultTableCollection results = kwQuery.Execute(); Microsoft.Office.Server.Search.Query.ResultTable tblResult = results[Microsoft.Office.Server.Search.Query.ResultType.RelevantResults];
if (tblResult.TotalRows == 0)
{
lblQueryResult.Text = "No Search Results Returned.";
}
else
{
ReadResultTable(tblResult);
}
2.
public void ReadResultTable(Microsoft.Office.Server.Search.Query.ResultTable rt)
{
#region Create a DataSet and load the returned ResultTable into it
DataTable relResultsTbl = new DataTable();
relResultsTbl.TableName = "Relevant Results";
DataSet ds = new DataSet("resultsset");
ds.Tables.Add(relResultsTbl);
ds.Load(rt, LoadOption.OverwriteChanges, relResultsTbl);
#endregion
#region Add the results to the DataGrid
fillResultsGrid(ds);
#endregion
}
Microsoft.Office.Server.Search.Query.FullTextSqlQuery kwQuery = new Microsoft.Office.Server.Search.Query.FullTextSqlQuery(new SPSite("Top Level Site Name"));
kwQuery.QueryText = "SELECT Title, URL FROM Scope() WHERE FREETEXT(Contents, '" + Custom Text Values + "') and Competitor='"+Custom Values+"'";
kwQuery.ResultTypes = Microsoft.Office.Server.Search.Query.ResultType.RelevantResults; Microsoft.Office.Server.Search.Query.ResultTableCollection results = kwQuery.Execute(); Microsoft.Office.Server.Search.Query.ResultTable tblResult = results[Microsoft.Office.Server.Search.Query.ResultType.RelevantResults];
if (tblResult.TotalRows == 0)
{
lblQueryResult.Text = "No Search Results Returned.";
}
else
{
ReadResultTable(tblResult);
}
2.
public void ReadResultTable(Microsoft.Office.Server.Search.Query.ResultTable rt)
{
#region Create a DataSet and load the returned ResultTable into it
DataTable relResultsTbl = new DataTable();
relResultsTbl.TableName = "Relevant Results";
DataSet ds = new DataSet("resultsset");
ds.Tables.Add(relResultsTbl);
ds.Load(rt, LoadOption.OverwriteChanges, relResultsTbl);
#endregion
#region Add the results to the DataGrid
fillResultsGrid(ds);
#endregion
}
Subscribe to:
Posts (Atom)