org.apache.solr.core.SolrCore Java Examples

The following examples show how to use org.apache.solr.core.SolrCore. 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: SignatureUpdateProcessorFactoryTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailNonIndexedSigWithOverwriteDupes() throws Exception {
  SolrCore core = h.getCore();
  SignatureUpdateProcessorFactory f = new SignatureUpdateProcessorFactory();
  NamedList<String> initArgs = new NamedList<>();
  initArgs.add("overwriteDupes", "true");
  initArgs.add("signatureField", "signatureField_sS");
  f.init(initArgs);
  boolean exception_ok = false;
  try {
    f.inform(core);
  } catch (Exception e) {
    exception_ok = true;
  }
  assertTrue("Should have gotten an exception from inform(SolrCore)", 
             exception_ok);
}
 
Example #2
Source File: SoftAutoCommitTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Before
public void createMonitor() throws Exception {
  assumeFalse("This test is not working on Windows (or maybe machines with only 2 CPUs)",
    Constants.WINDOWS);

  SolrCore core = h.getCore();

  updater = (DirectUpdateHandler2) core.getUpdateHandler();
  updater.setCommitWithinSoftCommit(true); // foce to default, let tests change as needed
  monitor = new MockEventListener();

  core.registerNewSearcherListener(monitor);
  updater.registerSoftCommitCallback(monitor);
  updater.registerCommitCallback(monitor);

  // isolate searcher getting ready from this test
  monitor.searcher.poll(5000, MILLISECONDS);
}
 
Example #3
Source File: FieldAnalyzerService.java    From vind with Apache License 2.0 6 votes vote down vote up
/**
 * analyzes string like the given field
 * @param field the name of the field
 * @param value the string to analyze
 * @return the analyzed string
 */
public static String analyzeString(SolrCore core, String field, String value) {
    try {
        StringBuilder b = new StringBuilder();
        try (TokenStream ts = core.getLatestSchema().getFieldType(field).getQueryAnalyzer().tokenStream(field, new StringReader(value))) {
            ts.reset();
            while (ts.incrementToken()) {
                b.append(" ");
                CharTermAttribute attr = ts.getAttribute(CharTermAttribute.class);
                b.append(attr);
            }
        }

        return b.toString().trim();
    } catch (IOException e) {
        //FIXME: This error should be properly logged!
        e.printStackTrace();
        return value;
    }
}
 
Example #4
Source File: SecureCoreAdminHandler.java    From incubator-sentry with Apache License 2.0 6 votes vote down vote up
private String getCollectionFromCoreName(String coreName) {
  SolrCore solrCore = null;
  try {
    if (coreName != null && !coreName.equals("")) {
      solrCore = coreContainer.getCore(coreName);
      if (solrCore != null) {
        return solrCore.getCoreDescriptor().getCloudDescriptor().getCollectionName();
      }
    }
  } finally {
    if (solrCore != null) {
      solrCore.close();
    }
  }
  return null;
}
 
Example #5
Source File: RecoveryStrategy.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
final private void cloudDebugLog(SolrCore core, String op) {
  if (!log.isDebugEnabled()) {
    return;
  }
  try {
    RefCounted<SolrIndexSearcher> searchHolder = core.getNewestSearcher(false);
    SolrIndexSearcher searcher = searchHolder.get();
    try {
      final int totalHits = searcher.count(new MatchAllDocsQuery());
      final String nodeName = core.getCoreContainer().getZkController().getNodeName();
      log.debug("[{}] {} [{} total hits]", nodeName, op, totalHits);
    } finally {
      searchHolder.decref();
    }
  } catch (Exception e) {
    log.debug("Error in solrcloud_debug block", e);
  }
}
 
