public SearchResult getFirstResult() { if (CollectionUtils.isEmpty(fulltextSearchResults.getResults())) { throw new RuntimeException("results list is empty"); } return new SearchResult(fulltextSearchResults.getResults().get(0)); }
protected FulltextSearchResult readNextResult(final SearchCriterion... searchCriterions) throws UnexpectedInputException, ParseException, NonTransientResourceException { FulltextSearchResult result = null; if (!bufferedResultIterator.hasNext()) { bufferedResultIterator = read(searchCriterions).getResults().iterator(); } if (bufferedResultIterator.hasNext()) { result = bufferedResultIterator.next(); } return result; }
/** * Returns the list of SearchResult records * @return never returns null */ public List<SearchResult> getResults() { List<SearchResult> results = Lists.newArrayList(); for (FulltextSearchResult ftResult : fulltextSearchResults.getResults()) { results.add(new SearchResult(ftResult)); } return results; }
private void updateContext(FulltextSearchResults results) { cursorMark = results.getCursorMark(); baseIterator = results.getResults().iterator(); }
private List<FulltextSearchResult> performSearch(final String id, final String type) { final FulltextSearchQuery searchQuery = prepareSearchQuery(id, type); FulltextSearchResults results = index.performSearch(searchQuery); return results.getResults(); }
@RequestMapping(value = "/userCollections/{userId}", method = RequestMethod.GET) public String fetchUserCollections(@PathVariable final String userId, @RequestParam(value = "first", defaultValue = "0") final int first, @RequestParam(value = "pageSize", defaultValue = "20") final int pageSize, Model model) { FulltextSearchResults searchResults = performSearch(Collections.singletonMap(FIELD_USER_UID, userId), first, pageSize); List<SimpleCollectionData> result = transform(searchResults.getResults()); PageListCreator pageListCreator = new PageListCreator(10); PageList pageList = pageListCreator.createPageList(first, pageSize, searchResults.getCount()); model.addAttribute("collections", result); model.addAttribute("pageList", pageList); model.addAttribute("first", first); model.addAttribute("pageSize", pageSize); model.addAttribute("totalCount", searchResults.getCount()); model.addAttribute("queryElementId", userId); return "platform/store/userCollection"; }
@RequestMapping(value = "/collectionContent/{id:.+}", method = RequestMethod.GET) public String fetchUserData(@PathVariable final String id, @RequestParam(defaultValue=MODE_CONTENT) final String mode, @RequestParam(value="first", defaultValue="0") final int first, @RequestParam(value="pageSize", defaultValue="20") final int pageSize, Model model) throws IOException { FulltextSearchResults searchResults = performSearch(id, first, pageSize, mode); List<CollectionContentData> result; if (MODE_IN_COLLECTION.equals(mode)) { result = transformCollections(searchResults.getResults()); } else { result = transformContent(searchResults.getResults()); } PageListCreator pageListCreator = new PageListCreator(10); PageList pageList = pageListCreator.createPageList(first, pageSize, searchResults.getCount()); model.addAttribute("collectionContents", result); model.addAttribute("pageList", pageList); model.addAttribute("first", first); model.addAttribute("pageSize", pageSize); model.addAttribute("totalCount", searchResults.getCount()); model.addAttribute("mode", mode); model.addAttribute("queryElementId", id); return "platform/store/collection/content"; }
List<SimpleCollectionData> result = transform(searchResults.getResults());
private List<YElement> prepareChildrenByLevel(final FulltextSearchQuery searchQuery) { List<YElement> elements = new ArrayList<YElement>(); for (final FulltextSearchResult fulltextSearchResult : indexService.performSearch(searchQuery).getResults()) { for (final ResultField resultField : fulltextSearchResult.getFields()) { if (FIELD_EXID.equals(resultField.getName())) { YElement yElement = fetchYElement(resultField.getValues()[0]); if (null != yElement) { elements.add(yElement); } } } } return elements; }
@RequestMapping(value = "/fetchElementData/{id:.+}", method = RequestMethod.GET) public void fetchUserData(@PathVariable final String id, HttpServletResponse response) throws IOException { FulltextSearchResults searchResults = performSearch(Collections.singletonMap(FIELD_EXID, id), 0, 1); if(searchResults.getCount()==1){ new SimpleJsonResponseUtil().handleResponse(response, transform(searchResults.getResults().get(0))); }else{ new SimpleJsonResponseUtil().handleResponse(response, null); } }
private int addLinesByInterval(final StatsWriter writer, String dataset, final int beg, final int size) throws IOException { FulltextSearchResults results = statisticsGenerationUtils.fetchResultLines(dataset, beg, size); for (final FulltextSearchResult fulltextSearchResult : results.getResults()) { writer.saveSingleLine(statisticsGenerationUtils.transformToStats(fulltextSearchResult)); } logger.debug("Processed " + (beg + size) + " of " + results.getCount()); return results.getSize(); }
FulltextSearchResults results = indexService.performSearch(query); long queryDur = System.currentTimeMillis() - queryStart; for (final FulltextSearchResult fulltextSearchResult : results.getResults()) { for (final ResultField resultField : fulltextSearchResult.getFields()) { if (FIELD_EXID.equals(resultField.getName())) {
private void tryIndex() { int batchSize = 1000; ResultsFormat resultsFormat = new ResultsFormat(new FieldRequest(pl.edu.icm.synat.logic.index.publication.CollectionIndexFieldConstants.FIELD_EXID, true)); FulltextSearchQuery searchQuery = null; searchQuery = new FulltextSearchQuery(0, batchSize, resultsFormat, new FieldCriterion("level", "bwmeta1.level.hierarchy_Journal_Article", SearchOperator.AND)); List<FulltextSearchResult> results = indexService.performSearch(searchQuery).getResults(); for (FulltextSearchResult result : results) { System.out.println("docId: " + result.getDocId()); } }
List<FulltextSearchResult> resultList = results.getResults(); for (FulltextSearchResult fulltextSearchResult : resultList) { List<ResultField> fields = fulltextSearchResult.getFields();
List<FulltextSearchResult> resultList = results.getResults(); for (FulltextSearchResult fulltextSearchResult : resultList) { List<ResultField> fields = fulltextSearchResult.getFields();
List<FulltextSearchResult> resultList = results.getResults(); for (FulltextSearchResult fulltextSearchResult : resultList) { List<ResultField> fields = fulltextSearchResult.getFields();
FulltextSearchQuery query = new FulltextSearchQuery(start, searchedElementSize, resultsFormat, orderList, fieldCriterionList); FulltextSearchResults results = indexService.performSearch(query); for (final FulltextSearchResult fulltextSearchResult : results.getResults()) { for (final ResultField resultField : fulltextSearchResult.getFields()) { if (FIELD_EXID.equals(resultField.getName())) {
public List<PublicationMetadata> matchMetadata(SearchCriterion criterion, ResultMatcher[] matchers, PublicationMetadata template) { if (criterion == null) return Collections.emptyList(); ResultsFormat format = new ResultsFormat(new FieldRequest[] { new FieldRequest(MetadataIndexConstants.F_AUTHOR_NORM), new FieldRequest(MetadataIndexConstants.F_JOURNAL_TITLE), new FieldRequest(MetadataIndexConstants.F_NUMBER), new FieldRequest(MetadataIndexConstants.F_PAGE_FROM), new FieldRequest(MetadataIndexConstants.F_TITLE), new FieldRequest(MetadataIndexConstants.F_VOLUME), new FieldRequest(MetadataIndexConstants.F_YEAR) }); Set<PublicationMetadata> hits = new HashSet<PublicationMetadata>(); FulltextSearchQuery query = new FulltextSearchQuery(0, 100, format, criterion); FulltextSearchResults ci = fulltextIndex.performSearch(query); for (FulltextSearchResult result : ci.getResults()) { if (itemMatches(result, template, matchers)) { hits.add(documentBuilder.restore(result)); } } return new ArrayList<PublicationMetadata>(hits); }
public List<PublicationMetadata> matchIds(PublicationMetadata template) { List<PublicationId> ids = template.getIds(); if (ids == null) { ids = Collections.emptyList(); } if (ids.isEmpty()) return Collections.emptyList(); ResultsFormat format = new ResultsFormat(new FieldRequest[] { new FieldRequest(MetadataIndexConstants.F_AUTHOR_NORM), new FieldRequest(MetadataIndexConstants.F_JOURNAL_TITLE), new FieldRequest(MetadataIndexConstants.F_NUMBER), new FieldRequest(MetadataIndexConstants.F_PAGE_FROM), new FieldRequest(MetadataIndexConstants.F_TITLE), new FieldRequest(MetadataIndexConstants.F_VOLUME), new FieldRequest(MetadataIndexConstants.F_YEAR) }); Set<PublicationMetadata> hits = new HashSet<PublicationMetadata>(); BooleanCriterion criterion = new BooleanCriterion(); criterion.setOperator(SearchOperator.OR); for (PublicationId id : ids) { criterion.addCriterion(new FieldCriterion(MetadataIndexConstants.F_IDENTIFIER, idToString(id)), SearchOperator.OR); } FulltextSearchQuery query = new FulltextSearchQuery(0, 100, format, criterion); FulltextSearchResults ci = fulltextIndex.performSearch(query); for (FulltextSearchResult result : ci.getResults()) { PublicationMetadata metadata = documentBuilder.restore(result); hits.add(metadata); } return new ArrayList<PublicationMetadata>(hits); }
@Override public SearchResultsProto convertFrom(final FulltextSearchResults fromObject) { Builder builder = SearchResultsProto.newBuilder(); builder.setCount(fromObject.getCount()); builder.setFirst(fromObject.getFirst()); for (FulltextSearchResult singleSearchResult : fromObject.getResults()) { SearchResultProto resultProto = transformSingleResult(singleSearchResult); builder.addResults(resultProto); } builder.setFacetResult(transformFacetResult(fromObject.getFacetResult())); return builder.build(); }