Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 68 additions & 70 deletions docs/source/admin/fs/local-fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -512,70 +512,80 @@ For example, a PDF document could generate:
.. code:: json

{
"date" : "2016-07-07T08:37:42Z",
"pdf:PDFVersion" : "1.5",
"xmp:CreatorTool" : "Microsoft Word",
"Keywords" : "keyword1, keyword2",
"access_permission:assemble_document" : "true",
"access_permission:can_modify" : "true",
"access_permission:can_print" : "true",
"access_permission:can_print_faithful" : "true",
"access_permission:extract_content" : "true",
"access_permission:extract_for_accessibility" : "true",
"access_permission:fill_in_form" : "true",
"access_permission:modify_annotations" : "true",
"access_permission:can_print_degraded" : "true",
"subject" : "Test Tika Object",
"Content-Length" : "101643",
"Content-Type" : "application/pdf",
"Content-Type-Magic-Detected" : "application/pdf",
"dc:creator" : "David Pilato",
"dc:format" : "application/pdf; version=1.5",
"dc:language" : "en-US",
"dc:subject" : "keyword1, keyword2",
"dc:title" : "Test Tika title",
"dcterms:created" : "2016-07-07T08:37:42Z",
"Last-Modified" : "2016-07-07T08:37:42Z",
"dcterms:modified" : "2016-07-07T08:37:42Z",
"dc:format" : "application/pdf; version=1.5",
"title" : "Test Tika title",
"Last-Save-Date" : "2016-07-07T08:37:42Z",
"access_permission:fill_in_form" : "true",
"meta:save-date" : "2016-07-07T08:37:42Z",
"pdf:charsPerPage" : "42",
"pdf:containsDamagedFont" : "false",
"pdf:containsNonEmbeddedFont" : "false",
"pdf:docinfo:created" : "2016-07-07T08:37:42Z",
"pdf:docinfo:creator" : "David Pilato",
"pdf:docinfo:creator_tool" : "Microsoft Word",
"pdf:docinfo:keywords" : "keyword1, keyword2",
"pdf:docinfo:modified" : "2016-07-07T08:37:42Z",
"pdf:docinfo:subject" : "Test Tika Object",
"pdf:docinfo:title" : "Test Tika title",
"pdf:encrypted" : "false",
"dc:title" : "Test Tika title",
"modified" : "2016-07-07T08:37:42Z",
"cp:subject" : "Test Tika Object",
"Content-Type" : "application/pdf",
"X-Parsed-By" : "org.apache.tika.parser.DefaultParser",
"creator" : "David Pilato",
"meta:author" : "David Pilato",
"dc:subject" : "keyword1, keyword2",
"meta:creation-date" : "2016-07-07T08:37:42Z",
"created" : "Thu Jul 07 10:37:42 CEST 2016",
"access_permission:extract_for_accessibility" : "true",
"access_permission:assemble_document" : "true",
"xmpTPg:NPages" : "2",
"Creation-Date" : "2016-07-07T08:37:42Z",
"access_permission:extract_content" : "true",
"access_permission:can_print" : "true",
"meta:keyword" : "keyword1, keyword2",
"Author" : "David Pilato",
"access_permission:can_modify" : "true"
"pdf:eofOffsets" : "101460",
"pdf:hasCollection" : "false",
"pdf:hasMarkedContent" : "true",
"pdf:hasXFA" : "false",
"pdf:hasXMP" : "false",
"pdf:incrementalUpdateCount" : "1",
"pdf:num3DAnnotations" : "0",
"pdf:ocrPageCount" : "0",
"pdf:overallPercentageUnmappedUnicodeChars" : "0.0",
"pdf:PDFVersion" : "1.5",
"pdf:totalUnmappedUnicodeChars" : "0",
"pdf:unmappedUnicodeCharsPerPage" : "0",
"X-TIKA:Parsed-By" : "org.apache.tika.parser.pdf.PDFParser",
"X-TIKA:Parsed-By-Full-Set" : "org.apache.tika.parser.pdf.PDFParser",
"X-TIKA:resourceName" : "test.pdf",
"X-TIKA:versionCount" : "1",
"xmp:CreatorTool" : "Microsoft Word",
"xmpTPg:NPages" : "2"
}

Where a MP3 file would generate:

.. code:: json