Example #6
Source File: SpellcheckComponent.java    From customized-symspell with MIT License 6 votes vote down vote up
private void loadDefault(String unigramsFile, String bigramsFile, String exclusionsFile,
    SpellChecker spellChecker,
    SolrCore core, String exclusionListSperatorRegex) {
  try {
    if (!StringUtils.isEmpty(unigramsFile)) {
      loadUniGramFile(core.getResourceLoader().openResource(unigramsFile),
          spellChecker.getDataHolder());
    }

    if (!StringUtils.isEmpty(bigramsFile)) {
      loadBiGramFile(core.getResourceLoader().openResource(bigramsFile),
          spellChecker.getDataHolder());
    }

    if (!StringUtils.isEmpty(exclusionsFile)) {
      loadExclusions(core.getResourceLoader().openResource(exclusionsFile),
          spellChecker.getDataHolder(), exclusionListSperatorRegex);
    }

  } catch (SpellCheckException | IOException ex) {
    log.error("Error occured while loading default Configs for Spellcheck");
  }
}
 
Example #7
Source File: TestMerge.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
/**
 * When [shard] is not in the field list, the [shard] field should not be returned, even
 * if score is in the field list.
 */
@Test
public void testNotWantsShardWithScore() throws Exception {
  try (SolrCore core = h.getCoreContainer().getCore("merge")) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add("q", "*:*");
    params.add("sort", "letter asc");
    params.add("fl", "*,score");

    SolrDocumentList docs = queryDocs(core, "merge", params);
    assertEquals(3, docs.size());
    
    for (SolrDocument doc : docs) {
      assertNull(doc.getFieldValue("[shard]"));
      assertEquals(1.0f, doc.getFieldValue("score"));
    }
  }   
}
 
Example #8
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadRequest_missingLocalParams() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "*:*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNotNull(rsp.getException());
}
 
Example #9
Source File: SyncStrategy.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public PeerSync.PeerSyncResult sync(ZkController zkController, SolrCore core, ZkNodeProps leaderProps,
    boolean peerSyncOnlyWithActive) {
  if (SKIP_AUTO_RECOVERY) {
    return PeerSync.PeerSyncResult.success();
  }

  if (isClosed) {
    log.warn("Closed, skipping sync up.");
    return PeerSync.PeerSyncResult.failure();
  }

  recoveryRequests.clear();

  if (log.isInfoEnabled()) {
    log.info("Sync replicas to {}", ZkCoreNodeProps.getCoreUrl(leaderProps));
  }

  if (core.getUpdateHandler().getUpdateLog() == null) {
    log.error("No UpdateLog found - cannot sync");
    return PeerSync.PeerSyncResult.failure();
  }

  return syncReplicas(zkController, core, leaderProps, peerSyncOnlyWithActive);
}
 
Example #10
Source File: StreamHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public void inform(SolrCore core) {
  String defaultCollection;
  String defaultZkhost;
  CoreContainer coreContainer = core.getCoreContainer();
  this.solrClientCache = coreContainer.getSolrClientCache();
  this.coreName = core.getName();
  String cacheKey = this.getClass().getName() + "_" + coreName + "_";
  this.objectCache = coreContainer.getObjectCache().computeIfAbsent(cacheKey + "objectCache",
      ConcurrentHashMap.class, k-> new ConcurrentHashMap());
  if (coreContainer.isZooKeeperAware()) {
    defaultCollection = core.getCoreDescriptor().getCollectionName();
    defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
    streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
    streamFactory.withDefaultZkHost(defaultZkhost);
    modelCache = coreContainer.getObjectCache().computeIfAbsent(cacheKey + "modelCache",
        ModelCache.class,
        k -> new ModelCache(250, defaultZkhost, solrClientCache));
  }
  streamFactory.withSolrResourceLoader(core.getResourceLoader());

  // This pulls all the overrides and additions from the config
  addExpressiblePlugins(streamFactory, core);
}
 
Example #11
Source File: SuggestComponentTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void reloadCore(boolean createNewCore) throws Exception {
  if (createNewCore) {
    CoreContainer cores = h.getCoreContainer();
    SolrCore core = h.getCore();
    String dataDir1 = core.getDataDir();
    CoreDescriptor cd = core.getCoreDescriptor();
    h.close();
    createCore();
    SolrCore createdCore = h.getCore();
    assertEquals(dataDir1, createdCore.getDataDir());
    assertEquals(createdCore, h.getCore());
  } else {
    h.reload();
    // On regular reloading, wait until the new searcher is registered
    waitForWarming();
  }
  
  assertQ(req("qt", "/select",
      "q", "*:*"), 
      "//*[@numFound='11']"
      );
}
 
