@Override public void updateDocument(String path, Iterable<? extends IndexableField> doc) throws IOException { addLuceneDoc(LuceneDoc.forUpdate(definition.getIndexPath(), path, doc)); }
@Override public void updateDocument(String path, Iterable<? extends IndexableField> doc) throws IOException { addLuceneDoc(LuceneDoc.forUpdate(definition.getIndexPath(), path, doc)); }
private Set<MediaType> getNonIndexedMediaTypes() { InputStream configStream = null; String configSource = null; try { if (definition.hasCustomTikaConfig()) { configSource = String.format("Custom config at %s", definition.getIndexPath()); configStream = definition.getTikaConfig(); } else { URL configUrl = FulltextIndexEditorContext.class.getResource("tika-config.xml"); configSource = "Default : tika-config.xml"; if (configUrl != null) { configStream = configUrl.openStream(); } } if (configStream != null) { return TikaParserConfig.getNonIndexedMediaTypes(configStream); } } catch (TikaException | IOException | SAXException e) { log.warn("Tika configuration not available : " + configSource, e); } finally { IOUtils.closeQuietly(configStream); } return Collections.emptySet(); }
public void enableReindexMode(){ reindex = true; ReindexOperations reindexOps = new ReindexOperations(root, definitionBuilder, definition.getIndexPath(), newDefinitionBuilder()); definition = reindexOps.apply(indexDefnRewritten); }
private static TikaConfigHolder initializeTikaConfig(@Nullable IndexDefinition definition) { ClassLoader current = Thread.currentThread().getContextClassLoader(); InputStream configStream = null; String configSource = null; try { Thread.currentThread().setContextClassLoader(FulltextIndexEditorContext.class.getClassLoader()); if (definition != null && definition.hasCustomTikaConfig()) { log.debug("[{}] Using custom tika config", definition.getIndexName()); configSource = "Custom config at " + definition.getIndexPath(); configStream = definition.getTikaConfig(); } else { URL configUrl = FulltextIndexEditorContext.class.getResource("tika-config.xml"); if (configUrl != null) { configSource = configUrl.toString(); configStream = configUrl.openStream(); } } if (configStream != null) { return new TikaConfigHolder(new TikaConfig(configStream), configSource); } } catch (TikaException | IOException | SAXException e) { log.warn("Tika configuration not available : " + configSource, e); } finally { IOUtils.closeQuietly(configStream); Thread.currentThread().setContextClassLoader(current); } return new TikaConfigHolder(TikaConfig.getDefaultConfig(), "Default Config"); }
@Test public void indexNameIsIndexPath() throws Exception { NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); newLucenePropertyIndexDefinition(index, "lucene", ImmutableSet.of("foo"), null); NodeState before = builder.getNodeState(); builder.setProperty("foo", "bar"); NodeState after = builder.getNodeState(); NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY); String indexPath = "/oak:index/lucene"; IndexDefinition defn = new IndexDefinition(root, indexed.getChildNode("oak:index").getChildNode("lucene"), indexPath); assertEquals(indexPath, defn.getIndexName()); assertEquals(indexPath, defn.getIndexPath()); }