{
"xmpDM:genre" : "Vocal",
"X-Parsed-By" : "org.apache.tika.parser.DefaultParser",
"creator" : "David Pilato",
"channels" : "2",
"Content-Type" : "audio/mpeg",
"Content-Type-Magic-Detected" : "audio/mpeg",
"dc:creator" : "David Pilato",
"dc:title" : "Test Tika",
"samplerate" : "44100",
"version" : "MPEG 3 Layer III Version 1",
"X-TIKA:Parsed-By" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:Parsed-By-Full-Set" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:resourceName" : "test.mp3",
"xmpDM:album" : "FS Crawler",
"xmpDM:trackNumber" : "1",
"xmpDM:releaseDate" : "2016",
"meta:author" : "David Pilato",
"xmpDM:artist" : "David Pilato",
"dc:creator" : "David Pilato",
"xmpDM:audioCompressor" : "MP3",
"title" : "Test Tika",
"xmpDM:audioChannelType" : "Stereo",
"version" : "MPEG 3 Layer III Version 1",
"xmpDM:logComment" : "Hello but reverted",
"xmpDM:audioCompressor" : "MP3",
"xmpDM:audioSampleRate" : "44100",
"channels" : "2",
"dc:title" : "Test Tika",
"Author" : "David Pilato",
"xmpDM:duration" : "1018.775146484375",
"Content-Type" : "audio/mpeg",
"samplerate" : "44100"
"xmpDM:duration" : "1.0187751054763794",
"xmpDM:genre" : "Vocal",
"xmpDM:logComment" : "Hello but reverted",
"xmpDM:releaseDate" : "2016",
"xmpDM:trackNumber" : "1"
}

.. note::
Expand Down Expand Up @@ -879,31 +889,19 @@ Tika Config Path

.. versionadded:: 2.10

If you want to override the default tika parser configuration, you can set the path to a custom tika
configuration file, which will be used instead.
.. warning::

Since the upgrade to Apache Tika 4, ``fs.tika_config_path`` is **temporarily not supported**. Tika 4
removed the XML-based Tika configuration file mechanism, and there is currently no drop-in replacement
to assemble a parser from a configuration file. If this setting is provided, FSCrawler fails fast with
a clear configuration error. Support is expected to return on top of Tika 4's new JSON-based
configuration.

This setting used to let you override the default Tika parser configuration by pointing to a custom Tika
configuration file:

.. code:: yaml

name: "test"
fs:
tika_config_path: '/path/to/tikaConfig.xml'

An example tika config file is shown below. See |Tika_configuring|_ for more information.

.. code:: xml

