Package org.apache.solr.core

Examples of org.apache.solr.core.SolrCore


  public void testDeleteCommit() throws Exception {
    addSimpleDoc("A");
    addSimpleDoc("B");

    // commit "A", "B"
    SolrCore core = h.getCore();
    UpdateHandler updater = core.getUpdateHandler();
    CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
    cmtCmd.waitSearcher = true;
    updater.commit(cmtCmd);

    // search - "A","B" should be found.
View Full Code Here


  public void testAddRollback() throws Exception {
    addSimpleDoc("A");

    // commit "A"
    SolrCore core = h.getCore();
    UpdateHandler updater = core.getUpdateHandler();
    assertTrue( updater instanceof DirectUpdateHandler2 );
    DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
    CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
    cmtCmd.waitSearcher = true;
    assertEquals( 1, duh2.addCommands.get() );
View Full Code Here

  public void testDeleteRollback() throws Exception {
    addSimpleDoc("A");
    addSimpleDoc("B");

    // commit "A", "B"
    SolrCore core = h.getCore();
    UpdateHandler updater = core.getUpdateHandler();
    assertTrue( updater instanceof DirectUpdateHandler2 );
    DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
    CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
    cmtCmd.waitSearcher = true;
    assertEquals( 2, duh2.addCommands.get() );
View Full Code Here

    assertTrue(r.getLeafReaders().length > 1)// still more than 1 segment
    sr.close();
  }
 
  private void addSimpleDoc(String id) throws Exception {
    SolrCore core = h.getCore();
   
    UpdateHandler updater = core.getUpdateHandler();
   
    AddUpdateCommand cmd = new AddUpdateCommand();
    cmd.overwriteCommitted = true;
    cmd.overwritePending = true;
    cmd.allowDups = false;
View Full Code Here

    cmd.doc.add( new Field( "id", id, Store.YES, Index.UN_TOKENIZED ) );
    updater.addDoc( cmd );
  }
 
  private void deleteSimpleDoc(String id) throws Exception {
    SolrCore core = h.getCore();
   
    UpdateHandler updater = core.getUpdateHandler();
   
    // Delete the document
    DeleteUpdateCommand cmd = new DeleteUpdateCommand();
    cmd.id = id;
    cmd.fromCommitted = true;
View Full Code Here

  @Override public String getSchemaFile() { return "schema12.xml"; }
  @Override public String getSolrConfigFile() { return "solrconfig-elevate.xml"; }
 
  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" );
   
    QueryElevationComponent comp = new QueryElevationComponent();
    comp.init( args );
    comp.inform( core );
   
    IndexReader reader = core.getSearcher().get().getReader();
    Map<String, ElevationObj> map = comp.getElevationMap( reader, core );
    // Make sure the boosts loaded properly
    assertEquals( 3, map.size() );
    assertEquals( 1, map.get( "XXXX" ).priority.size() );
    assertEquals( 2, map.get( "YYYY" ).priority.size() );
View Full Code Here

    assertEquals( "xxxx", comp.getAnalyzedQuery( "XXXX" ) );
    assertEquals( "xxxxyyyy", comp.getAnalyzedQuery( "XXXX YYYY" ) );
  }

  public void testEmptyQuery() throws Exception {
    SolrCore core = h.getCore();

    //String query = "title:ipod";

    Map<String,String> args = new HashMap<String, String>();
    args.put( "q.alt", "*:*" );
View Full Code Here

  }


  public void testSorting() throws IOException
  {
    SolrCore core = h.getCore();
   
    assertU(adoc("id", "a", "title", "ipod",           "str_s", "a" ));
    assertU(adoc("id", "b", "title", "ipod ipod",      "str_s", "b" ));
    assertU(adoc("id", "c", "title", "ipod ipod ipod", "str_s", "c" ));

    assertU(adoc("id", "x", "title", "boosted",                 "str_s", "x" ));
    assertU(adoc("id", "y", "title", "boosted boosted",         "str_s", "y" ));
    assertU(adoc("id", "z", "title", "boosted boosted boosted", "str_s", "z" ));
    assertU(commit());
   
    String query = "title:ipod";
   
    Map<String,String> args = new HashMap<String, String>();
    args.put( CommonParams.Q, query );
    args.put( CommonParams.QT, "/elevate" );
    args.put( CommonParams.FL, "id,score" );
    args.put( "indent", "true" );
    //args.put( CommonParams.FL, "id,title,score" );
    SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
   
    assertQ("Make sure standard sort works as expected", req
            ,"//*[@numFound='3']"
            ,"//result/doc[1]/str[@name='id'][.='a']"
            ,"//result/doc[2]/str[@name='id'][.='b']"
            ,"//result/doc[3]/str[@name='id'][.='c']"
            );
   
    // Explicitly set what gets boosted
    IndexReader reader = core.getSearcher().get().getReader();
    QueryElevationComponent booster = (QueryElevationComponent)core.getSearchComponent( "elevate" );
    booster.elevationCache.clear();
    booster.setTopQueryResults( reader, query, new String[] { "x", "y", "z" }, null );

    assertQ("All six should make it", req
            ,"//*[@numFound='6']"
 
View Full Code Here

    System.out.println( "OUT:"+file.getAbsolutePath() );
  }

  public void testElevationReloading() throws Exception
  {
    SolrCore core = h.getCore();

    String testfile = "data-elevation.xml";
    File f = new File( core.getDataDir(), testfile );
    writeFile( f, "aaa", "A" );
   
    QueryElevationComponent comp = (QueryElevationComponent)core.getSearchComponent("elevate");
    NamedList<String> args = new NamedList<String>();
    args.add( QueryElevationComponent.CONFIG_FILE, testfile );
    comp.init( args );
    comp.inform( core );
   
    IndexReader reader = core.getSearcher().get().getReader();
    Map<String, ElevationObj> map = comp.getElevationMap(reader, core);
    assertTrue( map.get( "aaa" ).priority.containsKey( "A" ) );
    assertNull( map.get( "bbb" ) );
   
    // now change the file
    writeFile( f, "bbb", "B" );
    assertU(adoc("id", "10000")); // will get same reader if no index change
    assertU(commit());
   
    reader = core.getSearcher().get().getReader();
    map = comp.getElevationMap(reader, core);
    assertNull( map.get( "aaa" ) );
    assertTrue( map.get( "bbb" ).priority.containsKey( "B" ) );
  }
View Full Code Here

  }

  @Test
  public void testCopyFieldFunctionality()
    {
      SolrCore core = h.getCore();
      assertU(adoc("id", "10", "title", "test copy field", "text_en", "this is a simple test of the copy field functionality"));
      assertU(commit());
     
      Map<String,String> args = new HashMap<String, String>();
      args.put( CommonParams.Q, "text_en:simple" );
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.