我使用索引服务器在 Windows Server 2008 r2 中使用 ASP.NET 4.6.1。
我使用Microsoft OLE DB Provider for Microsoft Indexing Service,相同的 Provider MSIDXS
现在,我想使用 Windows Server 2012 r2。
从 Windows XP 开始不再支持索引服务,并且从 Windows 8 开始无法使用。相反,使用 Windows Search 进行客户端搜索,使用 Microsoft Search Server Express 进行服务器端搜索。
如何在 ASP.NET 中使用 Microsoft Search?
我很困惑:我使用的是Windows Search Server还是Windows Search Service?
需要哪个OLE DB 提供程序?
如何安装Windows 搜索服务器?
如何安装Windows 搜索服务?(可能是 Windows 2012 R2 中的功能)
下载和安装 Windows Search Server 不会安装 OLE DB 提供程序。也不安装 Windows SDK。安装 Windows 搜索服务时安装提供程序。
在 Win7/8 桌面操作系统上,这是默认安装的(我相信)。在服务器 Windows Server 2012 上,您必须启用该功能。
我在 Windows 2008 R2 + ASP.NET 中使用索引服务器的代码:
// Catalog Name
string strCatalog = txtNombreCatalogo.Text;
string strQuery = "";
strQuery = "Select DocTitle,Filename,Size,PATH,URL";
strQuery += ", DocAuthor, vpath, Write, Rank, Create, Characterization, DocCategory";
strQuery += " from Scope() where FREETEXT('" + txtNombreFichero.Text + "')";
// txtNombreFichero.Text is the word that you type in the text box to query by using Indexing Service.
string connstring = "Provider=MSIDXS;Integrated Security .='';Data Source=" + strCatalog;
//connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source=" + strCatalog;
var conn = new System.Data.OleDb.OleDbConnection(connstring);
conn.Open();
var cmd = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
var testDataSet = new System.Data.DataSet();
cmd.Fill(testDataSet, "SearchResults");
DataView source = new DataView(testDataSet.Tables[0]);
dgResultados.DataSource = source;
dgResultados.DataBind();