索引服务空文件名属性

发布于 2024-12-22 08:23:51 字数 361 浏览 0 评论 0原文

我是第一次使用 Windows 索引服务,我需要从查询中返回文档标题和文件名。

我的查询是;

select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '" & searchText & "') order by rank desc

我设置了一个相当基本的目录,仅指向一个文件夹。我正在使用网站上的代码,文件位于本地计算机上,身份验证应该不成问题。

我的搜索返回结果,但文件名属性中没有任何内容。文档标题已填充,但没有其他内容。

谢谢, 麦克风

I'm using the Windows Indexing Service for the first time and I need to return the doctitle and filename from the query.

My query is;

select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '" & searchText & "') order by rank desc

I setup a fairly basic catalogue just pointing to a folder. I'm using this code from a website, the files are on the local machine and authentication shouldn't be a problem.

My search returns results but nothing in the filename property. The doctitle is populated but nothing else.

Thanks,
Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光磨忆 2024-12-29 08:23:51

我知道这个问题已经有几个月了,但我目前正在 Windows Server 2008 R2 上使用 C# 使用 WIS,并在搜索中发现了这个问题。有时我无法接受“不”的答案,所以我在互联网上搜索并想出了这个解决方案。

我确信您可以根据需要转换代码,但是...

您必须从服务器管理器的角色安装 Windows Server 2003 文件服务索引服务。

对于目录属性,我禁用了可继承设置并相应地设置了 WWW 服务器。我还生成了 250 个字符的摘要,存储在“特征”列中。

当我设置目录时,我包含/排除了网站目录的某些文件夹(包括网站根目录),当我查询它时,我使用了以下 SQL 语句:

编辑: 注意使用FREETEXT(Filename, '\""+q+"\"')) 查询文件的名称

String fileTypes = "\".aspx\" OR \".doc*\" OR \".xls*\" OR \".ppt*\" OR \".txt\" OR \".pdf\" OR \".rtf\"";
String q = query.Text.Replace("'", "''");   

sSqlString = "SELECT Filename, DocTitle, Size, VPath, Path, Rank, Write, Contents, Characterization ";
sSqlString += "FROM SCOPE() ";
sSqlString += "WHERE (CONTAINS(Contents, '\""+q+"\"') ";
sSqlString += "OR FREETEXT(Filename, '\""+q+"\"')) ";
sSqlString += "AND CONTAINS(Filename, '"+fileTypes+"') ";
sSqlString += "ORDER BY rank DESC, write DESC";

我使用 using 语句创建连接:

using(OleDbConnection conn = new OleDbConnection("Provider=MSIDXS.1;Data Source='"+catalog+"'"))
{
    //your connection and data collection code here
}

我遇到的问题之一是某些文件类型。如果文档创建者未在其 MS Office 产品中包含文档标题,您将无法获得 DocTitle。如果 pdf 中没有任何可识别的文本并且未填写文档属性,则 docTitle 和 Content 将为空。我的看法是,如果企业不使其文件符合 508 标准,它们就不会正确显示在结果中。

这是我正在使用的 ListView 模板的快速片段。

<ItemTemplate>
    <h3><a href="<%# vFilePath(Eval("Path")) %>"><%# Eval("DocTitle").ToString().Trim() == "" ? Eval("Filename").ToString().Split('.')[0] : ProperCase(Eval("DocTitle").ToString()) %></a></h3>
    <p><span style="color:#0083be;">
        <%# Request.ServerVariables["HTTP_HOST"].Length+vFilePath(Eval("Path")).Length > 100 ? (Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path"))).Substring(0,100)+"..." : Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path")) %></span><br />
        <span style="color:#4d4e53"><%# String.Format("{0:MMMM dd, yyyy}",Eval("Write")) %> - </span>
        <%# Eval("Characterization").ToString().Trim() == "" ? "..." : Eval("Characterization").ToString().Length == 250 ? 
        Eval("Characterization").ToString().Substring(0,250)+"..." : Eval("Characterization")%>
    </p>                
</ItemTemplate>

由于我的例子中的 docTitle 用于结果标题,因此我认为如果它为空,我可以采用该空字符串并将其替换为文件名,减去扩展名。

进行查询时,请确保您还使用关键字和描述正确使用元标记。 WIS 会读取该内容以及 .aspx 页面上的静态内容。您会注意到我使用特征化来检索内容。

