private String runBigIdeas(Map<String, Set<String>> bigIdeaMap) { try { KiWiSearchCriteria ksc = getBigIdeasCriteria(); // bigIdea if (bigIdeaMap != null) ksc.setRdfObjectProperties(bigIdeaMap); Set<String> ts = ksc.getTypes(); for (Iterator iterator = selectedTypes.iterator(); iterator.hasNext(); ) { KiWiUriResource type = (KiWiUriResource) iterator.next(); ts.add(type.getKiwiIdentifier()); } ksc.setTypes(ts); searchResults = solrService.search(ksc); log.info(searchResults.getResults().size()); // set status facets if (searchResults != null) { bigIdeaFacets = buildBigIdeaFacet(); relevantTypes = buildRelevantTypes(); } else Collections.emptyList(); } catch (DkmsContentRetrievalException e) { searchResults = new KiWiSearchResults(); } return "search"; }
/** * Search function combining fulltext search, tag search, and author search. * * <p>We might need to expand this function for further criteria, particulary SPARQL, and possibly * for paging. * * @param searchQuery a lucene query string to use for fulltext search * @param searchTags a list of tag titles used in the search * @param searchAuthor the login of an author to search for * @return a list of content items matching the given search criteria */ public List<ContentItem> searchContentItems( String searchQuery, List<String> searchTags, String searchAuthor) { KiWiSearchCriteria criteria = new KiWiSearchCriteria(); if (searchQuery != null) criteria.setKeywords(searchQuery); if (searchTags != null) criteria.getTags().addAll(searchTags); if (searchAuthor != null) criteria.setPerson(searchAuthor); KiWiSearchResults results = solrService.search(criteria); LinkedList<ContentItem> _result = new LinkedList<ContentItem>(); for (SearchResult r : results.getResults()) { if (r.getItem() != null) { _result.add(r.getItem()); } } return _result; }
private KiWiSearchCriteria getBigIdeasCriteria() throws DkmsContentRetrievalException { KiWiSearchCriteria criteria = new KiWiSearchCriteria(); // set full search query string if (fullquery != null && !fullquery.equals("")) { if ("*".equals(fullquery)) { // criteria = solrService.parseSearchString(""); // criteria.setSolrSearchString("type:\"uri::http://www.artaround.at/ArtWork\" OR // type:\"uri::http://www.artaround.at/ArtAroundUser\""); criteria.setSolrSearchString("type:\"uri::http://www.dkms.at/DkmsContentItem\""); // criteria = solrService.parseSearchString("type:artaround:ArtWork"); // criteria.getTypes().add(tripleStore.createUriResource(Constants.ART_AROUND_CORE + // "ArtWork").getKiwiIdentifier()); // criteria.getTypes().add(tripleStore.createUriResource(Constants.NS_FOAF+"Person").getKiwiIdentifier()); } else { criteria = solrService.parseSearchString(fullquery); // criteria.setSolrSearchString("(type:\"uri::http://www.artaround.at/ArtWork\" OR // type:\"uri::http://www.artaround.at/ArtAroundUser\")"); criteria.setSolrSearchString("type:\"uri::http://www.dkms.at/DkmsContentItem\""); // criteria = solrService.parseSearchString(fullquery + " type:artaround:ArtWork"); } } else { throw new DkmsContentRetrievalException("no query defined"); } log.info("order #0", order); log.info("sort #0", sort); // set pages,limit etc. criteria.setOffset(page * PAGE_SIZE); criteria.setLimit(PAGE_SIZE); criteria.setSortField(sort); Set<String> s = new HashSet<String>(); s.add("http://www.dkms.at/bigIdeas"); criteria.setRdfObjectFacets(s); if (order.equals("asc")) criteria.setSortOrder(ORDER.asc); else criteria.setSortOrder(ORDER.desc); return criteria; }