#2097 Tika ParserBolt: limit the extracted text with parser.tika.text.maxlength (#2174)

ParserBolt built its text handler with BodyContentHandler(-1), which
removes the limit Tika applies by default, and there was no way to set
one. The whole text of a document was held as a single String next to
the original bytes until the tuple was emitted, so a large body reaching
the bolt could take a lot of the worker heap.

The new key parser.tika.text.maxlength sets the maximum number of
characters of text kept per document. When the limit is reached Tika
stops the parse with a WriteLimitReachedException; the bolt now keeps
the text and outlinks extracted up to that point, sets
parse.text.trimmed to true in the metadata, counts it under
text_trimmed and emits the document instead of failing it with a parse
error. The default stays -1 so the behaviour does not change unless the
key is set; any negative value means no limit, since Tika itself only
accepts exactly -1 and fails every document on other negative values.

The parse timeout described in the issue is left for a follow-up.
4 files changed
tree: c75cdacd5ba8885dcb5a94251d5882b482c3c5a4
  1. .github/
  2. .mvn/
  3. archetype/
  4. core/
  5. docs/
  6. external/
  7. .asf.yaml
  8. .editorconfig
  9. .gitattributes
  10. .gitignore
  11. AGENTS.md
  12. assembly.xml
  13. checkstyle.xml
  14. CONTRIBUTING.md
  15. DISCLAIMER-BINARIES.txt
  16. LICENSE
  17. NOTICE
  18. pom.xml
  19. README.md
  20. RELEASING.md
  21. SECURITY.md
  22. THIRD-PARTY.properties
  23. THIRD-PARTY.txt
README.md

StormCrawler

license Build Status javadoc

Apache StormCrawler is an open source collection of resources for building low-latency, scalable web crawlers on Apache Storm. It is provided under Apache License and is written mostly in Java.

Quickstart

NOTE: These instructions assume that you have Apache Maven installed. You will need to install Apache Storm 3.1.0 to run the crawler.

StormCrawler requires Java 25 or above. To execute tests, it requires you to have a locally installed and working Docker environment.

Once Storm is installed, the easiest way to get started is to generate a new StormCrawler project following the instructions below:

mvn archetype:generate -DarchetypeGroupId=org.apache.stormcrawler -DarchetypeArtifactId=stormcrawler-archetype -DarchetypeVersion=<CURRENT_VERSION>

Be sure to replace <CURRENT_VERSION> with the latest released version, which you can find on search.maven.org.

You'll be asked to enter a groupId (e.g. com.mycompany.crawler), an artefactId (e.g. stormcrawler), a version, a package name and details about the user agent to use.

This will not only create a fully formed project containing a POM with the dependency above but also the default resource files, a default CrawlTopology class and a configuration file. Enter the directory you just created (should be the same as the artefactId you specified earlier) and follow the instructions on the README file.

Alternatively if you can‘t or don’t want to use the Maven archetype above, you can simply copy the files from archetype-resources.

Have a look at crawler.flux, the crawler-conf.yaml file as well as the files in src/main/resources/, they are all that is needed to run a crawl topology : all the other components come from the core module.

Getting help

The documentation is a good place to start your investigations but if you are stuck please use the tag stormcrawler on StackOverflow or ask a question in the discussions section.

The project website has a page listing companies providing commercial support for Apache StormCrawler.

Note for developers

Please format your code before submitting a PR with

mvn git-code-format:format-code -Dgcf.globPattern="**/*" -Dskip.format.code=false

You can enable pre-commit format hooks by running:

mvn clean install -Dskip.format.code=false

Building from source

The requirements for building from source are as follows

  • JDK 25+
  • Apache Maven 3
  • Docker (if you want to run tests)

The build itself is straightforward:

mvn clean install

Note: We use some binary files for testing advanced crawler functionality. These files are located exclusively in the src/test directories of the respective modules.

Thanks

alt tag

YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.