From 30098a14fef8a2f2e19c922154a5d5fa47509755 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Thu, 31 Oct 2019 14:49:22 +0100 Subject: Nonfunctional changes only --- .../java/com/yahoo/searchdefinition/FieldSets.java | 12 ++---- .../java/com/yahoo/searchdefinition/Index.java | 48 +++++++++------------- .../java/com/yahoo/search/test/QueryTestCase.java | 10 +++++ 3 files changed, 33 insertions(+), 37 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 builtInFieldSets() { return Collections.unmodifiableMap(builtInFieldSets); } - /** - * The user defined field sets, unmodifiable - * @return user field sets - */ + /** Returns the user defined field sets, unmodifiable */ public Map 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/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 @@ -311,6 +311,16 @@ public class QueryTestCase { assertEquals("Profile: myProfile", q.properties().get("myField")); } + @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"); -- cgit v1.2.3