链接提供了有关设置 W2k8 WIS 以及 vb.net 代码的说明。

链接是众多属性的良好来源可以查询和/或显示。

I know it's been a few months since this has been answered, but I'm currently using WIS on Windows Server 2008 R2 using C# and came across this on a search. Sometimes I can't take no for an answer, so I had scoured the internet and came up with this solution.

I'm sure you can convert the code as necessary, but...

You'll have to install the Windows Server 2003 File Services Indexing Service from the Server Manager's Roles.

For the catalog properties, I disabled the Inheritable Settings and set the WWW Server appropriately. I also generated 250 character abstracts to be stored in the Characterization column.

When I set up my catalog, I included/excluded certain folders of my web site's directory (include the site root) and when I queried it, I used the below SQL statement:

EDIT: Note the use of FREETEXT(Filename, '\""+q+"\"')) to query the name of the file

String fileTypes = "\".aspx\" OR \".doc*\" OR \".xls*\" OR \".ppt*\" OR \".txt\" OR \".pdf\" OR \".rtf\"";
String q = query.Text.Replace("'", "''");   

sSqlString = "SELECT Filename, DocTitle, Size, VPath, Path, Rank, Write, Contents, Characterization ";
sSqlString += "FROM SCOPE() ";
sSqlString += "WHERE (CONTAINS(Contents, '\""+q+"\"') ";
sSqlString += "OR FREETEXT(Filename, '\""+q+"\"')) ";
sSqlString += "AND CONTAINS(Filename, '"+fileTypes+"') ";
sSqlString += "ORDER BY rank DESC, write DESC";

I create my connection using the using statement:

using(OleDbConnection conn = new OleDbConnection("Provider=MSIDXS.1;Data Source='"+catalog+"'"))
{
    //your connection and data collection code here
}

One of the issues that I have run into is with certain filetypes. If the document creator didn't include a document title in their MS Office product, you won't get the DocTitle. If the pdf doesn't have any recognizable text in it and the document properties are not filled out, the docTitle and Content will be empty. The way I look at it, is if the business doesn't make their files 508 compliant, they won't show up in the results properly.

Here's a quick snippet of the ListView template that I am using.

<ItemTemplate>
    <h3><a href="<%# vFilePath(Eval("Path")) %>"><%# Eval("DocTitle").ToString().Trim() == "" ? Eval("Filename").ToString().Split('.')[0] : ProperCase(Eval("DocTitle").ToString()) %></a></h3>
    <p><span style="color:#0083be;">
        <%# Request.ServerVariables["HTTP_HOST"].Length+vFilePath(Eval("Path")).Length > 100 ? (Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path"))).Substring(0,100)+"..." : Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path")) %></span><br />
        <span style="color:#4d4e53"><%# String.Format("{0:MMMM dd, yyyy}",Eval("Write")) %> - </span>
        <%# Eval("Characterization").ToString().Trim() == "" ? "..." : Eval("Characterization").ToString().Length == 250 ? 
        Eval("Characterization").ToString().Substring(0,250)+"..." : Eval("Characterization")%>
    </p>                
</ItemTemplate>

Since the docTitle in my case is used for the results header, I figured that if it's empty, I can take that empty string and replace it with the filename, minus the extention.

When making the query, make sure that you also properly use your meta tags using the keywords and description. This and the static content on the .aspx pages does get read by WIS. You'll note my use of Characterization to retrieve the contents.

This link provides instructions on setting up the W2k8 WIS along with vb.net code.

This link is a good source for the multitude of properties that can be queried and/or displayed.

单身情人 2024-12-29 08:23:51

我在这篇文章中找到了答案;
http://support.microsoft.com/kb/954822

您无法为 Internet 信息服务 (IIS) 网站编制索引
Windows Server 2008 由于设计更改
IIS 7.0。

索引服务的后继者是Windows Search。
Windows Search Wiki

看来我必须更改站点才能使用 Windows Search。

I found the answer in this article;
http://support.microsoft.com/kb/954822

You cannot index Internet Information Services (IIS) Web sites in
Windows Server 2008 because of the design changes that were made to
IIS 7.0.

The successor or the Indexing Service is Windows Search.
Windows Search Wiki

Looks like I'm going to have to change the site to use Windows Search.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文