如何执行 MOSS FullTextSqlQuery 并按技能托管属性筛选人员结果?

发布于 2024-08-21 17:42:23 字数 933 浏览 3 评论 0原文

当我尝试使用 CONTAINS 谓词过滤技能托管属性上的人员结果时,我遇到了 MOSS FulltextSqlQuery 的问题。让我演示一下:

没有过滤器的查询返回预期结果:

SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')

结果

Total Rows: 1
ACCOUNTNAME: MYDOMAIN\Bob
SKILLS: Numchucks | ASP.Net | Application Architecture

但是当我附加 CONTAINS 谓词时,我不再获得预期结果:

SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks'))

结果

Total Rows: 0

我确实意识到我可以使用 SOME ARRAY 谓词来完成此操作,但我想知道为什么这不适用于 Skills 属性的 CONTAINS 谓词。我已成功将 CONTAINS 谓词与指示为“多值”的自定义已爬网属性结合使用。 SSP 管理站点的“已爬网属性”页面上未显示“技能”属性(尽管它似乎是多值的):

http:///ssp/admin/_layouts/schema.aspx?ConsoleView=crawledPropertiesView&category=人们

有什么想法吗?

I am having trouble with a MOSS FulltextSqlQuery when attempting to filter People results on the Skills Managed Property using the CONTAINS predicate. Let me demonstrate:

A query with no filters returns the expected result:

SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')

Result

Total Rows: 1
ACCOUNTNAME: MYDOMAIN\Bob
SKILLS: Numchucks | ASP.Net | Application Architecture

But when I append a CONTAINS predicate, I no longer get the expected result:

SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks'))

Result

Total Rows: 0

I do realize I can accomplish this using the SOME ARRAY predicate, but I would like to know why this is not working with the CONTAINS predicate for the Skills property. I have been successful using the CONTAINS predicate with a custom crawled property that is indicated as 'Multi-valued'. The Skills property (though it seems to be multi-valued) is not indicated as such on the Crawled Properties page in the SSP admin site:

http:///ssp/admin/_layouts/schema.aspx?ConsoleView=crawledPropertiesView&category=People

Anyone have any ideas?

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

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

发布评论

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

评论(2

梦明 2024-08-28 17:42:23

因此,在 Mark Cameron(Microsoft SharePoint 开发人员支持)的帮助下,我发现必须通过将 FullTextQueriable 属性设置为 true,才能使用 ManagedProperty 对象模型 API 启用某些托管属性以进行全文搜索。下面是为我解决这个问题的方法。它可以包含在控制台应用程序中或作为 Farm 或 Web 应用程序范围的功能接收器。

    using Microsoft.Office.Server;
    using Microsoft.Office.Server.Search.Administration;

    private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext)
    {
        var schema = new Schema(SearchContext.GetContext(serverContext));
        var managedProperties = new[] { "SKILLS", "INTERESTS" };
        foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
        {
            if (!managedProperties.Contains(managedProperty.Name.ToUpper()))
                continue;

            if (managedProperty.FullTextQueriable)
                continue;

            try
            {
                managedProperty.FullTextQueriable = true;
                managedProperty.Update();
                Log.Info(m => m("Successfully set managed property {0} to be FullTextQueriable", managedProperty.Name));
            }
            catch (Exception e)
            {
                Log.Error(m => m("Error updating managed property {0}", managedProperty.Name), e);
            }
        }
    }

So with the help of Mark Cameron (Microsoft SharePoint Developer Support), I figured out that certain managed properties have to be enabled for full text search using the ManagedProperty object model API by setting the FullTextQueriable property to true. Below is the method that solved this issue for me. It could be included in a Console app or as a Farm or Web Application scoped Feature Receiver.

    using Microsoft.Office.Server;
    using Microsoft.Office.Server.Search.Administration;

    private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext)
    {
        var schema = new Schema(SearchContext.GetContext(serverContext));
        var managedProperties = new[] { "SKILLS", "INTERESTS" };
        foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
        {
            if (!managedProperties.Contains(managedProperty.Name.ToUpper()))
                continue;

            if (managedProperty.FullTextQueriable)
                continue;

            try
            {
                managedProperty.FullTextQueriable = true;
                managedProperty.Update();
                Log.Info(m => m("Successfully set managed property {0} to be FullTextQueriable", managedProperty.Name));
            }
            catch (Exception e)
            {
                Log.Error(m => m("Error updating managed property {0}", managedProperty.Name), e);
            }
        }
    }
笨笨の傻瓜 2024-08-28 17:42:23
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks*'))

最后使用*。

您还可以尝试以下几个选项:

以下列表标识
附加查询元素是
仅支持 SQL 搜索语法
使用 FullTextSqlQuery 类:

FREETEXT()

包含()

喜欢

SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks*'))

use the * in the end.

You also have a few more options to try:

The following list identifies
additional query elements that are
supported only with SQL search syntax
using the FullTextSqlQuery class:

FREETEXT()

CONTAINS()

LIKE

Source

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