File Search / Indexing Search with .net 2.0
Hello friends Follwing are the code for Indexing search.
you need not to create new catlog for Indexing searching.
HTML CODE
(Simple Text box, gridview and Button)
<html >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Search String"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="493px"></asp:TextBox>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
Width="595px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Search" /></div>
</form>
</body>
</html>
Code Behind
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Cisso;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.DataSource = GetIndexResults(TextBox1.Text);
GridView1.DataBind();
}
private DataTable GetIndexResults(string Query)
{
Cisso.CissoQueryClass csQueary = new Cisso.CissoQueryClass();
Cisso.CissoUtilClass csUtil = new Cisso.CissoUtilClass();
csQueary.Query = TextBox1.Text;
csQueary.SortBy = "rank[d]";
csQueary.Columns = "DocTitle, vpath, path, filename, size, write, characterization";
csUtil.AddScopeToQuery(csQueary,"/Myfiles", "deep" );
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter();
da.Fill(ds, csQueary.CreateRecordset("nonsequential"), "IndexServerResults");
if( ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["characterization"].ToString() !="")
{
Response.Write( Server.HtmlEncode(ds.Tables[0].Rows[0]["characterization"].ToString()));
}
return ds.Tables[0];
}
}
Just Copy paste the code test it then format it properly.
Cheers!
Happy Coding.
Maulik Pandya
|