Example #12
Source File: HighFrequencyDictionaryFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Dictionary create(SolrCore core, SolrIndexSearcher searcher) {
  if(params == null) {
    // should not happen; implies setParams was not called
    throw new IllegalStateException("Value of params not set");
  }
  String field = (String)params.get(SolrSpellChecker.FIELD);
  
  if (field == null) {
    throw new IllegalArgumentException(SolrSpellChecker.FIELD + " is a mandatory parameter");
  }
  
  float threshold = params.get(THRESHOLD_TOKEN_FREQUENCY) == null ? 0.0f
      : (Float)params.get(THRESHOLD_TOKEN_FREQUENCY);
  
  return new HighFrequencyDictionary(searcher.getIndexReader(), field, threshold);
}
 
Example #13
Source File: TestTlogReplica.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void waitForReplicasCatchUp(int numTry) throws IOException, InterruptedException {
  String leaderTimeCommit = getSolrCore(true).get(0).getDeletionPolicy().getLatestCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
  if (leaderTimeCommit == null) return;
  for (int i = 0; i < numTry; i++) {
    boolean inSync = true;
    for (SolrCore solrCore : getSolrCore(false)) {
      String replicateTimeCommit = solrCore.getDeletionPolicy().getLatestCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
      if (!leaderTimeCommit.equals(replicateTimeCommit)) {
        inSync = false;
        Thread.sleep(500);
        break;
      }
    }
    if (inSync) return;
  }

  fail("Some replicas are not in sync with leader");

}
 
Example #14
Source File: HttpShardHandlerFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected ReplicaListTransformer getReplicaListTransformer(final SolrQueryRequest req) {
  final SolrParams params = req.getParams();
  final SolrCore core = req.getCore(); // explicit check for null core (temporary?, for tests)
  @SuppressWarnings("resource")
  ZkController zkController = core == null ? null : core.getCoreContainer().getZkController();
  if (zkController != null) {
    return requestReplicaListTransformerGenerator.getReplicaListTransformer(
        params,
        zkController.getZkStateReader().getClusterProperties()
            .getOrDefault(ZkStateReader.DEFAULT_SHARD_PREFERENCES, "")
            .toString(),
        zkController.getNodeName(),
        zkController.getBaseUrl(),
        zkController.getSysPropsCacher()
    );
  } else {
    return requestReplicaListTransformerGenerator.getReplicaListTransformer(params);
  }
}
 
Example #15
Source File: UpdateProcessorTestBase.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
protected void processDeleteById(final String chain, String id) throws IOException {
  SolrCore core = h.getCore();
  UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain);
  assertNotNull("No Chain named: " + chain, pc);

  SolrQueryResponse rsp = new SolrQueryResponse();

  SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());

  DeleteUpdateCommand cmd = new DeleteUpdateCommand(req);
  cmd.setId(id);
  UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
  try {
    processor.processDelete(cmd);
  } finally {
    req.close();
  }
}
 
Example #16
Source File: RandomTestDictionaryFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public RandomTestDictionary create(SolrCore core, SolrIndexSearcher searcher) {
  if(params == null) {
    // should not happen; implies setParams was not called
    throw new IllegalStateException("Value of params not set");
  }
  String name = (String)params.get(CommonParams.NAME);
  if (name == null) { // Shouldn't happen since this is the component name
    throw new IllegalArgumentException(CommonParams.NAME + " is a mandatory parameter");
  }
  long maxItems = DEFAULT_MAX_ITEMS;
  Object specifiedMaxItems = params.get(RAND_DICT_MAX_ITEMS);
  if (specifiedMaxItems != null) {
    maxItems = Long.parseLong(specifiedMaxItems.toString());
  }
  return new RandomTestDictionary(name, maxItems);
}
 
