@Component public class CmsSearchDirective extends AbstractTemplateDirective
参数列表
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
:最大结果数
返回结果
page
:PageHandler
page.list
:List类型 查询结果实体列表
CmsContent
<@cms.search word='cms' pageSize=10><#list page.list as a>${a.title}<#sep>,</#list></@cms.search>
<script> $.getJSON('${site.dynamicPath}api/directive/cms/search?word=cms&pageSize=10', function(data){ console.log(data.page.totalCount); }); </script>
限定符和类型 | 字段和说明 |
---|---|
private CmsContentAttributeService |
attributeService |
protected ContentConfigComponent |
contentConfigComponent |
protected FileUploadComponent |
fileUploadComponent |
private CmsContentService |
service |
private StatisticsComponent |
statisticsComponent |
ADVANCED, AUTH_TOKEN, AUTH_USER_ID, siteComponent
log
构造器和说明 |
---|
CmsSearchDirective() |
限定符和类型 | 方法和说明 |
---|---|
void |
execute(RenderHandler handler) |
PageHandler |
query(RenderHandler handler,
boolean factSearch) |
execute, expose, getAdvanced, getApp, getSite, getUserId, needAppToken, needUserToken, supportAdvanced
execute, getName, getNamespace, getShortName, httpEnabled, setName, setNamespace, setShortName
private CmsContentAttributeService attributeService
private StatisticsComponent statisticsComponent
protected ContentConfigComponent contentConfigComponent
protected FileUploadComponent fileUploadComponent
private CmsContentService service
public void execute(RenderHandler handler) throws java.io.IOException, freemarker.template.TemplateException
java.io.IOException
freemarker.template.TemplateException
public PageHandler query(RenderHandler handler, boolean factSearch) throws freemarker.template.TemplateModelException
freemarker.template.TemplateModelException