org.apache.solr.search.QParserPlugin Java Examples
The following examples show how to use
org.apache.solr.search.QParserPlugin.
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: HighlightComponent.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void prepare(ResponseBuilder rb) throws IOException { SolrParams params = rb.req.getParams(); rb.doHighlights = solrConfigHighlighter.isHighlightingEnabled(params); if(rb.doHighlights){ rb.setNeedDocList(true); String hlq = params.get(HighlightParams.Q); String hlparser = MoreObjects.firstNonNull(params.get(HighlightParams.QPARSER), params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE)); if(hlq != null){ try { QParser parser = QParser.getParser(hlq, hlparser, rb.req); rb.setHighlightQuery(parser.getHighlightQuery()); } catch (SyntaxError e) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e); } } } }
Example #2
Source File: ChronixRetentionHandler.java From chronix.server with Apache License 2.0 | 6 votes |
/** * 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; }
Example #3
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example #4
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example #5
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example #6
Source File: SOLR749Test.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testConstruction() throws Exception { SolrCore core = h.getCore(); assertTrue("core is null and it shouldn't be", core != null); QParserPlugin parserPlugin = core.getQueryPlugin(QParserPlugin.DEFAULT_QTYPE); assertTrue("parserPlugin is null and it shouldn't be", parserPlugin != null); assertTrue("parserPlugin is not an instanceof " + FooQParserPlugin.class, parserPlugin instanceof FooQParserPlugin); ValueSourceParser vsp = core.getValueSourceParser("boost"); assertTrue("vsp is null and it shouldn't be", vsp != null); assertTrue("vsp is not an instanceof " + DummyValueSourceParser.class, vsp instanceof DummyValueSourceParser); }
Example #7
Source File: TestXJoinQParserPlugin.java From BioSolr with Apache License 2.0 | 5 votes |
private static Query parse(String v) throws SyntaxError { ModifiableSolrParams localParams = new ModifiableSolrParams(); localParams.add(QueryParsing.V, v); QParserPlugin qpp = core.getQueryPlugin(PARSER_NAME); QParser qp = qpp.createParser(null, localParams, null, req); return qp.parse(); }
Example #8
Source File: TestXJoinQParserPlugin.java From BioSolr with Apache License 2.0 | 5 votes |
private static Query parse(String v) throws SyntaxError { ModifiableSolrParams localParams = new ModifiableSolrParams(); localParams.add(QueryParsing.V, v); QParserPlugin qpp = core.getQueryPlugin(PARSER_NAME); QParser qp = qpp.createParser(null, localParams, null, req); return qp.parse(); }
Example #9
Source File: TestXJoinQParserPlugin.java From BioSolr with Apache License 2.0 | 5 votes |
private static Query parse(String v) throws SyntaxError { ModifiableSolrParams localParams = new ModifiableSolrParams(); localParams.add(QueryParsing.V, v); QParserPlugin qpp = core.getQueryPlugin(PARSER_NAME); QParser qp = qpp.createParser(null, localParams, null, req); return qp.parse(); }
Example #10
Source File: SolrCore.java From lucene-solr with Apache License 2.0 | 4 votes |
public QParserPlugin getQueryPlugin(String parserName) { return qParserPlugins.get(parserName); }