public QueryShardException(QueryShardContext context, String msg, Throwable cause, Object... args) { this(context.getFullyQualifiedIndex(), msg, cause, args); }
@Override public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); if (indexName.startsWith(value)) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided prefix [" + value + "]."); } }
@Override public Query regexpQuery(String value, int flags, int maxDeterminizedStates, MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); Pattern pattern = Regex.compile(value, Regex.flagsToString(flags)); if (pattern.matcher(indexName).matches()) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided pattern [" + value + "]."); } }
@Override public Query termsQuery(List values, QueryShardContext context) { if (context == null) { return super.termsQuery(values, context); } for (Object value : values) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { // No need to OR these clauses - we can only logically be // running in the context of just one of these index names. return Queries.newMatchAllQuery(); } } // None of the listed index names are this one return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.getFullyQualifiedIndex().getName() + " vs. " + values); }
@Override public Query wildcardQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); if (isSameIndex(value, indexName)) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided pattern [" + value + "]."); } }
/** * This termQuery impl looks at the context to determine the index that * is being queried and then returns a MATCH_ALL_QUERY or MATCH_NO_QUERY * if the value matches this index. This can be useful if aliases or * wildcards are used but the aim is to restrict the query to specific * indices */ @Override public Query termQuery(Object value, @Nullable QueryShardContext context) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName() + " vs. " + value); } }
public QueryShardException(QueryShardContext context, String msg, Throwable cause, Object... args) { this(context.getFullyQualifiedIndex(), msg, cause, args); }
public QueryShardException(QueryShardContext context, String msg, Throwable cause, Object... args) { this(context.getFullyQualifiedIndex(), msg, cause, args); }
@Override public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); if (indexName.startsWith(value)) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided prefix [" + value + "]."); } }
@Override public Query regexpQuery(String value, int flags, int maxDeterminizedStates, MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); Pattern pattern = Regex.compile(value, Regex.flagsToString(flags)); if (pattern.matcher(indexName).matches()) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided pattern [" + value + "]."); } }
@Override public Query termsQuery(List values, QueryShardContext context) { if (context == null) { return super.termsQuery(values, context); } for (Object value : values) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { // No need to OR these clauses - we can only logically be // running in the context of just one of these index names. return Queries.newMatchAllQuery(); } } // None of the listed index names are this one return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.getFullyQualifiedIndex().getName() + " vs. " + values); }
@Override public Query termsQuery(List values, QueryShardContext context) { if (context == null) { return super.termsQuery(values, context); } for (Object value : values) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { // No need to OR these clauses - we can only logically be // running in the context of just one of these index names. return Queries.newMatchAllQuery(); } } // None of the listed index names are this one return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.getFullyQualifiedIndex().getName() + " vs. " + values); }
@Override public Query wildcardQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); if (isSameIndex(value, indexName)) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided pattern [" + value + "]."); } }
@Override @SuppressWarnings("unchecked") public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { IndexFieldData.Builder builder = fieldType.fielddataBuilder(shardContext.getFullyQualifiedIndex().getName()); IndexFieldDataCache cache = new IndexFieldDataCache.None(); CircuitBreakerService circuitBreaker = new NoneCircuitBreakerService(); return (IFD) builder.build(shardContext.getIndexSettings(), fieldType, cache, circuitBreaker, shardContext.getMapperService()); } };
@Override @SuppressWarnings("unchecked") public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { IndexFieldData.Builder builder = fieldType.fielddataBuilder(shardContext.getFullyQualifiedIndex().getName()); IndexFieldDataCache cache = new IndexFieldDataCache.None(); CircuitBreakerService circuitBreaker = new NoneCircuitBreakerService(); return (IFD) builder.build(shardContext.getIndexSettings(), fieldType, cache, circuitBreaker, shardContext.getMapperService()); } };
/** * This termQuery impl looks at the context to determine the index that * is being queried and then returns a MATCH_ALL_QUERY or MATCH_NO_QUERY * if the value matches this index. This can be useful if aliases or * wildcards are used but the aim is to restrict the query to specific * indices */ @Override public Query termQuery(Object value, @Nullable QueryShardContext context) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName() + " vs. " + value); } }
/** * This termQuery impl looks at the context to determine the index that * is being queried and then returns a MATCH_ALL_QUERY or MATCH_NO_QUERY * if the value matches this index. This can be useful if aliases or * wildcards are used but the aim is to restrict the query to specific * indices */ @Override public Query termQuery(Object value, @Nullable QueryShardContext context) { if (isSameIndex(value, context.getFullyQualifiedIndex().getName())) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("Index didn't match. Index queried: " + context.index().getName() + " vs. " + value); } }