List of usage examples for org.apache.solr.common.params MapSolrParams MapSolrParams
public MapSolrParams(Map<String, String> map)
From source file:com.cloudera.cdk.morphline.solrcell.SolrCellMorphlineTest.java
License:Apache License
/** * Test that the ContentHandler properly strips the illegal characters *//*from w w w.j a v a2s. c o m*/ @Test public void testTransformValue() { String fieldName = "user_name"; assertFalse("foobar".equals(getFoobarWithNonChars())); Metadata metadata = new Metadata(); // load illegal char string into a metadata field and generate a new document, // which will cause the ContentHandler to be invoked. metadata.set(fieldName, getFoobarWithNonChars()); StripNonCharSolrContentHandlerFactory contentHandlerFactory = new StripNonCharSolrContentHandlerFactory( DateUtil.DEFAULT_DATE_FORMATS); IndexSchema schema = h.getCore().getLatestSchema(); SolrContentHandler contentHandler = contentHandlerFactory.createSolrContentHandler(metadata, new MapSolrParams(new HashMap()), schema); SolrInputDocument doc = contentHandler.newDocument(); String foobar = doc.getFieldValue(fieldName).toString(); assertTrue("foobar".equals(foobar)); }
From source file:com.cominvent.solr.RequestSanitizerComponent.java
License:Apache License
@Override public void prepare(ResponseBuilder rb) throws IOException { SolrParams params = rb.req.getParams(); if (!params.getBool(COMPONENT_NAME, true)) return;/*from ww w . jav a 2s . co m*/ Map<String, Map<String, String>> mappings = parseMappings(Arrays.asList(params.getParams(SANITIZE_PARAM))); log.info("Initialized RequestSanitizerComponent with mappings " + mappings); Map<String, String> modified = getModifications(params, mappings); if (modified.size() > 0) { log.info("Request parameters that were modified by RequestSanitizerComponent: " + modified); rb.req.setParams(new DefaultSolrParams(new MapSolrParams(modified), params)); } }
From source file:com.github.le11.nls.solr.SolrNLSQParserPluginTest.java
License:Apache License
@Test public void testSimple() { try {/* w w w . ja v a 2 s .c o m*/ SolrNLSQParserPlugin solrNLSQParserPlugin = new SolrNLSQParserPlugin(); LocalSolrQueryRequest request = testHarness.getRequestFactory("standard", 0, 10).makeRequest("q", "\"people working at Google Amsterdam office\"", "debugQuery", "true"); QParser nlsQParser = solrNLSQParserPlugin.createParser("people working at Google Amsterdam office", new MapSolrParams(new HashMap<String, String>()), new MapSolrParams(new HashMap<String, String>()), request); Query q = nlsQParser.parse(); assertNotNull(q); System.out.println(q.toString()); } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } }
From source file:com.ngdata.hbaseindexer.parse.tika.TikaSolrDocumentExtractor.java
License:Apache License
private SolrInputDocument extractInternal(byte[] input) { Metadata metadata = new Metadata(); metadata.add(LiteralMimeDetector.MIME_TYPE, mimeType); Map<String, String> cellParams = (params == null || params.isEmpty()) ? DEFAULT_CELL_PARAMS : params; SolrContentHandler handler = new SolrContentHandler(metadata, new MapSolrParams(cellParams), indexSchema); try {/* w ww . j a va2 s.c o m*/ parser.parse(new ByteArrayInputStream(input), handler, metadata, new ParseContext()); } catch (Exception e) { throw new RuntimeException(e); } return handler.newDocument(); }
From source file:com.s24.search.solr.util.SolrParamsUtilTest.java
License:Apache License
@Test public void testModifiable() throws Exception { Map<String, String> map = new HashMap<>(); map.put("foo", "bar"); SolrParams params = new MapSolrParams(map); ModifiableSolrParams modifiable = SolrParamsUtil.modifiable(params); assertEquals(1, modifiable.size());/*from www. j av a 2 s . c o m*/ assertEquals("bar", modifiable.get("foo")); }
From source file:edu.toronto.cs.cidb.solr.SolrScriptService.java
License:Open Source License
/** * Search for HPO terms matching the specified query, using the Lucene query language. * // w w w. ja v a 2 s. co m * @param queryParameters a Lucene query * @return the list of matching documents, empty if there are no matching terms */ public SolrDocumentList search(final String queryParameters) { MapSolrParams params = new MapSolrParams(getSolrQuery(queryParameters, -1, 0)); return search(params); }
From source file:edu.toronto.cs.cidb.solr.SolrScriptService.java
License:Open Source License
/** * Search for HPO terms matching the specified query, using the Lucene query language. * //from w w w . j a v a 2s. com * @param queryParameters a Lucene query * @param sort sorting criteria * @return the list of matching documents, empty if there are no matching terms */ public SolrDocumentList search(final String queryParameters, final String sort) { MapSolrParams params = new MapSolrParams(getSolrQuery(queryParameters, sort, -1, 0)); return search(params); }
From source file:edu.toronto.cs.cidb.solr.SolrScriptService.java
License:Open Source License
/** * Search for HPO terms matching the specified query, using the Lucene query language. * * @param queryParameters a Lucene query * @param rows the number of items to return, or -1 to use the default number of results * @param start the number of items to skip, i.e. the index of the first hit to return, 0-based * @return the list of matching documents, empty if there are no matching terms *//* ww w . ja v a 2s . c o m*/ public SolrDocumentList search(final String queryParameters, final int rows, final int start) { MapSolrParams params = new MapSolrParams(getSolrQuery(queryParameters, rows, start)); return search(params); }
From source file:edu.toronto.cs.cidb.solr.SolrScriptService.java
License:Open Source License
/** * Search for HPO terms matching the specified query, using the Lucene query language. * * @param queryParameters a Lucene query * @param sort sorting criteria/*from w w w .j a v a 2s. c om*/ * @param rows the number of items to return, or -1 to use the default number of results * @param start the number of items to skip, i.e. the index of the first hit to return, 0-based * @return the list of matching documents, empty if there are no matching terms */ public SolrDocumentList search(final String queryParameters, final String sort, final int rows, final int start) { MapSolrParams params = new MapSolrParams(getSolrQuery(queryParameters, sort, rows, start)); return search(params); }
From source file:edu.toronto.cs.cidb.solr.SolrScriptService.java
License:Open Source License
/** * Search for HPO terms matching the specified query, where the query is specified as a map of field name and * keywords./*from ww w . j a v a 2s .co m*/ * * @param fieldValues the map of values to search for, where each key is the name of an indexed field and the value * is the keywords to match for that field * @param rows the number of items to return, or -1 to use the default number of results * @param start the number of items to skip, i.e. the index of the first hit to return, 0-based * @return the list of matching documents, empty if there are no matching terms */ public SolrDocumentList search(final Map<String, String> fieldValues, final int rows, final int start) { MapSolrParams params = new MapSolrParams(getSolrQuery(fieldValues, rows, start)); return search(params); }