类 CmsSearchDirective

所有已实现的接口:
Directive, HttpDirective, freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel
直接已知子类:
CmsFacetSearchDirective

@Component public class CmsSearchDirective extends AbstractTemplateDirective
search 内容列表查询指令

上下文变量

  • lang:语言

参数列表

  • word:搜索词,多个搜索词时取并集结果
  • exclude:排除词汇
  • tagIds:多个标签id,多个标签时取并集结果
  • userId:用户id
  • parentId:父内容id
  • categoryId:分类id
  • containChild:包含子分类,当categoryId不为空时有效
  • categoryIds:多个分类id,当categoryId为空时有效
  • modelIds:多个模型id
  • extendsValues 多个全文搜索字段値,格式:[字段编码]:字段値],例如:extendsValues='isbn:value1,unicode:value2'
  • dictionaryValues 多个字典搜索字段値,只有数据字典父级値時包含所有子级结果,格式:[字段编码]_[字段値],例如:dictionaryValues='extend1_value1,extend1_value2'
  • dictionaryUnion 取数据字典并集结果,dictionaryUnion不为空时有效,【true,false】,默认为交集结果
  • highlight:高亮关键词,【true,false】,默认为false,启用高亮后, 标题、作者、编辑、描述字段应该加?no_esc以使高亮html生效,cms会自动对原值有进行html安全转义
  • preTag:高亮前缀,启用高亮时有效,默认为"<B>"
  • postTag:高亮后缀,启用高亮时有效,默认为"</B>"
  • projection:投影结果,【true,false】,默认为false
  • phrase:精确搜索,【true,false】,默认为false
  • fields:搜索字段,【title:标题, author:作者, editor:编辑, description:描述, text:正文,files:附件】
  • containsAttribute默认为false,http请求时为高级选项,为true时content.attribute为内容扩展数据map(字段编码,value)
  • startPublishDate:起始发布日期,【2000-01-01 23:59:59】,【2000-01-01】
  • endPublishDate:终止发布日期,【2000-01-01 23:59:59】,【2000-01-01】
  • orderField 排序字段,【clicks:点击数倒序,score:分数倒序,publishDate:发布日期倒序,collections:收藏数倒叙,minPrice:最低价格,maxPrice:最高价格,extend.sort1-extend.sort10]:扩展字段排序标志】,默认相关度倒序
  • pageIndex:页码
  • pageSize:每页条数
  • maxResults:最大结果数

返回结果

使用示例

<#assign lang="cn"/> <@cms.search word='cms' pageSize=10><#list page.list as a>${a.title}<#sep>,</#list></@cms.search>

  <script>
  fetch('${site.dynamicPath}api/directive/cms/search?word=cms&pageSize=10',{"headers":{"lang":"cn"}}).then(res => res.json()).then(data=>{
    console.log(data.page.totalCount);
  });
  </script>