Kentico 智能搜索索引 - 有什么方法可以用 API 阅读它?

Kentico Smart Search Index - any way to read it with the API?

我们需要一个基于 Kentico 搜索索引的搜索框自动完成功能,但一半网站在 CMS 应用程序页面中,一半在 MVC 中。因此,自动完成 Web 部件适用于 CMS 应用程序页面,但不适用于 MVC 应用程序页面。

我们正在探索的一个选项是在站点的两侧使用 Twitter Typeahead js 库,这要求搜索词位于 json 文件中。

所以我们希望能够通过 Kentico API 加载搜索索引词,然后将其写入 json 文件。

SearchIndexInfo object 似乎无法获取写入索引文件的索引术语。

更新

澄清一下:我们可以通过 API 进行搜索,但搜索结果项只有 return 带有标题和内容字段,它们不包含存储在中的所有搜索词索引文件。

例如,自定义页面类型的搜索索引可能会基于文档名称、说明、位置、城市、公司名称、设计类别字段构建索引。所有这些都将存储在某个地方的索引中,那么我们如何读取存储在索引中的术语呢?

不只是结果,它只有文档名称(标题)和描述(内容)。

我们基本上是在尝试将搜索索引文件转换为 json 表示,而不是搜索结果。

当然,如果 SmartSearchDialog Web 部件仅在标题和内容字段上进行预测搜索,那么我们就这样做,但我相信 SmartSearchDialog 会进行实际搜索,不是吗?

谢谢

有API个:

// Gets the search index
SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("NewIndex");

if (index != null)
{
    // Prepares the search parameters
    SearchParameters parameters = new SearchParameters()
    {
        SearchFor = "home",
        SearchSort = "##SCORE##",
        Path = "/%",
        ClassNames = "",
        CurrentCulture = "EN-US",
        DefaultCulture = CultureHelper.EnglishCulture.IetfLanguageTag,
        CombineWithDefaultCulture = false,
        CheckPermissions = false,
        SearchInAttachments = false,
        User = (UserInfo)MembershipContext.AuthenticatedUser,
        SearchIndexes = index.IndexName,
        StartingPosition = 0,
        DisplayResults = 100,
        NumberOfProcessedResults = 100,
        NumberOfResults = 0,
        AttachmentWhere = String.Empty,
        AttachmentOrderBy = String.Empty,
    };

    // Performs the search and saves the results into a DataSet
    System.Data.DataSet results = SearchHelper.Search(parameters);

    if (parameters.NumberOfResults > 0)
    {
        // The search found at least one matching result, and you can handle the results

    }
}

更多详情here

Roman 在评论中的回答看起来不太行,在进一步考虑时,我们可能试图做一些过于复杂的事情,并且可能没有提出正确的问题。

与其尝试复制 json 中的搜索索引供 Twitter 预输入自动完成使用,或许更好的方法是保持简单,只使用搜索结果的标题和内容字段.

然后,为了将额外的字段添加到搜索结果的内容字段中(例如项目位置),我们可以自定义搜索构建代码 (CMSLoaderAttribute) 以将额外的字段添加到 SearchDocument 的内容字段中。