summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/searcher
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-05-25 11:24:00 +0200
committerJon Bratseth <bratseth@oath.com>2018-05-25 11:24:00 +0200
commitdc8ab0b7dd552b7587d37043b9d3ffa3e9b72625 (patch)
treecee3d65025ee76db9a8821b7ebd32573a4293170 /container-search/src/main/java/com/yahoo/prelude/searcher
parent4d4c97a77dcabace7e47e7dbe112e382c6fae13f (diff)
Revert "Merge pull request #5913 from vespa-engine/revert-5903-bratseth/iterate-over-indexes-not-fields"
This reverts commit f14a7189ea46c33fb3469ec1c0fcbb7eb531f32a, reversing changes made to 7243f2edf5d05e128947560539f840658e7648bb.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/searcher')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java10
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java12
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java108
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java2
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java24
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java9
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java4
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java88
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java3
10 files changed, 118 insertions, 148 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
index 415ebd7871c..2f9e81c1607 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
@@ -27,9 +27,12 @@ import java.util.Set;
* will be returned when attribute prefetch filling is requested.</p>
*
* @author bratseth
+ * @deprecated use {@link com.yahoo.search.searchchain.testutil.DocumentSourceSearcher}
*/
@SuppressWarnings({"rawtypes"})
+@Deprecated // TODO: Remove on Vespa 7
public class DocumentSourceSearcher extends Searcher {
+
// as for the SuppressWarnings annotation above, we are inside
// com.yahoo.prelude, this is old stuff, really no point firing off those
// warnings here...
@@ -38,7 +41,6 @@ public class DocumentSourceSearcher extends Searcher {
private Map<Query, Result> completelyFilledResults = new HashMap<>();
private Map<Query, Result> attributeFilledResults = new HashMap<>();
private Map<Query, Result> unFilledResults = new HashMap<>();
- //private Result defaultUnfilledResult;
/** Time (in ms) at which the index of this searcher was last modified */
long editionTimeStamp=0;
@@ -101,11 +103,11 @@ public class DocumentSourceSearcher extends Searcher {
}
/**
- * Returns a query clone which has offset and hits set to null. This is used by access to
+ * Returns a query clone which has source, offset and hits set to null. This is used by access to
* the maps using the query as key to achieve lookup independent of offset/hits value
*/
- private com.yahoo.search.Query getQueryKeyClone(com.yahoo.search.Query query) {
- com.yahoo.search.Query key=query.clone();
+ private Query getQueryKeyClone(Query query) {
+ Query key = query.clone();
key.setWindow(0,0);
key.getModel().setSources("");
return key;
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
index 71e54c810c2..21fa8962da4 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java
@@ -19,10 +19,9 @@ import java.util.Map;
/**
- * A searcher which does parametrized collapsing. Based on
- * SiteCollapsingSearcher. Deprecated - use grouping.
+ * A searcher which does parametrized collapsing.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
@SuppressWarnings("deprecation")
@After(PhaseNames.RAW_QUERY)
@@ -174,17 +173,18 @@ public class FieldCollapsingSearcher extends Searcher {
}
if (knownCollapses.containsKey(collapseId)) {
- int numHitsThisField = knownCollapses.get(collapseId).intValue();
+ int numHitsThisField = knownCollapses.get(collapseId);
if (numHitsThisField < collapseSize) {
result.hits().add(hit);
++numHitsThisField;
- knownCollapses.put(collapseId, Integer.valueOf(numHitsThisField));
+ knownCollapses.put(collapseId, numHitsThisField);
}
} else {
- knownCollapses.put(collapseId, Integer.valueOf(1));
+ knownCollapses.put(collapseId, 1);
result.hits().add(hit);
}
}
}
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
index c18f3d49da3..2330ca2382a 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JSONDebugSearcher.java
@@ -16,16 +16,17 @@ import java.util.Iterator;
/**
* Save the query in the incoming state to a meta hit in the result.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
-
public class JSONDebugSearcher extends Searcher {
+
public static final String JSON_FIELD = "JSON field: ";
public static final String STRUCT_FIELD = "Structured data field (as json): ";
public static final String FEATURE_FIELD = "Feature data field (as json): ";
private static CompoundName PROPERTYNAME = new CompoundName("dumpjson");
+ @Override
public Result search(com.yahoo.search.Query query, Execution execution) {
Result r = execution.search(query);
String propertyName = query.properties().getString(PROPERTYNAME);
@@ -53,4 +54,5 @@ public class JSONDebugSearcher extends Searcher {
}
return r;
}
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
index ca87c0c1d46..5c56379efc0 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java
@@ -78,13 +78,13 @@ public class JuniperSearcher extends Searcher {
@Override
public void fill(Result result, String summaryClass, Execution execution) {
Result workResult = result;
- final int worstCase = workResult.getHitCount();
- final List<Hit> hits = new ArrayList<>(worstCase);
- for (final Iterator<Hit> i = workResult.hits().deepIterator(); i.hasNext();) {
- final Hit sniffHit = i.next();
+ int worstCase = workResult.getHitCount();
+ List<Hit> hits = new ArrayList<>(worstCase);
+ for (Iterator<Hit> i = workResult.hits().deepIterator(); i.hasNext();) {
+ Hit sniffHit = i.next();
if ( ! (sniffHit instanceof FastHit)) continue;
- final FastHit hit = (FastHit) sniffHit;
+ FastHit hit = (FastHit) sniffHit;
if (hit.isFilled(summaryClass)) continue;
hits.add(hit);
@@ -105,54 +105,46 @@ public class JuniperSearcher extends Searcher {
Object searchDefinitionField = hit.getField(MAGIC_FIELD);
if (searchDefinitionField == null) continue;
- String searchDefinitionName = searchDefinitionField.toString();
-
- // TODO: Switch to iterate over indexes in the outer loop:
- //for (Index index : indexFacts.getIndexes(searchDefinitionName())) {
- // if (index.getDynamicSummary() || index.getHighlightSummary()) {
- // insertTags(hit.buildHitField(index.getName(), true, true), bolding, index.getDynamicSummary());
- // }
- //}
- for (String fieldName : hit.fields().keySet()) {
- Index index = indexFacts.getIndex(fieldName, searchDefinitionName);
- if (index.getDynamicSummary() || index.getHighlightSummary())
- insertTags(hit.buildHitField(fieldName, true, true), bolding, index.getDynamicSummary());
+
+ for (Index index : indexFacts.getIndexes(searchDefinitionField.toString())) {
+ if (index.getDynamicSummary() || index.getHighlightSummary()) {
+ HitField fieldValue = hit.buildHitField(index.getName(), true, true);
+ if (fieldValue != null)
+ insertTags(fieldValue, bolding, index.getDynamicSummary());
+ }
}
}
}
- private void insertTags(final HitField oldProperty, final boolean bolding, final boolean dynteaser) {
+ private void insertTags(HitField oldProperty, boolean bolding, boolean dynteaser) {
boolean insideHighlight = false;
- for (final ListIterator<FieldPart> i = oldProperty.listIterator(); i.hasNext();) {
- final FieldPart f = i.next();
- if (f instanceof SeparatorFieldPart) {
+ for (ListIterator<FieldPart> i = oldProperty.listIterator(); i.hasNext();) {
+ FieldPart f = i.next();
+ if (f instanceof SeparatorFieldPart)
setSeparatorString(bolding, (SeparatorFieldPart) f);
- }
- if (f.isFinal()) {
- continue;
- }
+ if (f.isFinal()) continue;
- final String toQuote = f.getContent();
+ String toQuote = f.getContent();
List<FieldPart> newFieldParts = null;
int previous = 0;
for (int j = 0; j < toQuote.length(); j++) {
- final char key = toQuote.charAt(j);
+ char key = toQuote.charAt(j);
switch (key) {
- case RAW_HIGHLIGHT_CHAR:
- newFieldParts = initFieldParts(newFieldParts);
- addBolding(bolding, insideHighlight, f, toQuote, newFieldParts, previous, j);
- previous = j + 1;
- insideHighlight = !insideHighlight;
- break;
- case RAW_SEPARATOR_CHAR:
- newFieldParts = initFieldParts(newFieldParts);
- addSeparator(bolding, dynteaser, f, toQuote, newFieldParts,
- previous, j);
- previous = j + 1;
- break;
- default:
- // no action
- break;
+ case RAW_HIGHLIGHT_CHAR:
+ newFieldParts = initFieldParts(newFieldParts);
+ addBolding(bolding, insideHighlight, f, toQuote, newFieldParts, previous, j);
+ previous = j + 1;
+ insideHighlight = !insideHighlight;
+ break;
+ case RAW_SEPARATOR_CHAR:
+ newFieldParts = initFieldParts(newFieldParts);
+ addSeparator(bolding, dynteaser, f, toQuote, newFieldParts,
+ previous, j);
+ previous = j + 1;
+ break;
+ default:
+ // no action
+ break;
}
}
if (previous > 0 && previous < toQuote.length()) {
@@ -160,37 +152,30 @@ public class JuniperSearcher extends Searcher {
}
if (newFieldParts != null) {
i.remove();
- for (final Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext();) {
+ for (Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext();) {
i.add(j.next());
}
}
}
}
- private void setSeparatorString(final boolean bolding,final SeparatorFieldPart f) {
- if (bolding) {
+ private void setSeparatorString(boolean bolding, SeparatorFieldPart f) {
+ if (bolding)
f.setContent(separatorTag);
- } else {
+ else
f.setContent(ELLIPSIS);
- }
}
- private void addSeparator(final boolean bolding, final boolean dynteaser,
- final FieldPart f, final String toQuote,
- final List<FieldPart> newFieldParts, final int previous, final int j) {
- if (previous != j) {
+ private void addSeparator(boolean bolding, boolean dynteaser, FieldPart f, String toQuote,
+ List<FieldPart> newFieldParts, int previous, int j) {
+ if (previous != j)
newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
- }
- if (dynteaser) {
- final FieldPart s = (bolding ? new SeparatorFieldPart(separatorTag) : new SeparatorFieldPart(ELLIPSIS));
- newFieldParts.add(s);
- }
+ if (dynteaser)
+ newFieldParts.add(bolding ? new SeparatorFieldPart(separatorTag) : new SeparatorFieldPart(ELLIPSIS));
}
- private void addBolding(final boolean bolding,
- final boolean insideHighlight, final FieldPart f,
- final String toQuote, final List<FieldPart> newFieldParts,
- final int previous, final int j) {
+ private void addBolding(boolean bolding, boolean insideHighlight, FieldPart f, String toQuote,
+ List<FieldPart> newFieldParts, int previous, int j) {
if (previous != j) {
newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
}
@@ -209,9 +194,8 @@ public class JuniperSearcher extends Searcher {
}
private List<FieldPart> initFieldParts(List<FieldPart> newFieldParts) {
- if (newFieldParts == null) {
+ if (newFieldParts == null)
newFieldParts = new ArrayList<>();
- }
return newFieldParts;
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
index c47af9e32da..3b2fd596cfa 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/MultipleResultsSearcher.java
@@ -17,7 +17,7 @@ import java.util.*;
*
* <p> For each group, the desired number of hits can be specified. </p>
*
- * @author tonytv
+ * @author tonytv
*/
public class MultipleResultsSearcher extends Searcher {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
index 33667349397..43717ecf6cd 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/PosSearcher.java
@@ -34,6 +34,7 @@ import com.yahoo.prelude.Location;
@Before(PhaseNames.TRANSFORMED_QUERY)
@Provides(PosSearcher.POSITION_PARSING)
public class PosSearcher extends Searcher {
+
public static final String POSITION_PARSING = "PositionParsing";
private static final CompoundName posBb = new CompoundName("pos.bb");
@@ -52,7 +53,7 @@ public class PosSearcher extends Searcher {
public final static double km2deg = 1000.000 * 180.0 / (Math.PI * 6356752.0);
public final static double mi2deg = 1609.344 * 180.0 / (Math.PI * 6356752.0);
-
+ @Override
public Result search(Query query, Execution execution) {
String bb = query.properties().getString(posBb);
String ll = query.properties().getString(posLl);
@@ -92,9 +93,8 @@ public class PosSearcher extends Searcher {
}
}
catch (IllegalArgumentException e) {
- // System.err.println("error: "+e);
- return new Result(query, ErrorMessage.createInvalidQueryParameter(
- "Error in pos parameters: " + Exceptions.toMessageString(e)));
+ return new Result(query, ErrorMessage.createInvalidQueryParameter("Error in pos parameters: " +
+ Exceptions.toMessageString(e)));
}
// and finally:
query.getRanking().setLocation(loc);
@@ -102,8 +102,8 @@ public class PosSearcher extends Searcher {
}
private void handleGeoCircle(Query query, String ll, Location target) {
- double ewCoord = 0;
- double nsCoord = 0;
+ double ewCoord;
+ double nsCoord;
try {
DegreesParser parsed = new DegreesParser(ll);
ewCoord = parsed.longitude;
@@ -111,9 +111,9 @@ public class PosSearcher extends Searcher {
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unable to parse lat/long string '" +ll + "'", e);
}
- String radius = query.properties().getString(posRadius);
- double radiusdegrees = 0.0;
+ String radius = query.properties().getString(posRadius);
+ double radiusdegrees;
if (radius == null) {
radiusdegrees = 50.0 * km2deg;
} else if (radius.endsWith("km")) {
@@ -133,8 +133,8 @@ public class PosSearcher extends Searcher {
private void handleXyCircle(Query query, String xy, Location target) {
- int xcoord = 0;
- int ycoord = 0;
+ int xcoord;
+ int ycoord;
// parse xy
int semipos = xy.indexOf(';');
if (semipos > 0 && semipos < xy.length()) {
@@ -143,8 +143,9 @@ public class PosSearcher extends Searcher {
} else {
throw new IllegalArgumentException("pos.xy must be in the format 'digits;digits' but was: '"+xy+"'");
}
+
String radius = query.properties().getString(posRadius);
- int radiusUnits = 0;
+ int radiusUnits;
if (radius == null) {
radiusUnits = 5000;
} else if (radius.endsWith("km")) {
@@ -165,7 +166,6 @@ public class PosSearcher extends Searcher {
target.setXyCircle(xcoord, ycoord, radiusUnits);
}
-
private static void parseBoundingBox(String bb, Location target) {
BoundingBoxParser parser = new BoundingBoxParser(bb);
target.setBoundingBox(parser.n, parser.s, parser.e, parser.w);
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
index 81b948682df..32efcde6feb 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuerySnapshotSearcher.java
@@ -11,19 +11,20 @@ import com.yahoo.search.searchchain.Execution;
/**
* Save the query in the incoming state to a meta hit in the result.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
+ * @deprecated do not use
*/
-
+@Deprecated // TODO: Remove on Vespa 7
public class QuerySnapshotSearcher extends Searcher {
public Result search(Query query, Execution execution) {
Query q = query.clone();
Result r = execution.search(query);
- Hit h = new Hit("meta:querysnapshot", new Relevance(
- Double.POSITIVE_INFINITY));
+ Hit h = new Hit("meta:querysnapshot", new Relevance(Double.POSITIVE_INFINITY));
h.setMeta(true);
h.setField("query", q);
r.hits().add(h);
return r;
}
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
index 4e604dcd226..558521a7a8d 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QueryValidatingSearcher.java
@@ -10,8 +10,10 @@ import com.yahoo.search.searchchain.Execution;
/**
* Ensures hits is 1000 or less and offset is 1000 or less.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
+ * @deprecated do not use
*/
+@Deprecated // TODO: Remove on Vespa 7
public class QueryValidatingSearcher extends Searcher {
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
index d4cad7f1246..5dcc533fb1f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/QuotingSearcher.java
@@ -35,6 +35,7 @@ public class QuotingSearcher extends Searcher {
}
private static class QuoteTable {
+
private final int lowerUncachedBound;
private final int upperUncachedBound;
private final Map<Character, String> quoteMap;
@@ -50,12 +51,10 @@ public class QuotingSearcher extends Searcher {
boolean newIsEmpty = true;
Map<Character, String> newQuoteMap = new HashMap<>();
for (Iterator<?> i = config.character().iterator(); i.hasNext(); ) {
- QrQuotetableConfig.Character character
- = (QrQuotetableConfig.Character)i.next();
+ QrQuotetableConfig.Character character = (QrQuotetableConfig.Character)i.next();
if (character.ordinal() > 256) {
newIsEmpty = false;
- newQuoteMap.put(new Character((char)character.ordinal()),
- character.quoting());
+ newQuoteMap.put(new Character((char)character.ordinal()), character.quoting());
newUseMap = true;
if (minOrd == 0 || character.ordinal() < minOrd)
minOrd = character.ordinal();
@@ -64,8 +63,7 @@ public class QuotingSearcher extends Searcher {
}
else {
newIsEmpty = false;
- newLowerTable[character.ordinal()]
- = character.quoting();
+ newLowerTable[character.ordinal()] = character.quoting();
}
}
lowerUncachedBound = minOrd;
@@ -75,22 +73,19 @@ public class QuotingSearcher extends Searcher {
isEmpty = newIsEmpty;
lowerTable = newLowerTable;
}
+
public String get(char c) {
- if (isEmpty)
- return null;
+ if (isEmpty) return null;
+
int ord = (int)c;
if (ord < 256) {
return lowerTable[ord];
}
else {
- if ((!useMap) || ord < lowerUncachedBound
- || ord > upperUncachedBound)
- {
+ if ((!useMap) || ord < lowerUncachedBound || ord > upperUncachedBound)
return null;
- }
- else {
+ else
return quoteMap.get(new Character(c));
- }
}
}
public boolean isEmpty() {
@@ -107,35 +102,29 @@ public class QuotingSearcher extends Searcher {
Result result = execution.search(query);
execution.fill(result);
QuoteTable translations = getQuoteTable();
- if (translations == null || translations.isEmpty()) {
- return result;
- }
+ if (translations == null || translations.isEmpty()) return result;
+
for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext(); ) {
Hit h = i.next();
- if (h instanceof FastHit) {
- quoteProperties((FastHit)h, translations);
- }
+ if (h instanceof FastHit)
+ quoteFields((FastHit) h, translations);
}
return result;
}
- private void quoteProperties(FastHit hit, QuoteTable translations) {
- for (Iterator<?> i = ((Set<?>) hit.fields().keySet()).iterator(); i.hasNext(); ) {
- String propertyName = (String) i.next();
- Object entry = hit.getField(propertyName);
- if (entry == null) {
- continue;
- }
- Class<? extends Object> propertyType = entry.getClass();
- if (propertyType.equals(HitField.class)) {
- quoteField((HitField) entry, translations);
- } else if (propertyType.equals(String.class)) {
- quoteProperty(hit, propertyName, (String)entry, translations);
+ private void quoteFields(FastHit hit, QuoteTable translations) {
+ hit.forEachField((fieldName, fieldValue) -> {
+ if (fieldValue != null) {
+ Class<?> fieldType = fieldValue.getClass();
+ if (fieldType.equals(HitField.class))
+ quoteField((HitField) fieldValue, translations);
+ else if (fieldType.equals(String.class))
+ quoteField(hit, fieldName, (String) fieldValue, translations);
}
- }
+ });
}
- private void quoteProperty(Hit hit, String fieldname, String toQuote, QuoteTable translations) {
+ private void quoteField(Hit hit, String fieldname, String toQuote, QuoteTable translations) {
List<FieldPart> l = translate(toQuote, translations, true);
if (l != null) {
HitField hf = new HitField(fieldname, toQuote);
@@ -144,13 +133,11 @@ public class QuotingSearcher extends Searcher {
}
}
-
private void quoteField(HitField field, QuoteTable translations) {
for (ListIterator<FieldPart> i = field.listIterator(); i.hasNext(); ) {
FieldPart f = i.next();
- if (!f.isFinal()) {
- List<FieldPart> newFieldParts = translate(f.getContent(), translations,
- f.isToken());
+ if ( ! f.isFinal()) {
+ List<FieldPart> newFieldParts = translate(f.getContent(), translations, f.isToken());
if (newFieldParts != null) {
i.remove();
for (Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext(); ) {
@@ -161,33 +148,24 @@ public class QuotingSearcher extends Searcher {
}
}
- private List<FieldPart> translate(String toQuote, QuoteTable translations,
- boolean isToken) {
+ private List<FieldPart> translate(String toQuote, QuoteTable translations, boolean isToken) {
List<FieldPart> newFieldParts = null;
int lastIdx = 0;
for (int i = 0; i < toQuote.length(); i++) {
String quote = translations.get(toQuote.charAt(i));
if (quote != null) {
- if (newFieldParts == null) {
+ if (newFieldParts == null)
newFieldParts = new ArrayList<>();
- }
- if (lastIdx != i) {
- newFieldParts.add(
- new StringFieldPart(toQuote.substring(lastIdx, i),
- isToken));
- }
+ if (lastIdx != i)
+ newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx, i), isToken));
String initContent = Character.toString(toQuote.charAt(i));
- newFieldParts.add(new ImmutableFieldPart(initContent,
- quote,
- isToken));
+ newFieldParts.add(new ImmutableFieldPart(initContent, quote, isToken));
lastIdx = i+1;
}
}
- if (lastIdx > 0 && lastIdx < toQuote.length()) {
- newFieldParts.add(
- new StringFieldPart(toQuote.substring(lastIdx),
- isToken));
- }
+ if (lastIdx > 0 && lastIdx < toQuote.length())
+ newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx), isToken));
return newFieldParts;
}
+
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
index 2e2c73b6707..9b6f5926b61 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidatePredicateSearcher.java
@@ -20,7 +20,7 @@ import java.util.Collection;
/**
* Checks that predicate queries don't use values outside the defined upper/lower bounds.
*
- * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a>
+ * @author Magnar Nedland
*/
@After(BooleanSearcher.PREDICATE)
public class ValidatePredicateSearcher extends Searcher {
@@ -78,4 +78,5 @@ public class ValidatePredicateSearcher extends Searcher {
@Override
public void onExit() {}
}
+
}