Java Code Examples for org.apache.solr.handler.component.ResponseBuilder#getQparser()

The following examples show how to use org.apache.solr.handler.component.ResponseBuilder#getQparser() . 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: QuerqyQueryComponent.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Override
public void prepare(final ResponseBuilder rb) throws IOException {

    super.prepare(rb);
    
    QParser parser = rb.getQparser();
    
    if (parser instanceof QuerqyDismaxQParser) {
    
        List<Query> filterQueries = ((QuerqyDismaxQParser) parser).getFilterQueries();
        if ((filterQueries != null) && !filterQueries.isEmpty()) {
            List<Query> filters = rb.getFilters();
            if (filters == null) {
                rb.setFilters(filterQueries);
            } else {
                filters.addAll(filterQueries);
            }
        }

    }
}
 
Example 2
Source File: QuerqyQueryComponent.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final ResponseBuilder rb) throws IOException {
    
    super.process(rb);
    
    QParser parser = rb.getQparser();
    
    if (parser instanceof QuerqyDismaxQParser) {

        final SearchEngineRequestAdapter searchEngineRequestAdapter =
                ((QuerqyDismaxQParser) parser).getSearchEngineRequestAdapter();

        final Map<String, Object> context = searchEngineRequestAdapter.getContext();
        if (context != null) {

            @SuppressWarnings("unchecked")
            Set<Object> decorations = (Set<Object>) context.get(DecorateInstruction.CONTEXT_KEY);
            if (decorations != null) {
                rb.rsp.add("querqy_decorations", decorations);
            }
        }

        searchEngineRequestAdapter.getInfoLoggingContext().ifPresent(InfoLoggingContext::endOfRequest);
    }

}