logger.debug("Executed query [{}] in {} ms", query.getQuery(), response.getElapsedTime()); int totalHits = response.getResults().size(); if (!query.hasLimit() && totalHits >= maxResults) { logger.warn("Query result set truncated to first [{}] elements for query: {}", maxResults, query);
logger.debug("Executed query [{}] in {} ms", query.getCondition(), response.getElapsedTime()); int totalHits = response.getResults().size();
final SolrDocumentList documentList = response.getResults(); if (response.getResults().size() > 0) { final SolrDocument lastSolrDocument = documentList.get(response.getResults().size()-1); final String latestDateValue = df.format(lastSolrDocument.get(dateField)); final String newCursorMark = response.getNextCursorMark(); continuePaging.set(response.getResults().size() == Integer.parseInt(context.getProperty(BATCH_SIZE).getValue()));
flowFileResponse = session.putAllAttributes(flowFileResponse, responseAttributes); if (response.getResults().size() > 0) {
@Override public Document getLatest(String guid, String sensorType) throws IOException { if (MetaAlertConstants.METAALERT_TYPE.equals(sensorType)) { // Unfortunately, we can't just defer to the indexDao for this. Child alerts in Solr end up // having to be dug out. String guidClause = Constants.GUID + ":" + guid; SolrQuery query = new SolrQuery(); query.setQuery(guidClause) .setFields("*", "[child parentFilter=" + guidClause + " limit=999]"); try { QueryResponse response = solrDao.getSolrClient(solrDao.getZkHosts()) .query(METAALERTS_COLLECTION, query); // GUID is unique, so it's definitely the first result if (response.getResults().size() == 1) { SolrDocument result = response.getResults().get(0); return SolrUtilities.toDocument(result); } else { return null; } } catch (SolrServerException e) { throw new IOException("Unable to retrieve metaalert", e); } } else { return solrDao.getLatest(guid, sensorType); } }
@Override public int size() { int totalSize = list.size(); int intLimit = (int) this.limit; return intLimit > 0 && totalSize > intLimit ? intLimit : totalSize; } }
@Override public <S, R> List<R> read(@Nullable SolrDocumentList source, Class<R> type) { if (source == null) { return Collections.emptyList(); } List<R> resultList = new ArrayList<>(source.size()); for (SolrDocumentBase item : source) { resultList.add(read(type, item)); } return resultList; }
private static String toStr(SolrDocumentList lst, int maxSz) { if (lst.size() <= maxSz) return lst.toString(); StringBuilder sb = new StringBuilder("SolrDocumentList[sz=" + lst.size()); if (lst.size() != lst.getNumFound()) { sb.append(" numFound=").append(lst.getNumFound()); } sb.append("]="); sb.append(lst.subList(0, maxSz / 2).toString()); sb.append(" , [...] , "); sb.append(lst.subList(lst.size() - maxSz / 2, lst.size()).toString()); return sb.toString(); }
@Override public <S, R> List<R> read(@Nullable SolrDocumentList source, Class<R> type) { if (source == null) { return Collections.emptyList(); } List<R> resultList = new ArrayList<>(source.size()); TypeInformation<R> typeInformation = ClassTypeInformation.from(type); for (SolrDocumentBase item : source) { resultList.add(read(typeInformation, item)); } return resultList; }
public <T> List<T> getBeans(Class<T> clazz, SolrDocumentList solrDocList) { List<DocField> fields = getDocFields(clazz); List<T> result = new ArrayList<>(solrDocList.size()); for (SolrDocument sdoc : solrDocList) { result.add(getBean(clazz, fields, sdoc)); } return result; }
/*************************/ public ComplexResultIterator ( SolrDocumentList results ) { if ( results != null ) { numberOfResults = results.size ( ) ; iterator = results.iterator ( ) ; nextResult = iterator.hasNext ( ) ? getFieldValues ( ) : null ; } else { throw new IllegalArgumentException ( "You must pass a SolrDocumentList not null to create a ComplexResultIterator" ) ; } }
List<String> myList = new ArrayList(); SolrDocumentList results = response.getResults(); for (int i = 0; i < results.size(); ++i) { System.out.println(results.get(i)); myList.add(results.get(i)); }
public <T> List<T> getBeans(Class<T> clazz, SolrDocumentList solrDocList) { List<DocField> fields = getDocFields(clazz); List<T> result = new ArrayList<>(solrDocList.size()); for (SolrDocument sdoc : solrDocList) { result.add(getBean(clazz, fields, sdoc)); } return result; }
public SolrDocumentListIterator(SolrDocumentList solrDocumentList) { this.solrDocumentIterator = solrDocumentList.iterator(); this.numFound = solrDocumentList.getNumFound(); // SolrQuery has the start field of type int while SolrDocumentList of // type long. We are always querying with an int so we can't receive a // long as output. That's the reason why the following cast seems safe this.start = (int) solrDocumentList.getStart(); this.size = solrDocumentList.size(); }
public KoulutuksetVastaus convertSolrToKoulutuksetVastaus(SolrDocumentList solrKomotoList, Map<String, OrganisaatioPerustieto> orgs, String defaultTarjoaja) { KoulutuksetVastaus vastaus = new KoulutuksetVastaus(); for (int i = 0; i < solrKomotoList.size(); ++i) { SolrDocument curDoc = solrKomotoList.get(i); KoulutusPerustieto koulutus = convertKoulutus(curDoc, orgs, defaultTarjoaja); if (koulutus != null) { vastaus.getKoulutukset().add(koulutus); } } return vastaus; }
public HakukohteetVastaus convertSolrToHakukohteetVastaus(SolrDocumentList solrHakukohdeList, Map<String, OrganisaatioPerustieto> orgResponse, String defaultTarjoaja) { HakukohteetVastaus vastaus = new HakukohteetVastaus(); for (int i = 0; i < solrHakukohdeList.size(); ++i) { SolrDocument hakukohdeDoc = solrHakukohdeList.get(i); HakukohdePerustieto hakukohde = convertHakukohde(hakukohdeDoc, orgResponse, defaultTarjoaja); if (hakukohde != null) { vastaus.getHakukohteet().add(hakukohde); } } return vastaus; }
@Override public int getColumnCount() { if(response == null || response.getResults().size() == 0) { return 0; } return response.getResults().get(0).getFieldNames().size(); }
@Override public boolean hasNext() { try { final QueryResponse response = cloud.query(query); sentCursorMark = query.get("cursorMark"); nextCursorMark = response.getNextCursorMark(); page = response.getResults(); return page.size() > 0; } catch (final Exception exception) { throw new RuntimeException(exception); } }
public String[] search(final SolrQuery query, final String retrievedField) throws SolrServerException, IOException { final QueryResponse response = this.getServer().query(query); final SolrDocumentList docList = response.getResults(); final int size = docList.size(); final String docIDs[] = new String[size]; SolrDocument doc = null; for (int i = 0; i < size; i++) { doc = docList.get(i); docIDs[i] = (String) doc.getFieldValue(retrievedField); } return docIDs; }