Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove controlNonVisibleCharacters #260

Merged
merged 2 commits into from
Jan 13, 2025
Merged
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 @@ -37,13 +37,11 @@
public class SimpleDecorate implements PostFilter {

static Logger logger = LoggerFactory.getLogger(SimpleDecorate.class);
protected static final Pattern controlNonVisibleCharacters = Pattern.compile("[\\p{Cntrl}\uFFFD\uFFFF]|[^\\p{Graph}\\p{Space}]");

MetaIndex meta = null;
String[] decorateKeys = null;
boolean any = false;

Matcher controlNonVisibleCharactersMatcher = controlNonVisibleCharacters.matcher("");
/**
* Adds all the metadata for the specified document occurring at the specified
* rank to the ResultSet
Expand All @@ -61,8 +59,7 @@ public final byte filter(
final String[] values = meta.getItems(decorateKeys, docid);
for(int j=0;j<decorateKeys.length;j++)
{
controlNonVisibleCharactersMatcher.reset(values[j]);
results.addMetaItem(decorateKeys[j], rank, controlNonVisibleCharactersMatcher.replaceAll(""));
results.addMetaItem(decorateKeys[j], rank, values[j]);
}
return PostFilter.FILTER_OK;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void process(Manager manager, Request q) {
: ArrayUtils.parseCommaDelimitedString(q.getControl("decorate"));
logger.debug("Decorating for " + java.util.Arrays.toString(decorateKeys));
if (decorateKeys.length == 0){
logger.warn("SimpleDecorate called, but no meta keys detected - either metaindex is empty, or decorate control is empty");
logger.warn("SimpleDecorate called, but no meta keys detected - either metaindex is empty, or decorate control is empty");
return;
}
ResultSet res = q.getResultSet();
Expand All @@ -69,9 +69,7 @@ public void process(Manager manager, Request q) {
String[] finalmeta = new String[num_docs];
for (int i=0;i<num_docs;i++)
{
String value = meta[i][j];
controlNonVisibleCharactersMatcher.reset(value);
finalmeta[i] = controlNonVisibleCharactersMatcher.replaceAll("");
finalmeta[i] = meta[i][j];
}
res.addMetaItems(decorateKeys[j], finalmeta);
}
Expand Down
Loading