[jira] [Commented] (TIKA-3226) Add custom connector endpoint

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] [Commented] (TIKA-3226) Add custom connector endpoint

L. C. Hsieh (Jira)

    [ https://issues.apache.org/jira/browse/TIKA-3226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17236191#comment-17236191 ]

Tim Allison commented on TIKA-3226:

Yes, yes and yes.  You've brought together two ideas that have been percolating for a while.

First, the fetchers...  Can we use the existing: https://github.com/apache/tika/blob/main/tika-server/src/main/java/org/apache/tika/server/InputStreamFactory.java ?

We could do service loading of inputstreamfactories and each one would be required to detect whether it should be used based on info the in the httpheaders.
 For example, when you send the file url: "fileUrl:file://docs/mydoc.xlsx" or "fileUrl:s3://blah.xlsx", the localfile fetcher would trigger on the first, and the s3 fetcher would trigger on the second.

We'd have a CompositeInputStreamFactory that would do the service loading and use the available detectors to figure out which one to apply for each request.

We could extend TikaConfig into TikaServerConfig to allow for configuration along the lines we currently have for parsers/detectors and other components.

We should deprecate https://github.com/apache/tika/blob/main/tika-server/src/main/java/org/apache/tika/server/InputStreamFactory.java#L34

and only allow https://github.com/apache/tika/blob/main/tika-server/src/main/java/org/apache/tika/server/InputStreamFactory.java#L35

The fetcher would populate the metadata object with metadata available from the fetch, e.g. if you're fetching a stream from a db, you might want to inject other metadata from the db.

> Add custom connector endpoint
> -----------------------------
>                 Key: TIKA-3226
>                 URL: https://issues.apache.org/jira/browse/TIKA-3226
>             Project: Tika
>          Issue Type: New Feature
>          Components: server
>            Reporter: Nicholas DiPiazza
>            Priority: Major
> Let's say you call the following api to parse a file and get its metadata and body content:
> {code}
> /rmeta/text
> {code}
> In order to do this, the caller needs to send the file to the tika server, then get the metadata and body sent to the caller. When you are working in microservices, this causes a lot of inner-service network communication.
> You can cut down on a majority of this overhead by using the local file system optimization. So that you send a file path instead of the entire file. But this obviously only works when you are on the same machine.
> Ideally - we would have a way to deploy "connector plugins" into tika, and be able to send files to be parsed with these plugins (asynchronously?).
> {code}
> /connector/{fetcherId}/{emitterId}
> {code}
> The Fetcher interface:
> init(Map initParams)
>   - initializes the fetcher (for example, initialize an http connection pool, etc)
> void fetch(Map parseParams, Metadata metadata, OutputStream bodyOutputStream)
>   - fetches the document indicated by parseParams and does whatever it is you want with it (for example, download a file from a web data source, then index the document into Solr). Sends the body to bodyOutputStream and metadata object will be populated with the metadata).
> The Emitter interface would be
> init(Map initParams)
>   - initializes the emitter. (for example, initialize a buffer to store output documents to solr, connect to solr, etc)
> void emit(Map parseParams, Fetcher fetcher)
>   - fetches and parses the "document" using the passed in fetcher, then emits it meaningfully.
> We could provide the most common fetchers and emitters such as:
> HttpFetcher
> S3Fetcher
> SolrEmitter
> ...

This message was sent by Atlassian Jira