aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java12
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/Index.java48
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/FieldCollapsingSearcher.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java10
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java20
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java4
6 files changed, 55 insertions, 56 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));
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
index cc9c8c87272..2017f0b3e6d 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
@@ -64,10 +64,7 @@ public class DockerOperationsImpl implements DockerOperations {
public void createContainer(NodeAgentContext context, ContainerData containerData, ContainerResources containerResources) {
context.log(logger, "Creating container");
- // IPv6 - Assume always valid
- Inet6Address ipV6Address = ipAddresses.getIPv6Address(context.node().hostname()).orElseThrow(
- () -> new RuntimeException("Unable to find a valid IPv6 address for " + context.node().hostname() +
- ". Missing an AAAA DNS entry?"));
+ Optional<Inet6Address> ipV6Address = ipAddresses.getIPv6Address(context.node().hostname());
Docker.CreateContainerCommand command = docker.createContainerCommand(
context.node().wantedDockerImage().get(), context.containerName())
@@ -97,14 +94,19 @@ public class DockerOperationsImpl implements DockerOperations {
command.withNetworkMode(networking.getDockerNetworkMode());
if (networking == DockerNetworking.NPT) {
- InetAddress ipV6Local = IPAddresses.prefixTranslate(ipV6Address, IPV6_NPT_PREFIX, 8);
- command.withIpAddress(ipV6Local);
+ Optional<InetAddress> ipV6Local = ipV6Address.map(ip -> IPAddresses.prefixTranslate(ip, IPV6_NPT_PREFIX, 8));
+ ipV6Local.ifPresent(command::withIpAddress);
// IPv4 - Only present for some containers
Optional<InetAddress> ipV4Local = ipAddresses.getIPv4Address(context.node().hostname())
.map(ipV4Address -> IPAddresses.prefixTranslate(ipV4Address, IPV4_NPT_PREFIX, 2));
ipV4Local.ifPresent(command::withIpAddress);
+ if (ipV4Local.isEmpty() && ipV6Address.isEmpty()) {
+ throw new IllegalArgumentException("Container " + context.node().hostname() + " with " +
+ networking + " networking must have at least 1 IP address, " +
+ "but found none");
+ }
addEtcHosts(containerData, context.node().hostname(), ipV4Local, ipV6Local);
}
@@ -117,7 +119,7 @@ public class DockerOperationsImpl implements DockerOperations {
void addEtcHosts(ContainerData containerData,
String hostname,
Optional<InetAddress> ipV4Local,
- InetAddress ipV6Local) {
+ Optional<InetAddress> ipV6Local) {
// The default /etc/hosts in a Docker container contains one entry for the host,
// mapping the hostname to the Docker-assigned IPv4 address.
//
@@ -137,8 +139,8 @@ public class DockerOperationsImpl implements DockerOperations {
"fe00::0\tip6-localnet\n" +
"ff00::0\tip6-mcastprefix\n" +
"ff02::1\tip6-allnodes\n" +
- "ff02::2\tip6-allrouters\n" +
- ipV6Local.getHostAddress() + '\t' + hostname + '\n');
+ "ff02::2\tip6-allrouters\n");
+ ipV6Local.ifPresent(ipv6 -> etcHosts.append(ipv6.getHostAddress()).append('\t').append(hostname).append('\n'));
ipV4Local.ifPresent(ipv4 -> etcHosts.append(ipv4.getHostAddress()).append('\t').append(hostname).append('\n'));
containerData.addFile(Paths.get("/etc/hosts"), etcHosts.toString());
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
index 5091e59e175..48a9e8ca039 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
@@ -98,7 +98,7 @@ public class DockerOperationsImplTest {
InetAddress ipV6Local = InetAddresses.forString("::1");
InetAddress ipV4Local = InetAddresses.forString("127.0.0.1");
- dockerOperations.addEtcHosts(containerData, hostname, Optional.empty(), ipV6Local);
+ dockerOperations.addEtcHosts(containerData, hostname, Optional.empty(), Optional.of(ipV6Local));
verify(containerData, times(1)).addFile(
Paths.get("/etc/hosts"),
@@ -111,7 +111,7 @@ public class DockerOperationsImplTest {
"ff02::2 ip6-allrouters\n" +
"0:0:0:0:0:0:0:1 hostname\n");
- dockerOperations.addEtcHosts(containerData, hostname, Optional.of(ipV4Local), ipV6Local);
+ dockerOperations.addEtcHosts(containerData, hostname, Optional.of(ipV4Local), Optional.of(ipV6Local));
verify(containerData, times(1)).addFile(
Paths.get("/etc/hosts"),