On Tika's website it says (concerning tika-app-1.2.jar) it can be used in server mode. Does anyone know how to send documents and receive parsed text from this server once it is running?
标签:
apache-tika
相关问题
- Files locked after indexing
- Parsing HTML issues with Apache Tika
- Using Solr CELL's ExtractingRequestHandler to
- Configuring Tika With Solr
- Managed bean with a parameterized bean class must
相关文章
- How to create Custom model using OpenNLP?
- Apache Tika how to extract html body with out head
- “java.lang.SecurityException: Prohibited package n
- Unable to extract scanned pdf using TesseractOCRCo
- how to parse html with nutch and index specific ta
- Memory Leak Issue With PDFBox
- PDFBox adding white spaces within words
- Elasticsearch Parse Exception error when attemptin
To enhance Gagravarr perfect answer:
Tika supports two "server" modes. The simpler and original is the
--server
flag of Tika-App. The more functional, but also more recent is the JAX-RS JSR-311 server component, which is an additional jar.The Tika-App Network Server is very simple to use. Simply start Tika-App with the
--server
flag, and a--port ###
flag telling it what port to listen on. Then, connect to that port and send it a single file. You'll get back the html version. NetCat works well for this, something likejava -jar tika-app.jar --server --port 12345
followed bync 127.0.0.1 12345 < MyFileToExtract
will get you back the htmlThe JAX-RS JSR-311 server component supports a few different urls, for things like metadata, plain text etc. You start the server with
java -jar tika-server.jar
, then do HTTP put calls to the appropriate url with your input document and you'll get the resource back. There are loads of details and examples (including using curl for testing) on the wiki pageThe Tika App Network Server is fairly simple, only supports one mode (extract to HTML), and is generally used for testing / demos / prototyping / etc. The Tika JAXRS Server is a fully RESTful service which talks HTTP, and exposes a wide range of Tika's modes. It's the generally recommended way these days to interface with Tika over the network, and/or from non-Java stacks.
Just adding to @Gagravarr's great answer.
When talking about Tika in server mode, it is important to differentiate between two versions which can otherwise cause confusion:
The first option only provides text extraction and returns the content as HTML. Most likely, what you really want is the second option, which is a RESTful service exposing many more of Tika's features.
You can simply download the tika-server.jar from the Tika project site. Start the server using
The -h 0.0.0.0 (host) option makes the server listen for any incoming requests, otherwise without it it would only listen for requests from localhost. You can also add the -p option to change the port, otherwise it defaults to 9998.
Then, once the server has started you can simply access it using your browser. It will list all available endpoints.
Finally to extract meta data from a file you can use cURL like this:
Returns the meta data as key/value pairs one per line. You can also have Tika return the results as JSON by adding the proper accept header:
[Update 2015-01-19] Previously the comment said that tika-server.jar is not available as download. Fixed that since it actually does exist as a binary download.