Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public class ICUCollationField extends FieldType {

private static void warnOrFailUdvas(boolean failHardOnUdvas) {
// NOTE: it may seem odd that we're checking these conditions ourselves rather than relying on
// the internal
// checking of `assertWarnOrFail(...)`. But the main reason we're logging this error via
// `XMLConfigFile.assertWarnOrFail(...)` is because this is at its root an xml config file
// the internal checking of `assertWarnOrFail(...)`. But the main reason we're logging this
// error via `XMLConfigFile.assertWarnOrFail(...)` is because this is at its root a xml config
// file
// error, so we log in a way that's consistent with that.
assertWarnOrFail(UDVAS_MESSAGE, false, failHardOnUdvas);
}
Expand All @@ -134,7 +134,7 @@ protected void init(IndexSchema schema, Map<String, String> args) {
super.init(schema, args);
}

/** Setup the field according to the provided parameters */
/** Set up the field according to the provided parameters */
private void setup(ResourceLoader loader, Map<String, String> args) {
String custom = args.remove("custom");
String localeID = args.remove("locale");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.solr.common.util.Pair;
import org.apache.solr.core.SolrCore;
import org.apache.solr.filestore.ClusterFileStore;
import org.apache.solr.filestore.FileStore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
Expand All @@ -59,7 +58,7 @@
*
* <p>See the <a
* href="https://solr.apache.org/guide/solr/latest/getting-started/tutorial-opennlp.html">Tutorial</a>
* for the step by step guide.
* for a step-by-step guide.
*
* <p>The <code>source</code> field(s) can be configured as either:
*
Expand Down Expand Up @@ -473,8 +472,6 @@ public final UpdateRequestProcessor getInstance(

{
// Initialize the categorizer.
FileStore fs = req.getCoreContainer().getFileStore();

var path = solrHome.resolve(ClusterFileStore.FILESTORE_DIRECTORY);
Path modelFile = Path.of(model);
Path vocabFile = Path.of(vocab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void testNegativeRangeQuery() {

/**
* Test canonical decomposition with turkish primary strength. With this sort order, İ is the
* uppercase form of i, and I is the uppercase form of ı. We index a decomposed form of İ.
* uppercase form of i, and "I" is the uppercase form of ı. We index a decomposed form of İ.
*/
public void testCanonicalDecomposition() {
assertQ(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testBasicTermQuery() {
}

/**
* Test rangequery again with the DIN 5007-1 collator. We do a range query of tone .. tp, in
* Test rangequery again with the DIN 5007-1 collator. We do a range query of "tone" to "tp", in
* binary order this would retrieve nothing due to case and accent differences.
*/
public void testBasicRangeQuery() {
Expand Down Expand Up @@ -148,7 +148,7 @@ public void testNegativeRangeQuery() {

/**
* Test canonical decomposition with turkish primary strength. With this sort order, İ is the
* uppercase form of i, and I is the uppercase form of ı. We index a decomposed form of İ.
* uppercase form of i, and "I" is the uppercase form of ı. We index a decomposed form of İ.
*/
public void testCanonicalDecomposition() {
assertQ(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FlatKeysAttrVisitor implements AttrVisitor {

/**
* @param attrs A map of attributes to set. Note the map has ordered keys: this is required for
* complex sub-types so that instantiation of a value precedes setting its attributes.
* complex subtypes so that instantiation of a value precedes setting its attributes.
*/
FlatKeysAttrVisitor(LinkedHashMap<String, String> attrs) {
this.attrs = attrs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.nio.file.Path;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.response.Cluster;
Expand Down Expand Up @@ -118,7 +117,7 @@ private StringBuilder toString(List<Cluster> clusters, String indent, StringBuil
clusters.forEach(
c -> {
sb.append(indent);
sb.append("- " + c.getLabels().stream().collect(Collectors.joining("; ")));
sb.append("- " + String.join("; ", c.getLabels()));
if (!c.getDocs().isEmpty()) {
sb.append(" [" + c.getDocs().size() + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void testParamOtherTopics() throws Exception {
* shorter when highlighter is in use.
*/
@Test
public void testClusteringOnHighlights() throws Exception {
public void testClusteringOnHighlights() {
String query = "+snippet:mine +" + QUERY_TESTSET_SAMPLE_DOCUMENTS;

Consumer<ModifiableSolrParams> common =
Expand Down Expand Up @@ -179,7 +179,7 @@ public void testClusteringOnHighlights() throws Exception {
* check that the results differ.
*/
@Test
public void testSummaryFragSize() throws Exception {
public void testSummaryFragSize() {
String query = "+snippet:mine +" + QUERY_TESTSET_SAMPLE_DOCUMENTS;

Consumer<ModifiableSolrParams> common =
Expand Down Expand Up @@ -243,7 +243,7 @@ public void testPassingAttributesViaSolrConfig() throws Exception {

/** Test maximum label truncation. */
@Test
public void testParamMaxLabels() throws Exception {
public void testParamMaxLabels() {
List<Cluster<SolrDocument>> clusters =
clusters(
"mock",
Expand Down Expand Up @@ -339,7 +339,7 @@ private StringBuilder toString(
clusters.forEach(
c -> {
sb.append(indent);
sb.append("- " + c.getLabels().stream().collect(Collectors.joining("; ")));
sb.append("- " + String.join("; ", c.getLabels()));
if (!c.getDocuments().isEmpty()) {
sb.append(" [" + c.getDocuments().size() + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ private static void assertSearchResults(
if (log.isInfoEnabled()) {
log.info("Rank {}: doc {} (id={}), score: {}", r, sd.doc, doc.get("id"), sd.score);
}
int idx = Integer.valueOf(doc.get("id"));
int idx = Integer.parseInt(doc.get("id"));
assertTrue("Expected doc id is missing:" + idx, expected.contains(idx));
}
assertTrue(numResults + " TopK results were returned instead of " + TOPK, numResults == TOPK);
assertEquals(numResults + " TopK results were returned instead of " + TOPK, TOPK, numResults);
}

private static List<List<Float>> generateRandomVectors(Random random, int size, int dimensions) {
List<List<Float>> dataset = new ArrayList<List<Float>>();
for (int i = 0; i < size; i++) {
List<Float> row = new ArrayList<Float>();
List<Float> row = new ArrayList<>();
for (int j = 0; j < dimensions; j++) {
row.add(random.nextFloat() * 100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
public interface ExtractingParams {

/** Map all generated attribute names to field names with lowercase and underscores. */
public static final String LOWERNAMES = "lowernames";
String LOWERNAMES = "lowernames";

/** if true, ignore TikaException (give up to extract text but index meta data) */
public static final String IGNORE_TIKA_EXCEPTION = "ignoreTikaException";
/** if true, ignore TikaException (give up to extract text but index metadata) */
String IGNORE_TIKA_EXCEPTION = "ignoreTikaException";

/**
* The param prefix for mapping Tika metadata to Solr fields.
Expand All @@ -35,7 +35,7 @@ public interface ExtractingParams {
* In this example, the tika "title" metadata value will be added to a Solr field named
* "solr.title"
*/
public static final String MAP_PREFIX = "fmap.";
String MAP_PREFIX = "fmap.";

/**
* Pass in literal values to be added to the document, as in
Expand All @@ -44,7 +44,7 @@ public interface ExtractingParams {
* literal.myField=Foo
* </pre>
*/
public static final String LITERALS_PREFIX = "literal.";
String LITERALS_PREFIX = "literal.";

/**
* Restrict the extracted parts of a document to be indexed by passing in an XPath expression. All
Expand All @@ -54,29 +54,29 @@ public interface ExtractingParams {
*
* @see #CAPTURE_ELEMENTS
*/
public static final String XPATH_EXPRESSION = "xpath";
String XPATH_EXPRESSION = "xpath";

/** Only extract and return the content, do not index it. */
public static final String EXTRACT_ONLY = "extractOnly";
String EXTRACT_ONLY = "extractOnly";

/** Content output format if extractOnly is true. Default is "xml", alternative is "text". */
public static final String EXTRACT_FORMAT = "extractFormat";
String EXTRACT_FORMAT = "extractFormat";

/**
* Capture attributes separately according to the name of the element, instead of just adding them
* to the string buffer
*/
public static final String CAPTURE_ATTRIBUTES = "captureAttr";
String CAPTURE_ATTRIBUTES = "captureAttr";

/**
* Literal field values will by default override other values such as metadata and content. Set
* this to false to revert to pre-4.0 behaviour
* this to "false" to revert to pre-4.0 behaviour
*/
public static final String LITERALS_OVERRIDE = "literalsOverride";
String LITERALS_OVERRIDE = "literalsOverride";

/**
* Capture the specified fields (and everything included below it that isn't capture by some other
* capture field) separately from the default. This is different then the case of passing in an
* capture field) separately from the default. This is different from the case of passing in an
* XPath expression.
*
* <p>The Capture field is based on the localName returned to the {@link SolrContentHandler} by
Expand All @@ -97,34 +97,34 @@ public interface ExtractingParams {
* By passing in the p tag, you could capture all P tags separately from the rest of the t Thus,
* in the example, the capture of the P tag would be: "some text here. more text"
*/
public static final String CAPTURE_ELEMENTS = "capture";
String CAPTURE_ELEMENTS = "capture";

/** The type of the stream. If not specified, Tika will use mime type detection. */
public static final String STREAM_TYPE = "stream.type";
String STREAM_TYPE = "stream.type";

/**
* Optional. The file name. If specified, Tika can take this into account while guessing the MIME
* type.
*/
public static final String RESOURCE_NAME = "resource.name";
String RESOURCE_NAME = "resource.name";

/**
* Optional. The password for this resource. Will be used instead of the rule based password
* lookup mechanisms
*/
public static final String RESOURCE_PASSWORD = "resource.password";
String RESOURCE_PASSWORD = "resource.password";

/**
* Optional. If specified, the prefix will be prepended to all Metadata, such that it would be
* possible to setup a dynamic field to automatically capture it
* possible to set up a dynamic field to automatically capture it
*/
public static final String UNKNOWN_FIELD_PREFIX = "uprefix";
String UNKNOWN_FIELD_PREFIX = "uprefix";

/**
* Optional. If specified and the name of a potential field cannot be determined, the default
* Field specified will be used instead.
*/
public static final String DEFAULT_FIELD = "defaultField";
String DEFAULT_FIELD = "defaultField";

/**
* Optional. If specified, loads the file as a source for password lookups for Tika encrypted
Expand All @@ -135,27 +135,26 @@ public interface ExtractingParams {
* i.e. the first match will be used If you want a fallback password to be always used, supply a
* .*=&lt;defaultmypassword&gt; at the end
*/
public static final String PASSWORD_MAP_FILE = "passwordsFile";
String PASSWORD_MAP_FILE = "passwordsFile";

/** Backend selection */
public static final String EXTRACTION_BACKEND = "extraction.backend";
String EXTRACTION_BACKEND = "extraction.backend";

/** Preferred: Fix/normalize metadata naming for Tika Server compatibility */
public static final String TIKASERVER_METADATA_COMPATIBILITY =
"tikaserver.metadata.compatibility";
String TIKASERVER_METADATA_COMPATIBILITY = "tikaserver.metadata.compatibility";

/** URL of Tika Server instance. */
public static final String TIKASERVER_URL = "tikaserver.url";
String TIKASERVER_URL = "tikaserver.url";

/** Max characters allowed in parsed content */
public static final String TIKASERVER_MAX_CHARS = "tikaserver.maxChars";
String TIKASERVER_MAX_CHARS = "tikaserver.maxChars";

/**
* Enable recursive parsing of embedded documents when using TikaServer. This is experimental,
* uses /rmeta endpoint, uses more RAM and is disabled by default.
*/
public static final String TIKASERVER_RECURSIVE = "tikaserver.recursive";
String TIKASERVER_RECURSIVE = "tikaserver.recursive";

/** Default or per-request timeout in seconds for TikaServer HTTP calls. */
public static final String TIKASERVER_TIMEOUT_SECS = "tikaserver.timeoutSeconds";
String TIKASERVER_TIMEOUT_SECS = "tikaserver.timeoutSeconds";
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected void addCapturedContent() {
}

/**
* Add in the catch all content to the field. Default impl. uses the {@link #contentFieldName} and
* Add in the catch-all content to the field. Default impl. uses the {@link #contentFieldName} and
* the {@link #catchAllBuilder}
*/
protected void addContent() {
Expand Down Expand Up @@ -204,9 +204,10 @@ protected void addField(String fname, String fval, String[] vals) {
name = unknownFieldPrefix + name;
sf = schema.getFieldOrNull(name);
} else if (sf == null
&& defaultField.length() > 0
&& name.equals(ExtractingMetadataConstants.RESOURCE_NAME_KEY)
== false /*let the fall through below handle this*/) {
&& !defaultField.isEmpty()
&& !name.equals(
ExtractingMetadataConstants
.RESOURCE_NAME_KEY) /*let the fall through below handle this*/) {
name = defaultField;
sf = schema.getFieldOrNull(name);
}
Expand Down Expand Up @@ -266,7 +267,7 @@ public void startElement(String uri, String localName, String qName, Attributes
// we need to switch the currentBuilder
bldrStack.add(theBldr);
}
if (captureAttribs == true) {
if (captureAttribs) {
for (int i = 0; i < attributes.getLength(); i++) {
addField(localName, attributes.getValue(i), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.solr.handler.extraction;

import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.SolrTestCaseJ4;
Expand All @@ -31,11 +30,8 @@
import org.apache.solr.update.processor.BufferingRequestProcessor;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class ExtractingRequestHandlerTestAbstract extends SolrTestCaseJ4 {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

@Override
@Before
Expand Down
Loading
Loading