private void doSearch1(SolrDocumentList results, SolrIndexSearcher searcher, String q, Filter filter, int ndocs, SolrQueryRequest req, Map<String,SchemaField> fields, Set<Integer> alreadyFound) throws IOException { // build custom query and extra fields Query query = null; //buildCustomQuery1(q); Map<String,Object> extraFields = new HashMap<String,Object>(); extraFields.put("search_type", "search1"); boolean includeScore = req.getParams().get(CommonParams.FL).contains("score"); int maxDocsPerSearcherType = 0; float maprelScoreCutoff = 2.0f; append(results, searcher.search( query, filter, maxDocsPerSearcherType).scoreDocs, alreadyFound, fields, extraFields, maprelScoreCutoff , searcher.getIndexReader(), includeScore); }
private void doSearch1(SolrDocumentList results, SolrIndexSearcher searcher, String q, Filter filter, int ndocs, SolrQueryRequest req, Map<String,SchemaField> fields, Set<Integer> alreadyFound) throws IOException { // build custom query and extra fields Query query = null; //buildCustomQuery1(q); Map<String,Object> extraFields = new HashMap<String,Object>(); extraFields.put("search_type", "search1"); boolean includeScore = req.getParams().get(CommonParams.FL).contains("score"); int maxDocsPerSearcherType = 0; float maprelScoreCutoff = 2.0f; append(results, searcher.search( query, filter, maxDocsPerSearcherType).scoreDocs, alreadyFound, fields, extraFields, maprelScoreCutoff , searcher.getIndexReader(), includeScore); }
private void SearchDocumentsTypeII(SolrDocumentList results, SolrIndexSearcher searcher, String q, UserPermissions up, int ndocs, SolrQueryRequest req, Map<String, SchemaField> fields, Set<Integer> alreadyFound) throws IOException, ParseException { BooleanQuery bq = new BooleanQuery(); String permLvl = "PermissionLevel:" + up.getPermissionLevel(); QParser parser = QParser.getParser(permLvl, null, req); bq.add(parser.getQuery(), Occur.MUST); Filter filter = CachingWrapperFilter(new QueryWrapperFilter(bq)); QueryParser qp = new QueryParser(q, new StandardAnalyzer()); Query query = qp.parse(q); append (results, searcher.search( query, filter, 50).scoreDocs, alreadyFound, fields, new HashMap<String,Object>(), 0, searcher.getReader(), true); }
@Override public boolean hasNext() { try { final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); searcher.search(result, queryCommand); LOGGER.debugQuery(queryCommand, result); sentCursorMark = queryCommand.getCursorMark(); nextCursorMark = result.getNextCursorMark(); page = result.getDocListAndSet().docList; return page.size() > 0; } catch (final Exception exception) { throw new RuntimeException(exception); } }
public void deleteByQuery(DeleteUpdateCommand cmd) throws IOException { if (!cmd.fromPending && !cmd.fromCommitted) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd); if (!cmd.fromPending || !cmd.fromCommitted) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported: " + cmd); Query q = QueryParsing.parseQuery(cmd.query, schema); int totDeleted = 0; synchronized(this) { closeWriter(); openSearcher(); // if we want to count the number of docs that were deleted, then // we need a new instance of the DeleteHitCollector final DeleteHitCollector deleter = new DeleteHitCollector(searcher); searcher.search(q, null, deleter); totDeleted = deleter.deleted; } if (core.log.isDebugEnabled()) { core.log.debug(core.getLogId()+"docs deleted:" + totDeleted); } }
final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); try { request.getSearcher().search(result, GET_GRAPH_NODES_QUERY); final SimpleFacets facets = new SimpleFacets( request,
@Override protected int graphBaseSize() { final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); try { return searcher.search(result, graphSizeQueryCommand()).getDocListAndSet().docList.matches(); } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } }
@Override protected boolean _containsGraph(final Node graphNode) { final SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand(); cmd.setQuery(new MatchAllDocsQuery()); cmd.setLen(0); cmd.setFilterList(new TermQuery(new Term(Field.C, asNtURI(graphNode)))); final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); try { request.getSearcher().search(result, cmd); return result.getDocListAndSet().docList.matches() > 0; } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } } }
@Override public boolean hasNext() { try { final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); searcher.search(result, queryCommand); LOGGER.debugQuery(queryCommand, result); consumer.onDocSet(result.getDocListAndSet().docSet); queryCommand.clearFlags(SolrIndexSearcher.GET_DOCSET); sentCursorMark = queryCommand.getCursorMark(); nextCursorMark = result.getNextCursorMark(); page = result.getDocListAndSet().docList; return page.size() > 0; } catch (final Exception exception) { throw new RuntimeException(exception); } }
@Override public long getStatistic(final Node s, final Node p, final Node o) { final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult(); try { return searcher.search( result, queryCommand(Triple.create(s, p, o), sortSpec())).getDocListAndSet().docList.matches(); } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } } }
/** * Searches the index, if older documents exists. Updates the solr query response. * * @param req - the solr query request information * @param rsp - the solr query response information * @return true if the hit count is greater zero, otherwise false * @throws SyntaxError, IOException if bad things happen */ private boolean olderDocumentsExists(String queryString, SolrQueryRequest req, SolrQueryResponse rsp) throws SyntaxError, IOException { String defType = req.getParams().get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE); QParser queryParser = QParser.getParser(queryString, defType, req); Query query = queryParser.getQuery(); TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector(); req.getSearcher().search(query, totalHitCountCollector); rsp.add("query", String.format("%s:[* TO NOW-%s]", queryField, timeSeriesAge)); rsp.add("queryTechnical", queryString); rsp.add("removedDocuments", totalHitCountCollector.getTotalHits()); return totalHitCountCollector.getTotalHits() != 0; }
/** * Returns documents matching both <code>query</code> and <code>filter</code> * and sorted by <code>sort</code>. * FUTURE: The returned DocList may be retrieved from a cache. * * @param query * @param filter may be null * @param lsort criteria by which to sort (if null, query relevance is used) * @param offset offset into the list of documents to return * @param len maximum number of documents to return * @return DocList meeting the specified criteria, should <b>not</b> be modified by the caller. * @throws IOException */ public DocList getDocList(Query query, DocSet filter, Sort lsort, int offset, int len) throws IOException { QueryCommand qc = new QueryCommand(); qc.setQuery(query) .setFilter(filter) .setSort(lsort) .setOffset(offset) .setLen(len); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocList(); }
/** * Returns documents matching both <code>query</code> and <code>filter</code> * and sorted by <code>sort</code>. * <p> * This method is cache aware and may retrieve <code>filter</code> from * the cache or make an insertion into the cache as a result of this call. * <p> * FUTURE: The returned DocList may be retrieved from a cache. * * @param query * @param filter may be null * @param lsort criteria by which to sort (if null, query relevance is used) * @param offset offset into the list of documents to return * @param len maximum number of documents to return * @return DocList meeting the specified criteria, should <b>not</b> be modified by the caller. * @throws IOException */ public DocList getDocList(Query query, Query filter, Sort lsort, int offset, int len) throws IOException { QueryCommand qc = new QueryCommand(); qc.setQuery(query) .setFilterList(filter) .setSort(lsort) .setOffset(offset) .setLen(len); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocList(); }
/** * Returns documents matching both <code>query</code> and the * intersection of the <code>filterList</code>, sorted by <code>sort</code>. * <p> * This method is cache aware and may retrieve <code>filter</code> from * the cache or make an insertion into the cache as a result of this call. * <p> * FUTURE: The returned DocList may be retrieved from a cache. * * @param query * @param filterList may be null * @param lsort criteria by which to sort (if null, query relevance is used) * @param offset offset into the list of documents to return * @param len maximum number of documents to return * @return DocList meeting the specified criteria, should <b>not</b> be modified by the caller. * @throws IOException */ public DocList getDocList(Query query, List<Query> filterList, Sort lsort, int offset, int len, int flags) throws IOException { QueryCommand qc = new QueryCommand(); qc.setQuery(query) .setFilterList(filterList) .setSort(lsort) .setOffset(offset) .setLen(len) .setFlags(flags); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocList(); }
/** * Returns documents matching both <code>query</code> and <code>filter</code> * and sorted by <code>sort</code>. Also returns the compete set of documents * matching <code>query</code> and <code>filter</code> (regardless of <code>offset</code> and <code>len</code>). * <p> * FUTURE: The returned DocList may be retrieved from a cache. * * @param query * @param filter may be null * @param lsort criteria by which to sort (if null, query relevance is used) * @param offset offset into the list of documents to return * @param len maximum number of documents to return * @return DocListAndSet meeting the specified criteria, should <b>not</b> be modified by the caller. * @throws IOException */ public DocListAndSet getDocListAndSet(Query query, DocSet filter, Sort lsort, int offset, int len) throws IOException { QueryCommand qc = new QueryCommand(); qc.setQuery(query) .setFilter(filter) .setSort(lsort) .setOffset(offset) .setLen(len) .setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet(); }
.setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet();
.setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet();
.setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet();
.setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet();
.setNeedDocSet(true); QueryResult qr = new QueryResult(); search(qr,qc); return qr.getDocListAndSet();