Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
janhoy closed pull request #3361: SOLR-7632: Tika module to replace extraction module URL: https://github.com/apache/solr/pull/3361 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
janhoy commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-3311913292 > Also, I wonder if instead of a whole new module, what if we just forced this into the ExtractingRequestHandler.java, and kept it in /extraction? Or do we think it's cleaner to remove /extraction and add /tika? By all means. We could aim for having to "extraction backends" inside extraction handler, i.e. pluggable loader, and reuse all the logic in place for request parsing, arguments etc. And tell people in 9.x that a new experimental tika-server backend is available, just add to the request handler config `loader=org.apache.solr.extraction.loaders.TikaServerDocumentLoader` or similar. And in 10.0 it becomes the default as we remove the in-process loader? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
epugh commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-3309660673 Also, I wonder if instead of a whole new module, what if we just forced this into the ExtractingRequestHandler.java, and kept it in /extraction? Or do we think it's cleaner to remove /extraction and add /tika? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
epugh commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-3309657240 > Impressive results! > > I'd much prefer to see testcontainers. I don't trust mocks in the slightest mocking some external system. Who knows if what we mock is trustworthy or not? There currently is NOT a testcontainer for Tika, as far as I know. What do you say @tballison? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
epugh commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-3309634070 I ran the existing `test_extraction.bats` just to make sure the old stuff still worked. And fixed the tests. Though they are still very mock! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
dsmiley commented on code in PR #3361:
URL: https://github.com/apache/solr/pull/3361#discussion_r2127845663
##
solr/modules/tika/src/java/org/apache/solr/handler/tika/TikaServerDocumentLoader.java:
##
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.handler.tika;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.handler.loader.ContentStreamLoader;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.eclipse.jetty.client.ContentResponse;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.InputStreamRequestContent;
+import org.eclipse.jetty.client.Request;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.MimeTypes;
+import org.noggit.JSONParser;
+import org.noggit.ObjectBuilder;
+
+public class TikaServerDocumentLoader extends ContentStreamLoader {
+
+ private final String tikaServerUrl;
+ private final int connectionTimeout;
+ private final int socketTimeout;
+ private final String idField;
+ private final boolean returnMetadata;
+ private final String metadataPrefix;
+ private final String contentField;
+ private final HttpClient httpClient; // Jetty's HttpClient
+ private final SolrQueryRequest req;
+ private final UpdateRequestProcessor processor;
+
+ public TikaServerDocumentLoader(
+ SolrQueryRequest req,
+ UpdateRequestProcessor processor,
+ String tikaServerUrl,
+ int connectionTimeout,
+ int socketTimeout,
+ String idField,
+ boolean returnMetadata,
+ String metadataPrefix,
+ String contentField,
+ HttpClient jettyClient) {
+this.req = req;
+this.processor = processor;
+this.tikaServerUrl = tikaServerUrl;
+this.connectionTimeout = connectionTimeout;
+this.socketTimeout =
+socketTimeout; // Store it, though specific usage might vary with
Jetty client
+this.idField = idField;
+this.returnMetadata = returnMetadata;
+this.metadataPrefix = metadataPrefix;
+this.contentField = contentField;
+this.httpClient = jettyClient;
+ }
+
+ @Override
+ public void load(
+ SolrQueryRequest req,
+ SolrQueryResponse rsp,
+ ContentStream stream,
+ UpdateRequestProcessor processor)
+ throws Exception {
+String fullTikaServerUrl = this.tikaServerUrl;
+if (!fullTikaServerUrl.endsWith("/")) {
+ fullTikaServerUrl += "/";
+}
+// Using /rmeta/text to ensure X-TIKA:content has the main textual content.
+fullTikaServerUrl += "rmeta/text";
+
+Request jettyRequest = this.httpClient.POST(fullTikaServerUrl);
+jettyRequest.accept(MimeTypes.Type.APPLICATION_JSON.asString());
+
+String reqContentType = stream.getContentType();
+if (reqContentType != null) {
+ jettyRequest.headers(headers -> headers.add(HttpHeader.CONTENT_TYPE,
reqContentType));
+} else {
+ jettyRequest.headers(
+ headers -> headers.add(HttpHeader.CONTENT_TYPE,
"application/octet-stream"));
+}
+
+// Apply request-specific timeout using connectionTimeout.
+// The HttpClient instance itself is configured with an idleTimeout
(derived from
+// socketTimeout).
+jettyRequest.timeout(this.connectionTimeout, TimeUnit.MILLISECONDS);
Review Comment:
weird to use the connection timeout as the request timeout. If we want one
universal timeout for all the things that timeout, then
`this.connectionTimeout` should just be `this.timeout`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
epugh commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-2901322604 Honestly, this looks like what I would expect... We are just trying to do a bit of redirection... Accept a binary doc, forward it to a specific endpoint, take the response from the end point, and then index that/return it to the caller It looks like you have *much* of what is needed...I've contemplated taking this task on, and it always seemed like a "big deal", and I'm almost embarrased to see how little code doing this "redirection" takes! While you could tweak your prompt to get to perfection, maybe this is enough? Get it to compile and see if `test_extraction.bats` passes? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] SOLR-7632: Tika module to replace extraction module [solr]
janhoy commented on PR #3361: URL: https://github.com/apache/solr/pull/3361#issuecomment-2900814848 It got some of the project-specific stuff wrong, so I'll prompt it to fix gradle, use version catalogs, add license headers, use v12 instead of v11 of jetty-clent etc. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
