Package org.apache.solr.core

Examples of org.apache.solr.core.SolrCore


    if (xslt != null) {
      xslt = context.replaceTokens(xslt);
      try {
        // create an instance of TransformerFactory
        TransformerFactory transFact = TransformerFactory.newInstance();
        final SolrCore core = context.getSolrCore();
        final StreamSource xsltSource;
        if (core != null) {
          final ResourceLoader loader = core.getResourceLoader();
          transFact.setURIResolver(new SystemIdResolver(loader).asURIResolver());
          xsltSource = new StreamSource(loader.openResource(xslt),
            SystemIdResolver.createSystemIdFromResourceName(xslt));
        } else {
          // fallback for tests
View Full Code Here


    super.setUp();
    lrf = h.getRequestFactory("standard", 0, 20 );
  }
 
  public void testSorting() throws Exception {
    SolrCore core = h.getCore();
    assertU(adoc("id", "10", "title", "test", "val_s1", "aaa"));
    assertU(adoc("id", "11", "title", "test", "val_s1", "bbb"));
    assertU(adoc("id", "12", "title", "test", "val_s1", "ccc"));
    assertU(commit());
   
View Full Code Here

**/
public class ClusteringComponentTest extends AbstractClusteringTestCase {

  @Test
  public void testComponent() throws Exception {
    SolrCore core = h.getCore();

    SearchComponent sc = core.getSearchComponent("clustering");
    assertTrue("sc is null and it shouldn't be", sc != null);
    ModifiableSolrParams params = new ModifiableSolrParams();

    params.add(ClusteringComponent.COMPONENT_NAME, "true");
    params.add(CommonParams.Q, "*:*");

    params.add(ClusteringParams.USE_SEARCH_RESULTS, "true");


    SolrRequestHandler handler = core.getRequestHandler("standard");
    SolrQueryResponse rsp;
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
    handler.handleRequest(req, rsp);
    NamedList values = rsp.getValues();
    Object clusters = values.get("clusters");
    //System.out.println("Clusters: " + clusters);
    assertTrue("clusters is null and it shouldn't be", clusters != null);
    req.close();

    params = new ModifiableSolrParams();
    params.add(ClusteringComponent.COMPONENT_NAME, "true");
    params.add(ClusteringParams.ENGINE_NAME, "mock");
    params.add(ClusteringParams.USE_COLLECTION, "true");
    params.add(QueryComponent.COMPONENT_NAME, "false");

    handler = core.getRequestHandler("docClustering");

    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    req = new LocalSolrQueryRequest(core, params);
    handler.handleRequest(req, rsp);
View Full Code Here

    super.tearDown();
  }

  protected String loadDataConfig(String dataConfigFileName) {
    try {
      SolrCore core = h.getCore();
      return SolrWriter.getResourceAsString(core.getResourceLoader()
              .openResource(dataConfigFileName));
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

   *             this method should be changed to use {@link #handleRequest}
   *             method with a ContentStream.
   */
  @Deprecated
  public void doLegacyUpdate(InputStream input, String inputContentType, Writer output) {
    SolrCore core = SolrCore.getSolrCore();
    SolrQueryRequest req = new LocalSolrQueryRequest(core, new HashMap<String,String[]>());
    try {
      // Old style requests do not choose a custom handler
      UpdateRequestProcessorChain processorFactory = core.getUpdateProcessingChain(null);
      SolrQueryResponse rsp = new SolrQueryResponse(); // ignored
      final String charset = ContentStreamBase.getCharsetFromContentType(inputContentType);
      final XMLStreamReader parser = (charset == null) ?
        inputFactory.createXMLStreamReader(input) : inputFactory.createXMLStreamReader(input, charset);
      UpdateRequestProcessor processor = processorFactory.createProcessor(req, rsp);
View Full Code Here

  }
 
  @Test
  public void testInterface() throws Exception
  {
    SolrCore core = h.getCore();
   
    NamedList<String> args = new NamedList<String>();
    args.add( QueryElevationComponent.FIELD_TYPE, "string" );
    args.add( QueryElevationComponent.CONFIG_FILE, "elevate.xml" );
   
View Full Code Here

    final Map<String, Evaluator> evaluators = new HashMap<String, Evaluator>();
    evaluators.put(DATE_FORMAT_EVALUATOR, getDateFormatEvaluator());
    evaluators.put(SQL_ESCAPE_EVALUATOR, getSqlEscapingEvaluator());
    evaluators.put(URL_ENCODE_EVALUATOR, getUrlEvaluator());
    evaluators.put(ESCAPE_SOLR_QUERY_CHARS, getSolrQueryEscapingEvaluator());
    SolrCore core = docBuilder == null ? null : docBuilder.dataImporter.getCore();
    for (Map<String, String> map : fn) {
      try {
        evaluators.put(map.get(NAME), (Evaluator) loadClass(map.get(CLASS), core).newInstance());
      } catch (Exception e) {
        wrapAndThrow(SEVERE, e, "Unable to instantiate evaluator: " + map.get(CLASS));
View Full Code Here

  }

  @Test
  public void testBuildDocument() throws Exception
  {
    SolrCore core = h.getCore();
   
    // undefined field
    try {
      SolrInputDocument doc = new SolrInputDocument();
      doc.setField( "unknown field", 12345, 1.0f );
      DocumentBuilder.toDocument( doc, core.getSchema() );
      fail( "should throw an error" );
    }
    catch( SolrException ex ) {
      assertEquals( "should be bad request", 400, ex.code() );
    }
View Full Code Here

  }

  @Test
  public void testNullField()
  {
    SolrCore core = h.getCore();
   
    // make sure a null value is not indexed
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField( "name", null, 1.0f );
    Document out = DocumentBuilder.toDocument( doc, core.getSchema() );
    assertNull( out.get( "name" ) );
  }
View Full Code Here

    assertNull( out.get( "name" ) );
  }

  @Test
  public void testMultiField() throws Exception {
    SolrCore core = h.getCore();

    // make sure a null value is not indexed
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField( "home", "2.2,3.3", 1.0f );
    Document out = DocumentBuilder.toDocument( doc, core.getSchema() );
    assertNotNull( out.get( "home" ) );//contains the stored value and term vector, if there is one
    assertNotNull( out.getFieldable( "home_0" + FieldType.POLY_FIELD_SEPARATOR + "double" ) );
    assertNotNull( out.getFieldable( "home_1" + FieldType.POLY_FIELD_SEPARATOR + "double" ) );
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.core.SolrCore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.