我目前正在使用以下代码在Tridion中进行搜索。它根据输入获取项目(组件和页面)。
问题:在富文本字段中,我们有“设计”,“源”和“预览”选项卡。以下代码仅搜索“设计”选项卡中的内容。我也需要Source选项卡内容 在执行搜索时要考虑。
CoreServiceSession client = new CoreServiceSession();
SessionAwareCoreServiceClient csClient = client.GetClient();
var find = new SearchQueryData
{
Description = "Universe"
ItemTypes = new ItemType[] { ItemType.Page, ItemType.Component }
);
IdentifiableObjectData[] foundItems = csClient.GetSearchResults(find);
答案 0 :(得分:5)
您是否尝试使用 FullTextQuery
CoreServiceSession client = new CoreServiceSession();
SessionAwareCoreServiceClient csClient = client.GetClient();
ReadOptions readoption = new ReadOptions();
var find = new SearchQueryData
{
Description = "Universe"
FullTextQuery= "Universe"
ItemTypes = new ItemType[] { ItemType.Component }
);
IdentifiableObjectData[] foundItems = csClient.GetSearchResults(find);
由于FullTextQuery可能会影响您的CMS性能,因此您可能希望它仅限于特定架构组件字段。
BasedOnSchemaData basedSchemaNote = new BasedOnSchemaData();
basedSchemaNote.Schema = new LinkToSchemaData() { IdRef = "tcm:XX-xxxx-8" };
basedSchemaNote.Field = "FieldName";
basedSchemaNote.FieldValue = "*SeachText*";