Java Code Examples for org.apache.solr.search.SolrIndexSearcher#QueryResult

The following examples show how to use org.apache.solr.search.SolrIndexSearcher#QueryResult . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeepPagingIterator.java    From SolRDF with Apache License 2.0 6 votes vote down vote up
@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);
	}
}
 
Example 2
Source File: DeepPagingIterator.java    From SolRDF with Apache License 2.0 6 votes vote down vote up
@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);
	}
}
 
Example 3
Source File: LocalDatasetGraph.java    From SolRDF with Apache License 2.0 6 votes vote down vote up
@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);
	}	    
}
 
Example 4
Source File: Log.java    From SolRDF with Apache License 2.0 5 votes vote down vote up
/**
 * Debugs the given query command.
 * 
 * @param cmd the query command.
 */
public void debugQuery(final QueryCommand cmd, final SolrIndexSearcher.QueryResult result) {
	if (logger.isDebugEnabled()) {
		final StringBuilder builder = new StringBuilder("*:*");
		for (final Query filter : cmd.getFilterList()) {
			builder.append(" & ").append(filter);
		}
		
		logger.debug(createMessage(
				MessageCatalog._00109_SOLR_QUERY, 
				builder.toString(), 
				result.getDocList().size(), 
				result.getDocList().matches()));
	}
}
 
Example 5
Source File: LocalGraph.java    From SolRDF with Apache License 2.0 5 votes vote down vote up
@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);
	}	    
}
 
Example 6
Source File: LocalGraph.java    From SolRDF with Apache License 2.0 5 votes vote down vote up
@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);
	}	    
}
 
Example 7
Source File: LocalDatasetGraph.java    From SolRDF with Apache License 2.0 5 votes vote down vote up
@Override
public Iterator<Node> listGraphNodes() {
    final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult();
    try {
		request.getSearcher().search(result, GET_GRAPH_NODES_QUERY);
		final SimpleFacets facets = new SimpleFacets(
	    		request, 
	    		result.getDocSet(), 
	    		GET_GRAPH_NODES_QUERY_PARAMS);
		
		final NamedList<Integer> list = facets.getFacetTermEnumCounts(
				request.getSearcher(), 
				result.getDocSet(),
				Field.C,
				0,
				-1,
				1,
				false,
				"count"
				,null,
				null,
				false,
				null);
		final List<Node> graphs = new ArrayList<Node>();
		for (final Entry<String, Integer> entry : list) {
			if (!SolRDFGraph.UNNAMED_GRAPH_PLACEHOLDER.equals(entry.getKey())) {
				graphs.add(NTriples.asURI(entry.getKey()));
			}
		}
		
		LOGGER.debug(MessageCatalog._00112_GRAPHS_TOTAL_COUNT, graphs.size());
		
		return graphs.iterator();
	} catch (final Exception exception) {
		LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception);
		throw new SolrException(ErrorCode.SERVER_ERROR, exception);
	}	    
}