Example #17
Source File: SpellcheckComponent.java    From customized-symspell with MIT License 6 votes vote down vote up
@Override
public void inform(SolrCore core) {
  if (initParams == null) {
    return;
  }

  log.info("Initializing spell checkers");

  if (initParams.getName(0).equals("spellcheckers")) {
    Object cfg = initParams.getVal(0);
    if (cfg instanceof NamedList) {
      addSpellChecker(core, (NamedList) cfg);
    } else if (cfg instanceof Map) {
      addSpellChecker(core, new NamedList((Map) cfg));
    } else if (cfg instanceof List) {
      for (Object o : (List) cfg) {
        if (o instanceof Map) {
          addSpellChecker(core, new NamedList((Map) o));
        }
      }
    }
  }

  log.info("Spell checker  Initialization completed");
}
 
Example #18
Source File: SolrFeature.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private LocalSolrQueryRequest makeRequest(SolrCore core, String solrQuery,
    List<String> fqs, String df) {
  final NamedList<String> returnList = new NamedList<String>();
  if ((solrQuery != null) && !solrQuery.isEmpty()) {
    returnList.add(CommonParams.Q, solrQuery);
  }
  if (fqs != null) {
    for (final String fq : fqs) {
      returnList.add(CommonParams.FQ, fq);
    }
  }
  if ((df != null) && !df.isEmpty()) {
    returnList.add(CommonParams.DF, df);
  }
  if (returnList.size() > 0) {
    return new LocalSolrQueryRequest(core, returnList);
  } else {
    return null;
  }
}
 
Example #19
Source File: ReplicateFromLeader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static String getCommitVersion(SolrCore solrCore) {
  IndexCommit commit = solrCore.getDeletionPolicy().getLatestCommit();
  try {
    String commitVersion = commit.getUserData().get(SolrIndexWriter.COMMIT_COMMAND_VERSION);
    if (commitVersion == null) return null;
    else return commitVersion;
  } catch (Exception e) {
    log.warn("Cannot get commit command version from index commit point ",e);
    return null;
  }
}
 
Example #20
Source File: RoutedAlias.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private String doPreemptive(CandidateCollection targetCollectionDesc, SolrCore core, CoreContainer coreContainer) {

    if (!this.preemptiveCreateOnceAlready) {
      preemptiveAsync(() -> {
        try {
          ensureCollection(targetCollectionDesc.creationCollection, coreContainer);
        } catch (Exception e) {
          log.error("Async creation of a collection for routed Alias {} failed!", this.getAliasName(), e);
        }
      }, core);
    }
    return targetCollectionDesc.destinationCollection;
  }
 
Example #21
Source File: CollectionsAPIDistributedZkTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void checkInstanceDirs(JettySolrRunner jetty) throws IOException {
  CoreContainer cores = jetty.getCoreContainer();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    // look for core props file
    Path instancedir = core.getInstancePath();
    assertTrue("Could not find expected core.properties file", Files.exists(instancedir.resolve("core.properties")));

    Path expected = Paths.get(jetty.getSolrHome()).toAbsolutePath().resolve(core.getName());

    assertTrue("Expected: " + expected + "\nFrom core stats: " + instancedir, Files.isSameFile(expected, instancedir));
  }
}
 
Example #22
Source File: TemplatesDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void newCoreUsinglshTemplate() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    SolrCore rankCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, "templateWithrerank", AlfrescoCoreAdminHandler.DEFAULT_TEMPLATE, 2, 1);

    //Call custom actions
    SolrQueryResponse response = callHandler(coreAdminHandler, rankCore, "SUMMARY");
    assertSummaryCorrect(response, rankCore.getName());
}
 
Example #23
Source File: NotRequiredUniqueKeyTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemaLoading() 
{
  SolrCore core = h.getCore();
  IndexSchema schema = core.getLatestSchema();
  SchemaField uniqueKey = schema.getUniqueKeyField();
  
  assertFalse( uniqueKey.isRequired() );
  
  assertFalse( schema.getRequiredFields().contains( uniqueKey ) );
}
 
