diff options
4 files changed, 42 insertions, 45 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java b/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java index abe19ddf831..5e580d8f4df 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java @@ -10,8 +10,8 @@ import com.yahoo.searchdefinition.document.FieldSet; /** * The field sets owned by a {@link Search} * Both built in and user defined. - * @author vegardh * + * @author vegardh */ public class FieldSets { @@ -46,18 +46,12 @@ public class FieldSets { builtInFieldSets.get(setName).addFieldName(field); } - /** - * The built in field sets, unmodifiable - * @return built in field sets - */ + /** Returns the built in field sets, unmodifiable */ public Map<String, FieldSet> builtInFieldSets() { return Collections.unmodifiableMap(builtInFieldSets); } - /** - * The user defined field sets, unmodifiable - * @return user field sets - */ + /** Returns the user defined field sets, unmodifiable */ public Map<String, FieldSet> userFieldSets() { return Collections.unmodifiableMap(userFieldSets); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Index.java b/config-model/src/main/java/com/yahoo/searchdefinition/Index.java index 0ea3f5c24a3..e46db1d1b5f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Index.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Index.java @@ -16,14 +16,15 @@ import java.util.Set; * Two indices are equal if they have the same name and the same settings, except * alias settings (which are excluded). * - * @author bratseth + * @author bratseth */ public class Index implements Cloneable, Serializable { - public static enum Type { + public enum Type { + VESPA("vespa"); private String name; - private Type(String name) { this.name = name; } + Type(String name) { this.name = name; } public String getName() { return name; } } @@ -34,7 +35,7 @@ public class Index implements Cloneable, Serializable { private String name; /** The rank type of this index */ - private RankType rankType=null; + private RankType rankType = null; /** Whether this index supports prefix search */ private boolean prefix; @@ -46,10 +47,10 @@ public class Index implements Cloneable, Serializable { * The stemming setting of this field, or null to use the default. * Default is determined by the owning search definition. */ - private Stemming stemming=null; + private Stemming stemming = null; /** Whether the content of this index is normalized */ - private boolean normalized=true; + private boolean normalized = true; private Type type = Type.VESPA; @@ -64,16 +65,16 @@ public class Index implements Cloneable, Serializable { } public Index(String name, boolean prefix) { - this.name=name; - this.prefix=prefix; + this.name = name; + this.prefix = prefix; } - public void setName(String name) { this.name=name; } + public void setName(String name) { this.name = name; } public String getName() { return name; } /** Sets the rank type of this field */ - public void setRankType(RankType rankType) { this.rankType=rankType; } + public void setRankType(RankType rankType) { this.rankType = rankType; } /** Returns the rank type of this field, or null if nothing is set */ public RankType getRankType() { return rankType; } @@ -86,7 +87,7 @@ public class Index implements Cloneable, Serializable { * this is never null */ public Stemming getStemming(Search search) { - if (stemming!=null) + if (stemming != null) return stemming; else return search.getStemming(); @@ -95,7 +96,7 @@ public class Index implements Cloneable, Serializable { /** * Sets how this field should be stemmed, or set to null to use the default. */ - public void setStemming(Stemming stemming) { this.stemming=stemming; } + public void setStemming(Stemming stemming) { this.stemming = stemming; } /** Returns whether this index supports prefix search, default is false */ public boolean isPrefix() { return prefix; } @@ -113,10 +114,12 @@ public class Index implements Cloneable, Serializable { return Collections.unmodifiableSet(aliases).iterator(); } + @Override public int hashCode() { return name.hashCode() + ( prefix ? 17 : 0 ); } + @Override public boolean equals(Object object) { if ( ! (object instanceof Index)) return false; @@ -137,6 +140,7 @@ public class Index implements Cloneable, Serializable { } /** Makes a deep copy of this index */ + @Override public Object clone() { try { Index copy=(Index)super.clone(); @@ -152,34 +156,22 @@ public class Index implements Cloneable, Serializable { return (Index)clone(); } - /** - * The index engine type - * @return the type - */ + /** Returns the index engine type */ public Type getType() { return type; } - /** - * Sets the index engine type - * @param type a index engine type - */ + /** Sets the index engine type */ public void setType(Type type) { this.type = type; } - /** - * The boolean index definition - * @return the boolean index definition - */ + /** Returns the boolean index definition */ public BooleanIndexDefinition getBooleanIndexDefiniton() { return boolIndex; } - /** - * Sets the boolean index definition - * @param def boolean index definition - */ + /** Sets the boolean index definition */ public void setBooleanIndexDefiniton(BooleanIndexDefinition def) { boolIndex = def; } 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 694c30eba9a..badb99c0523 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 @@ -17,7 +17,6 @@ import com.yahoo.search.searchchain.PhaseNames; import java.util.Iterator; import java.util.Map; - /** * A searcher which does parametrized collapsing. * @@ -29,9 +28,9 @@ import java.util.Map; public class FieldCollapsingSearcher extends Searcher { private static final CompoundName collapse = new CompoundName("collapse"); - private static final CompoundName collapsefield=new CompoundName("collapsefield"); - private static final CompoundName collapsesize=new CompoundName("collapsesize"); - private static final CompoundName collapseSummaryName=new CompoundName("collapse.summary"); + private static final CompoundName collapsefield = new CompoundName("collapsefield"); + private static final CompoundName collapsesize = new CompoundName("collapsesize"); + private static final CompoundName collapseSummaryName = new CompoundName("collapse.summary"); /** Maximum number of queries to send next searcher */ private int maxQueries = 4; @@ -64,6 +63,7 @@ public class FieldCollapsingSearcher extends Searcher { } @Inject + @SuppressWarnings("unused") public FieldCollapsingSearcher(QrSearchersConfig config) { QrSearchersConfig.Com.Yahoo.Prelude.Searcher.FieldCollapsingSearcher s = config.com().yahoo().prelude().searcher().FieldCollapsingSearcher(); @@ -99,7 +99,7 @@ public class FieldCollapsingSearcher extends Searcher { public Result search(com.yahoo.search.Query query, Execution execution) { String collapseField = query.properties().getString(collapsefield); - if (collapseField==null) return execution.search(query); + if (collapseField == null) return execution.search(query); int collapseSize = query.properties().getInteger(collapsesize,defaultCollapseSize); query.properties().set(collapse, "0"); @@ -113,11 +113,12 @@ public class FieldCollapsingSearcher extends Searcher { int performedQueries = 0; Result resultSource; String collapseSummary = query.properties().getString(collapseSummaryName); + String summaryClass = (collapseSummary == null) + ? query.getPresentation().getSummary() : collapseSummary; + query.trace("Collapsing by '" + collapseField + "' using summary '" + collapseSummary + "'", 2); do { resultSource = search(query.clone(), execution, nextOffset, hitsToRequest); - String summaryClass = (collapseSummary == null) - ? query.getPresentation().getSummary() : collapseSummary; fill(resultSource, summaryClass, execution); collapse(result, knownCollapses, resultSource, collapseField, collapseSize); @@ -146,7 +147,7 @@ public class FieldCollapsingSearcher extends Searcher { return result; } - private Result search(Query query, Execution execution, int offset , int hits) { + private Result search(Query query, Execution execution, int offset, int hits) { query.setOffset(offset); query.setHits(hits); return execution.search(query); diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java index 8c6c4e31808..84565472820 100644 --- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java @@ -312,6 +312,16 @@ public class QueryTestCase { } @Test + public void testQueryProfileSourceAccess() { + QueryProfile profile = new QueryProfile("myProfile"); + profile.set("myField", "Profile: %{queryProfile}", null); + Query query = new Query(QueryTestCase.httpEncode("/search?queryProfile=myProfile"), profile.compile(null)); + + String source = query.properties().getInstance(com.yahoo.search.query.profile.QueryProfileProperties.class).getQueryProfile().listValuesWithSources(new CompoundName(""), query.getHttpRequest().propertyMap(), query.properties()).get("myField").source(); + assertEquals("myProfile", source); + } + + @Test public void testBooleanParameter() { QueryProfile profile = new QueryProfile("myProfile"); Query query = new Query("/?query=something&ranking.softtimeout.enable=false", profile.compile(null)); |