Page History
...
- Easy Configuration, adding facets is easy through access to solr fields and teh possibility to facet on evrything that is indexed.
- Facet/Categorize on all fields submitted to the index and for all content inside the index ( DMS/DATA, WEBSITE, Third party )
- Do keyword based searches in faceted content, get the current facets for a specific keyword search.
- The above keyword search gives the associated categories that are available for teh specific search, refining is possible by clicking again on one of the items, for instance clicking on IT Systems will give us teh only result matching IT-Systems and "Magnolia Presentation".
- Do range faceting ( price/dates) propose a general search interface for product/e-commerce sites.
- Be able to provide user context content paths, a diagram on how to use this is available below.maybe this could be another concept page on its own.
- First all content is categorized, each content must have at least one user profile categorization ( developer, marketing, buyer, ...)
- Then, navigation is done through solr's faceted search.Based on a few initial choices, different layouts can be proposed after each refining.
Proposed architecture
We will try to make things as generic as possible, to be able to use as well other search providers, we extend the ExtSearchResultModel Class with the FacetedSearchResultModel Class which will only contain the specific getters/setters for faceting.
How do we push the categories to the index ?
...
Code Block | ||
---|---|---|
| ||
private final static String XpathData = "//*[((@jcr:primaryType='slideshow-resource') or (@jcr:primaryType='video-resource'))]"; /* (non-Javadoc) * @see info.magnolia.commands.MgnlCommand#execute(info.magnolia.context.Context) */ @Override public boolean execute(Context context) throws Exception { Session session = context.getJCRSession("data"); QueryManager qm = session.getWorkspace().getQueryManager(); Query query = qm.createQuery(XpathData, "xpath"); NodeIterator nodeIt = query.execute().getNodes(); /** * This call is important since we ask access to the search provider instance * */ SearchService<?, ?, ?, String> svc = EsUtil.getProviderInstance(); while(nodeIt.hasNext()){ Node current = nodeIt.nextNode(); Map<String,String>things = this.prepareThings(current, session); if(things!=null){ svc.addUpdate(RepositoryEntries.DAM.name(), things); } } return true; } private Map<String,String> prepareThings(Node current,Session session){ Map<String,String>things = new HashMap<String,String>(); ContentMap mp = new ContentMap(current); Map<String,List<String>> categorySet = extractCategories(((String[])mp.get("categories")),session); //put categories /** * Here we already give the correct syntax for usage with solr, * This is not ok since this class should be agnostic, we can overcome this by creating a generic format and converters for each format in the provider package's logic * */ for(String facet:categorySet.keySet()){ things.put("literal.category_"+facet,StringUtils.join(categorySet.get(facet),",")); } String abstrakt = (String)mp.get("abstract"); things.put("literal.abstract", abstrakt); String itemType = (String) mp.get("itemtype"); things.put("literal.type", itemType); String link = (String) mp.get("link"); things.put("literal.htmllink", link); String url = extractURL(link); things.put("literal.url", url); String id=null; try { id = URLEncoder.encode(url,"UTF-8"); } catch (UnsupportedEncodingException e) { log.warn("could not encode id"+e.getMessage()); return null; } things.put("literal.id", id); String name = (String) mp.get("name"); things.put("literal.title", name); log.debug(name+"<======>"+url+"<=====>"+StringUtils.join(categorySet.values(),"-")); //cr:lastModified,width,nodeDataTemplate,jcr:data,depth,jcr:uuid,size,extension,id,height,name,path,jcr:mimeType,fileName,nodeType,jcr:primaryType String thumbnail = (String) ((ContentMap)mp.get("thumbnail")).get("name"); log.debug("node's thumbnail name:"+thumbnail); return things; } private String extractURL(String link) { Pattern p = Pattern.compile("href=\"([^\"]*)\"|src=\"([^\"]*)\"", Pattern.DOTALL); Matcher m = p.matcher(link); String url = null; if (m.find()) { for(int i=0;i<m.groupCount();i++){ if(m.group(i)!=null){ int a = m.group(i).indexOf("http"); url = m.group(i).substring(a); url = url.replaceAll("\"", ""); } } } if(url==null){ if(link.startsWith("http")){ url=link; } } return url; } private Map<String,List<String>> extractCategories(String [] nodes,Session session){ Map<String,List<String>> categorySet = new HashMap<String,List<String>>(); for(String nodeId:nodes){ Node category; try { category = session.getNodeByIdentifier(nodeId); String facet = category.getParent().getName(); String tag = category.getName(); if(categorySet.containsKey(facet)){ categorySet.get(facet).add(tag); }else{ List<String>values=new ArrayList<String>(); values.add(tag); categorySet.put(facet, values); } } catch (ItemNotFoundException e) { log.warn(e.getMessage() + " not found as category"); } catch (RepositoryException e) { log.error(e.getMessage()); } } return categorySet; } |
Overview
Content Tools