Search 如何在AEM搜索组件中使用多个路径
我正在定制OOTB AEM 6.0搜索组件。我需要传递多个路径,而不是一个路径到搜索对象。有人试过吗?另外,当我将搜索属性设置为包含“hideInNav”时,它不会正确过滤页面。换句话说,结果页面仍然包括那些在导航中设置为隐藏的页面。请让我知道如何回避这个问题。非常感谢。您可以在“indexing_config.xml”中添加自定义索引配置,以限制搜索范围。参考URL:。你已经做过了 在导航中隐藏页面时,hideInNav的值将设置为true 在search.jsp文件中,如果'hideInNav'=true,则可以设置条件,然后在搜索结果中不显示相同的条件 自定义组件Search 如何在AEM搜索组件中使用多个路径,search,aem,Search,Aem,我正在定制OOTB AEM 6.0搜索组件。我需要传递多个路径,而不是一个路径到搜索对象。有人试过吗?另外,当我将搜索属性设置为包含“hideInNav”时,它不会正确过滤页面。换句话说,结果页面仍然包括那些在导航中设置为隐藏的页面。请让我知道如何回避这个问题。非常感谢。您可以在“indexing_config.xml”中添加自定义索引配置,以限制搜索范围。参考URL:。你已经做过了 在导航中隐藏页面时,hideInNav的值将设置为true 在search.jsp文件中,如果'hideInNa
您可以编写自定义搜索组件,使用SQL2查询存储库,并在其中定义多个路径。您可以在“indexing_config.xml”中添加自定义索引配置,以限制搜索范围。参考URL:。你已经做过了 在导航中隐藏页面时,hideInNav的值将设置为true 在search.jsp文件中,如果'hideInNav'=true,则可以设置条件,然后在搜索结果中不显示相同的条件 自定义组件
您可以编写自定义搜索组件,使用SQL2查询存储库,并在其中定义多个路径。您可以在“indexing_config.xml”中添加自定义索引配置,以限制搜索范围。参考URL:。你已经做过了 在导航中隐藏页面时,hideInNav的值将设置为true 在search.jsp文件中,如果'hideInNav'=true,则可以设置条件,然后在搜索结果中不显示相同的条件 自定义组件
您可以编写自定义搜索组件,使用SQL2查询存储库,并在其中定义多个路径。您可以在“indexing_config.xml”中添加自定义索引配置,以限制搜索范围。参考URL:。你已经做过了 在导航中隐藏页面时,hideInNav的值将设置为true 在search.jsp文件中,如果'hideInNav'=true,则可以设置条件,然后在搜索结果中不显示相同的条件 自定义组件
您可以编写自定义搜索组件,使用SQL2查询存储库,并在其中定义多个路径。您可以使用multifield()和一些pathfield计数 并使用查询生成器API处理输入的路径。
或者,您可以使用处理路径。您可以使用multifield()和一些pathfield计数 并使用查询生成器API处理输入的路径。
或者,您可以使用处理路径。您可以使用multifield()和一些pathfield计数 并使用查询生成器API处理输入的路径。
或者,您可以使用处理路径。您可以使用multifield()和一些pathfield计数 并使用查询生成器API处理输入的路径。
或者您可以使用处理路径。我们通过复制股票搜索组件代码来实现这一点,将searchIn路径更改为列表而不是字符串,并更新对话框以接受多个路径。我们使用cylinder.y引用的QueryBuilderAPI示例来验证我们的查询 dialog.xml
<searchPaths
jcr:primaryType="cq:Widget"
fieldLabel="Search Path"
name="./searchPaths"
xtype="multifield">
<fieldConfig
jcr:primaryType="nt:unstructured"
xtype="pathfield"/>
</searchPaths>
jsp-MultiSearch是我们复制的新组件
MultiSearch search = new MultiSearch(slingRequest);
String[] searchPaths = properties.get("searchPaths", new String[]{});
List<String> searchPathsList = Arrays.asList(searchPaths);
search.setSearchIn(searchPathsList);
MultiSearch search=新的MultiSearch(slingRequest);
String[]searchpath=properties.get(“searchpath”,新字符串[]{});
List searchPathsList=Arrays.asList(searchPaths);
search.setSearchIn(searchPathsList);
恳求
public SearchResult getResult()引发RepositoryException{
if(this.result==null){
字符串queryString=getQuery();
if((queryString.length()=0)&&(this.customPredicates.size()=0)){
返回null;
}
Map Map=newhashmap();
map.put(“group.p.or”、“true”);//组(路径/属性)上的“搜索”或“条件”
map.put(“全文”,queryString);//查询
List searchpath=getSearchIn();
int searchPathsLen=searchpath.size();
int searchPropertiesLen=this.searchProperties.size();
布尔类型覆盖=false;
for(谓词p:this.customPredicates){
if(“type”.equals(p.getName())){
typeOverwrite=true;
打破
}
}
如果(!typeOverwrite){
map.put(“type”,“nt:hierarchyNode”);
}
if(queryString.startsWith(“related:”){
for(int i=0;ipublic SearchResult getResult() throws RepositoryException {
if (this.result == null) {
String queryString = getQuery();
if ((queryString.length() == 0) && (this.customPredicates.size() == 0)) {
return null;
}
Map<String, String> map = new HashMap();
map.put("group.p.or", "true"); //Search "or" condition on groups (paths / properties)
map.put("fulltext", queryString); //query
List<String> searchPaths = getSearchIn();
int searchPathsLen = searchPaths.size();
int searchPropertiesLen = this.searchProperties.size();
boolean typeOverwrite = false;
for (Predicate p : this.customPredicates) {
if ("type".equals(p.getName())) {
typeOverwrite = true;
break;
}
}
if (!typeOverwrite) {
map.put("type", "nt:hierarchyNode");
}
if (queryString.startsWith("related:")) {
for (int i = 0; i < searchPathsLen; i++){
String searchPath = searchPaths.get(i);
map.put("group." + i + "_path", searchPath);
}
String path = queryString.substring("related:".length());
map.put("similar", path + "/" + "jcr:content");
map.put("similar.local", "jcr:content");
} else {
for (int i = 0; i < searchPathsLen; i++){
String searchPath = searchPaths.get(i);
for (int j = 0; j < searchPropertiesLen; j++){
String prop = searchProperties.get(j);
int counter = i * searchPropertiesLen + j;
map.put("group." + counter + "_path", searchPath);
StringBuffer path = new StringBuffer();
path.append("jcr:content");
if (!prop.equals(".")) {
String[] segments = Text.explode(prop, 47);
for (int k = 0; k < segments.length; k++) {
path.append("/");
if (k == segments.length - 1) {
path.append("@");
}
path.append(segments[k]);
}
}
map.put("group." + counter + "_fulltext.relPath", path.toString());
}
}
}
Query query = this.builder.createQuery(PredicateGroup.create(map), getSession());
for (Predicate p : this.customPredicates) {
query.getPredicates().add(p);
}
query.setExcerpt(true);
query.setStart(this.start);
query.setHitsPerPage(this.hitsPerPage);
this.result = query.getResult();
}
return this.result;
}