Example #24
Source File: AlfrescoSolrUtils.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addAcl(SolrQueryRequest solrQueryRequest, SolrCore core, AlfrescoSolrDataModel dataModel, int acltxid, int aclId, int maxReader,
        int totalReader) throws IOException
{
    AddUpdateCommand aclTxCmd = new AddUpdateCommand(solrQueryRequest);
    aclTxCmd.overwrite = true;
    SolrInputDocument aclTxSol = new SolrInputDocument();
    String aclTxId = AlfrescoSolrDataModel.getAclChangeSetDocumentId(new Long(acltxid));
    aclTxSol.addField(FIELD_SOLR4_ID, aclTxId);
    aclTxSol.addField(FIELD_VERSION, "0");
    aclTxSol.addField(FIELD_ACLTXID, acltxid);
    aclTxSol.addField(FIELD_INACLTXID, acltxid);
    aclTxSol.addField(FIELD_ACLTXCOMMITTIME, (new Date()).getTime());
    aclTxSol.addField(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_ACL_TX);
    aclTxCmd.solrDoc = aclTxSol;
    core.getUpdateHandler().addDoc(aclTxCmd);

    AddUpdateCommand aclCmd = new AddUpdateCommand(solrQueryRequest);
    aclCmd.overwrite = true;
    SolrInputDocument aclSol = new SolrInputDocument();
    String aclDocId = AlfrescoSolrDataModel.getAclDocumentId(AlfrescoSolrDataModel.DEFAULT_TENANT, new Long(aclId));
    aclSol.addField(FIELD_SOLR4_ID, aclDocId);
    aclSol.addField(FIELD_VERSION, "0");
    aclSol.addField(FIELD_ACLID, aclId);
    aclSol.addField(FIELD_INACLTXID, "" + acltxid);
    aclSol.addField(FIELD_READER, "GROUP_EVERYONE");
    aclSol.addField(FIELD_READER, "pig");
    for (int i = 0; i <= maxReader; i++)
    {
        aclSol.addField(FIELD_READER, "READER-" + (totalReader - i));
    }
    aclSol.addField(FIELD_DENIED, "something");
    aclSol.addField(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_ACL);
    aclCmd.solrDoc = aclSol;
    core.getUpdateHandler().addDoc(aclCmd);
}
 
Example #25
Source File: SignatureUpdateProcessorFactoryTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * a non-indexed signatureField is fine as long as overwriteDupes==false
 */
@Test
public void testNonIndexedSignatureField() throws Exception {
  SolrCore core = h.getCore();

  checkNumDocs(0);    

  chain = "stored_sig";
  addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"));
  addDoc(adoc("id", "2b", "v_t", "Hello Dude man!", "name", "ali babi'"));
  addDoc(commit());

  checkNumDocs(2);
}
 
Example #26
Source File: ResolveAnalyzerByNameTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemaLoadingSimpleAnalyzer() {
  SolrCore core = h.getCore();
  IndexSchema schema = core.getLatestSchema();
  assertTrue( schema.getFieldTypes().containsKey("text_ws") );
  @SuppressWarnings({"unchecked"})
  SimpleOrderedMap<Object> analyzerProps =
      (SimpleOrderedMap<Object>)schema.getFieldTypeByName("text_ws")
      .getNamedPropertyValues(true).get("analyzer");
  checkTokenizerName(analyzerProps, "whitespace");

  assertNotNull(schema.getFieldTypeByName("text_ws").getIndexAnalyzer());
  assertNotNull(schema.getFieldTypeByName("text_ws").getQueryAnalyzer());
}
 
Example #27
Source File: DefaultSolrCoreState.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void newIndexWriter(SolrCore core, boolean rollback) throws IOException {
  lock(iwLock.writeLock());
  try {
    changeWriter(core, rollback, true);
  } finally {
    iwLock.writeLock().unlock();
  }
}
 
