This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new a99ff066f40 SOLR-4841: DetectedLanguage constructor should be public 
(#5070)
a99ff066f40 is described below

commit a99ff066f405b11ce1fbb70ca2c23aba7eccda37
Author: Nick <[email protected]>
AuthorDate: Sat Oct 10 04:46:37 2026 -0600

    SOLR-4841: DetectedLanguage constructor should be public (#5070)
---
 ...LR-4841-detectedlanguage-public-constructor.yml |  8 ++++
 .../solr/update/processor/DetectedLanguage.java    |  2 +-
 .../custom/CustomLanguageIdentifierTest.java       | 49 ++++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git 
a/changelog/unreleased/SOLR-4841-detectedlanguage-public-constructor.yml 
b/changelog/unreleased/SOLR-4841-detectedlanguage-public-constructor.yml
new file mode 100644
index 00000000000..fbd26467880
--- /dev/null
+++ b/changelog/unreleased/SOLR-4841-detectedlanguage-public-constructor.yml
@@ -0,0 +1,8 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+title: The DetectedLanguage constructor in the langid module is now public, so 
custom LanguageIdentifierUpdateProcessor subclasses can return results.
+type: changed
+authors:
+  - name: Nick Shanin
+links:
+  - name: SOLR-4841
+    url: https://issues.apache.org/jira/browse/SOLR-4841
diff --git 
a/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java
 
b/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java
index 07d4e7530df..0735f1a40d6 100644
--- 
a/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java
+++ 
b/solr/modules/langid/src/java/org/apache/solr/update/processor/DetectedLanguage.java
@@ -21,7 +21,7 @@ public class DetectedLanguage {
   private final String langCode;
   private final Double certainty;
 
-  DetectedLanguage(String lang, Double certainty) {
+  public DetectedLanguage(String lang, Double certainty) {
     this.langCode = lang;
     this.certainty = certainty;
   }
diff --git 
a/solr/modules/langid/src/test/org/apache/solr/update/processor/custom/CustomLanguageIdentifierTest.java
 
b/solr/modules/langid/src/test/org/apache/solr/update/processor/custom/CustomLanguageIdentifierTest.java
new file mode 100644
index 00000000000..ce9a81d5d5e
--- /dev/null
+++ 
b/solr/modules/langid/src/test/org/apache/solr/update/processor/custom/CustomLanguageIdentifierTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.update.processor.custom;
+
+import java.io.Reader;
+import java.util.List;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.processor.DetectedLanguage;
+import org.apache.solr.update.processor.LanguageIdentifierUpdateProcessor;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+
+/** A language identifier living outside the processor package can build its 
own results. */
+public class CustomLanguageIdentifierTest extends SolrTestCase {
+
+  /** Minimal custom implementation; compiling it is the main check. */
+  static class FixedLanguageIdentifier extends 
LanguageIdentifierUpdateProcessor {
+    FixedLanguageIdentifier(
+        SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor 
next) {
+      super(req, rsp, next);
+    }
+
+    @Override
+    protected List<DetectedLanguage> detectLanguage(Reader solrDocReader) {
+      return List.of(new DetectedLanguage("sv", 0.75));
+    }
+  }
+
+  public void testDetectedLanguageCanBeCreatedOutsidePackage() {
+    DetectedLanguage lang = new DetectedLanguage("en", 0.9);
+    assertEquals("en", lang.getLangCode());
+    assertEquals(0.9, lang.getCertainty(), 0.0);
+  }
+}

Reply via email to