<?xml version="1.0" encoding="UTF-8"?>
<properties>
<service-loader dynamic="true"/>
<service-loader loadErrorHandler="IGNORE"/>
<parsers>
<!-- Use Default Parser for files, but Default Parser will never use HTML parser -->
<parser class="org.apache.tika.parser.DefaultParser">
<parser-exclude class="org.apache.tika.parser.html.JsoupParser"/>
</parser>
<!-- Use a different parser for XHTML -->
<parser class="org.apache.tika.parser.xml.XMLParser">
<mime>application/xhtml+xml</mime>
</parser>
</parsers>
</properties>
14 changes: 10 additions & 4 deletions docs/source/admin/fs/rest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ You will get back your document as it has been stored by elasticsearch:
},
"meta" : {
"raw" : {
"X-Parsed-By" : "org.apache.tika.parser.DefaultParser",
"Content-Encoding" : "ISO-8859-1",
"Content-Type" : "text/plain; charset=ISO-8859-1"
"Content-Type" : "text/plain; charset=ISO-8859-1",
"Content-Type-Magic-Detected" : "text/plain",
"X-TIKA:Parsed-By" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:Parsed-By-Full-Set" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:resourceName" : "test.txt"
}
},
"path" : {
Expand Down Expand Up @@ -187,9 +190,12 @@ will give
},
"meta" : {
"raw" : {
"X-Parsed-By" : "org.apache.tika.parser.DefaultParser",
"Content-Encoding" : "ISO-8859-1",
"Content-Type" : "text/plain; charset=ISO-8859-1"
"Content-Type" : "text/plain; charset=ISO-8859-1",
"Content-Type-Magic-Detected" : "text/plain",
"X-TIKA:Parsed-By" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:Parsed-By-Full-Set" : "org.apache.tika.parser.DefaultParser",
"X-TIKA:resourceName" : "test.txt"
}
},
"path" : {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/fscrawler.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Version=2.10-SNAPSHOT
JavaVersion=17

[3rdParty]
TikaVersion=3.3.1
TikaVersion=4.0.0-beta-1
ElasticsearchVersion7=7.17.29
ElasticsearchVersion8=8.19.5
ElasticsearchVersion9=9.3.0
Expand Down
14 changes: 14 additions & 0 deletions docs/source/release/2.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ enough. Thanks to dadoonet.
* We don't support anymore the ``elasticsearch.nodes.url`` setting. You need to use ``elasticsearch.urls``
instead. Thanks to dadoonet.
* The ``_upload`` REST endpoint has been removed. Please now use the ``_document`` endpoint. Thanks to dadoonet.
* The Apache Tika 4 upgrade changes several ``meta.raw.*`` metadata key names. If you search, aggregate or
map these fields, you will need to update your queries and index templates accordingly:

* Image and EXIF metadata (JPEG, PNG, TIFF, …) keys are now namespaced under ``img:``. For example
``Number of Tables`` becomes ``img:Number of Tables`` and ``Exif IFD0:Orientation`` becomes
``img:Exif IFD0:Orientation``.
* The resource name key ``resourceName`` is renamed to ``X-TIKA:resourceName``.
* New keys are now produced, such as ``Content-Type-Magic-Detected``, ``X-TIKA:Parsed-By-Full-Set`` and,
for text documents, the encoding detection keys ``X-TIKA:detectedEncoding``,
``X-TIKA:encodingDetectionTrace`` and ``X-TIKA:encodingDetector``.

Thanks to dadoonet.

New
---
Expand All @@ -38,6 +50,8 @@ New
* You can now remove a document in Elasticsearch using FSCrawler ``_document`` endpoint. See :ref:`rest-service`. Thanks to dadoonet.
* Implement our own HTTP Client for Elasticsearch. Thanks to dadoonet.
* Add option to set path to custom tika config file. See :ref:`local-fs-settings`. Thanks to iadcode.
**Note**: this option is temporarily disabled after the Apache Tika 4 upgrade, which removed the XML-based
configuration file mechanism. It is expected to return on top of Tika 4's JSON-based configuration.
* Support for Index Templates. See :ref:`mappings`. Thanks to dadoonet.
* Support for Aliases. You can now index to an alias. Thanks to dadoonet.
* Support for Access Token and Api Keys instead of Basic Authentication. See :ref:`credentials`. Thanks to dadoonet.
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch-client/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Logger name="fr.pilato.elasticsearch.crawler.fs" level="info" additivity="false">
<AppenderRef ref="CONSOLE"/>
</Logger>
<Logger name="fr.pilato.elasticsearch.crawler.fs.client" level="debug" additivity="false">
<Logger name="fr.pilato.elasticsearch.crawler.fs.client" level="info" additivity="false">
<AppenderRef ref="CONSOLE"/>
</Logger>
<Logger name="org.glassfish" level="info" additivity="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
import java.nio.file.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tika.parser.external.ExternalParser;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.parser.ocr.TesseractOCRParser;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.Assumptions;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;

/** Test all type of documents we have */
@VerySlow
Expand Down Expand Up @@ -253,14 +254,28 @@ void chineseContent369() throws ElasticsearchClientException {
}

@Test
@DisabledIf(value = "tesseractNotInstalled", disabledReason = "Tesseract is not installed")
void ocr() throws ElasticsearchClientException {
Assumptions.assumeThat(ExternalParser.check("tesseract"))
.as("Tesseract is not installed so we are skipping this test")
.isTrue();
runSearch("test-ocr.png", "words");
runSearch("test-ocr.pdf", "words");
}

/**
* Condition for {@link #ocr()}. Tika 4 removed {@code ExternalParser.check()}, so we reuse the same Tesseract
* availability check as production code. Returns {@code true} (disabling the test) when Tesseract is not installed
* or cannot be configured.
*
* @return {@code true} when Tesseract is unavailable
*/
@SuppressWarnings("unused")
static boolean tesseractNotInstalled() {
try {
return !new TesseractOCRParser().hasTesseract();
} catch (TikaConfigException e) {
return true;
}
}

@Test
void shiftJisEncoding() throws ElasticsearchClientException {
runSearch("issue-400-shiftjis.txt", "elasticsearch");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
}

@Test
void documentWithExternalTags() throws Exception {

Check warning on line 276 in integration-tests/src/test/java/fr/pilato/elasticsearch/crawler/fs/test/integration/elasticsearch/FsCrawlerRestIT.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce the number of assertions from 41 to less than 25.

See more on https://sonarcloud.io/project/issues?id=dadoonet_fscrawler&issues=AZ89TnLWj5FB4xK0eegA&open=AZ89TnLWj5FB4xK0eegA&pullRequest=2432
// We iterate over all sample files, and we try to locate any existing tag file
// which can overwrite the data we extracted
AtomicInteger numFiles = new AtomicInteger();
Expand Down Expand Up @@ -372,7 +372,7 @@
checkDocument("replace_meta_only.txt", hit -> {
Assertions.assertThat((String) JsonPath.read(hit.getSource(), "$.content"))
.contains("This file content will be extracted");
Assertions.assertThat((String) JsonPath.read(hit.getSource(), "$.meta.raw.resourceName"))
Assertions.assertThat((String) JsonPath.read(hit.getSource(), "$.meta.raw['X-TIKA:resourceName']"))
.isEqualTo("another-file-name.txt");
Assertions.assertThatThrownBy(() -> JsonPath.read(hit.getSource(), "$.external"))
.isInstanceOf(PathNotFoundException.class);
Expand Down
Loading
Loading