【问题标题】:Advanced Search option Programatically Sharepoint Search高级搜索选项以编程方式共享点搜索
【发布时间】:2009-03-13 09:22:41
【问题描述】:

我正在使用目标代码模型从共享点搜索中检索搜索结果。任何人都可以建议我如何为我的搜索设置高级搜索选项。目标代码模型是否具有执行高级搜索的功能。

【问题讨论】:

    标签: sharepoint search object model


    【解决方案1】:

    是的,您可以使用FullTextSqlQuery 类执行高级搜索,如下面的代码示例所示。另见Best Practices: Writing SQL Syntax Queries for Relevant Results in Enterprise Search

    using (SPSite site = new SPSite("http://server"))   // Site Collection URL
    using (FullTextSqlQuery query = new FullTextSqlQuery(site))
    {
      query.ResultTypes = ResultType.RelevantResults;
      query.EnableStemming = true;
      query.TrimDuplicates = true;
      query.Culture = new CultureInfo(1033);    // Use en-US stemmer and word-breaker
      query.RowLimit = 40;
      query.StartRow = 0;
      query.KeywordInclusion = KeywordInclusion.Allkeywords;   // Implicit AND search
      query.HighlightedSentenceCount = 3;
      query.SiteContext = new Uri("http://server");  // Site Collection URL
      query.QueryText = "SELECT WorkId, Title, Path, HitHighlightedSummary, HitHighlightedProperties, CollapsingStatus, Description, Rank, Size" +
                         " FROM SCOPE()" +
                         " WHERE \"scope\" = 'A Scope'" +
                         " AND FREETEXT(defaultproperties, 'keyword1 keyword2')" +
                         " AND Color = 'Black'" + // Color is a managed property
                         " ORDER BY Rank DESC";            
    
      ResultTableCollection results = query.Execute();
      ResultTable relevantResults = results[ResultType.RelevantResults];
    
      // TODO: Process results
    };
    

    【讨论】:

    • 工作正常...但我需要获取托管属性的结果,这些属性映射到业务数据的已爬网属性,默认名称为“LOBSystemName.EntityName.ColumnName”,显示错误...可以任何人都可以帮助
    • 您能否更具体地说明您遇到的错误?在上面的代码中,您只需将托管属性的名称添加到 SELECT 后的逗号分隔的属性列表中。
    猜你喜欢
    • 2013-08-07
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多