Example #28
Source File: TestDJoin.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * Test that (a) sorting works correctly, so that we get docs 1 and 2 returned (sort values A and B)
 *       and (b) we still get all parts of doc 1 returned even though it ranks third on shard/3
 */
@Test
public void testJoin() throws Exception {
  try (SolrCore core = h.getCoreContainer().getCore("djoin")) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add("q", "*:*");
    params.add("rows", "2");
    params.add("sort", "letter asc");
    params.add("fl", "*,[shard]");

    SolrQueryResponse rsp = query(core, "djoin", params);
    assertNull(rsp.getException());
    SolrDocumentList docs = (SolrDocumentList)rsp.getValues().get("response");
    assertEquals(2, docs.size());
    
    assertEquals(true, docs.get(0).get(DuplicateDocumentList.MERGE_PARENT_FIELD));
    assertEquals(3, docs.get(0).getChildDocumentCount());
    assertEquals("1", docs.get(0).getChildDocuments().get(0).get("id"));
    assertEquals("1", docs.get(0).getChildDocuments().get(1).get("id"));
    assertEquals("1", docs.get(0).getChildDocuments().get(2).get("id"));
    Set<String> letters = new HashSet<>();
    for (SolrDocument doc : docs.get(0).getChildDocuments()) {
      letters.add((String)doc.get("letter"));
    }
    assertEquals(new HashSet<String>(Arrays.asList("A", "D", "E")), letters);
    
    assertEquals(true, docs.get(1).get(DuplicateDocumentList.MERGE_PARENT_FIELD));
    assertEquals(2, docs.get(1).getChildDocumentCount());
    assertEquals("2", docs.get(1).getChildDocuments().get(0).get("id"));
    assertEquals("B", docs.get(1).getChildDocuments().get(0).get("letter"));
    assertEquals("2", docs.get(1).getChildDocuments().get(1).get("id"));
    assertEquals("B", docs.get(1).getChildDocuments().get(1).get("letter"));
  }
}
 
Example #29
Source File: AnalysisAfterCoreReloadTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void tearDown() throws Exception {
  String configDir;
  try (SolrCore core = h.getCoreContainer().getCore(collection)) {
    configDir = core.getResourceLoader().getConfigDir();
  }
  super.tearDown();
  if (new File(configDir, "stopwords.txt.bak").exists()) {
    FileUtils.deleteQuietly(new File(configDir, "stopwords.txt"));
    FileUtils.moveFile(new File(configDir, "stopwords.txt.bak"), new File(configDir, "stopwords.txt"));
  }
}
 
Example #30
Source File: AbstractAlfrescoDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SolrQueryResponse rangeCheck(int shard) throws Exception
{
    int maxAttemps = 10;
    for (int attemp=0; attemp < maxAttemps; ++attemp)
    {
        Collection<SolrCore> cores = getCores(solrShards);
        List<AlfrescoCoreAdminHandler> alfrescoCoreAdminHandlers = getAdminHandlers(solrShards);
        SolrCore core = cores.stream()
                .filter(solrcore -> solrcore.getName().equals("shard" + shard)).findAny().orElseThrow(RuntimeException::new);
        AlfrescoCoreAdminHandler alfrescoCoreAdminHandler = alfrescoCoreAdminHandlers.get(shard);
        SolrQueryResponse response = callHandler(alfrescoCoreAdminHandler, core, "RANGECHECK");
        NamedList<?> values = response.getValues();

        boolean isReady = !Optional.ofNullable(values.get("report"))
                    .map(Object::toString)
                    .filter(r -> r.contains("WARNING=The requested endpoint is not available on the slave"))
                    .isPresent() &&
                !Optional.ofNullable(values.get("exception"))
                    .map(Object::toString)
                    .filter(ex -> ex.contains("not initialized"))
                    .isPresent();

        if (!isReady)
        {
            Thread.sleep(1000);
        }
        else
        {
            return response;
        }
    }

    throw new Exception("impossible to perform rangeChack");
}