Merge pull request #14775 from cbuescher/fix/14746
Add unique id to query names to avoid naming conflicts
This commit is contained in:
commit
a34b555fff
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.query;
|
||||||
import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator;
|
import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
import com.fasterxml.jackson.core.io.JsonStringEncoder;
|
import com.fasterxml.jackson.core.io.JsonStringEncoder;
|
||||||
|
|
||||||
import org.apache.lucene.search.BoostQuery;
|
import org.apache.lucene.search.BoostQuery;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.apache.lucene.search.TermQuery;
|
import org.apache.lucene.search.TermQuery;
|
||||||
|
@ -128,6 +129,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
||||||
private static IndicesQueriesRegistry indicesQueriesRegistry;
|
private static IndicesQueriesRegistry indicesQueriesRegistry;
|
||||||
private static QueryShardContext queryShardContext;
|
private static QueryShardContext queryShardContext;
|
||||||
private static IndexFieldDataService indexFieldDataService;
|
private static IndexFieldDataService indexFieldDataService;
|
||||||
|
private static int queryNameId = 0;
|
||||||
|
|
||||||
|
|
||||||
protected static QueryShardContext queryShardContext() {
|
protected static QueryShardContext queryShardContext() {
|
||||||
|
@ -316,12 +318,21 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
||||||
query.boost(2.0f / randomIntBetween(1, 20));
|
query.boost(2.0f / randomIntBetween(1, 20));
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
query.queryName(randomAsciiOfLengthBetween(1, 10));
|
query.queryName(createUniqueRandomName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make sure query names are unique by suffixing them with increasing counter
|
||||||
|
*/
|
||||||
|
private static String createUniqueRandomName() {
|
||||||
|
String queryName = randomAsciiOfLengthBetween(1, 10) + queryNameId;
|
||||||
|
queryNameId++;
|
||||||
|
return queryName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the query that is being tested
|
* Create the query that is being tested
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue