mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
parent
cbe18608ef
commit
d094042b08
@ -76,6 +76,7 @@ public class TermsFilterParser implements FilterParser {
|
||||
String lookupType = null;
|
||||
String lookupId = null;
|
||||
String lookupPath = null;
|
||||
String lookupRouting = null;
|
||||
|
||||
CacheKeyFilter.Key cacheKey = null;
|
||||
XContentParser.Token token;
|
||||
@ -109,6 +110,8 @@ public class TermsFilterParser implements FilterParser {
|
||||
lookupId = parser.text();
|
||||
} else if ("path".equals(currentFieldName)) {
|
||||
lookupPath = parser.text();
|
||||
} else if ("routing".equals(currentFieldName)) {
|
||||
lookupRouting = parser.textOrNull();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext.index(), "[terms] filter does not support [" + currentFieldName + "] within lookup element");
|
||||
}
|
||||
@ -164,7 +167,7 @@ public class TermsFilterParser implements FilterParser {
|
||||
}
|
||||
|
||||
// external lookup, use it
|
||||
TermsLookup termsLookup = new TermsLookup(fieldMapper, lookupIndex, lookupType, lookupId, lookupPath, parseContext);
|
||||
TermsLookup termsLookup = new TermsLookup(fieldMapper, lookupIndex, lookupType, lookupId, lookupRouting, lookupPath, parseContext);
|
||||
if (cacheKey == null) {
|
||||
cacheKey = new CacheKeyFilter.Key(termsLookup.toString());
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class TermsLookupFilterBuilder extends BaseFilterBuilder {
|
||||
private String lookupIndex;
|
||||
private String lookupType;
|
||||
private String lookupId;
|
||||
private String lookupRouting;
|
||||
private String lookupPath;
|
||||
|
||||
private String cacheKey;
|
||||
@ -81,6 +82,11 @@ public class TermsLookupFilterBuilder extends BaseFilterBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermsLookupFilterBuilder lookupRouting(String lookupRouting) {
|
||||
this.lookupRouting = lookupRouting;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermsLookupFilterBuilder cacheKey(String cacheKey) {
|
||||
this.cacheKey = cacheKey;
|
||||
return this;
|
||||
@ -96,6 +102,9 @@ public class TermsLookupFilterBuilder extends BaseFilterBuilder {
|
||||
}
|
||||
builder.field("type", lookupType);
|
||||
builder.field("id", lookupId);
|
||||
if (lookupRouting != null) {
|
||||
builder.field("routing", lookupRouting);
|
||||
}
|
||||
builder.field("path", lookupPath);
|
||||
builder.endObject();
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class IndicesTermsFilterCache extends AbstractComponent {
|
||||
return cache.get(cacheKey, new Callable<TermsFilterValue>() {
|
||||
@Override
|
||||
public TermsFilterValue call() throws Exception {
|
||||
GetResponse getResponse = client.get(new GetRequest(lookup.getIndex(), lookup.getType(), lookup.getId()).preference("_local")).actionGet();
|
||||
GetResponse getResponse = client.get(new GetRequest(lookup.getIndex(), lookup.getType(), lookup.getId()).preference("_local").routing(lookup.getRouting())).actionGet();
|
||||
if (!getResponse.isExists()) {
|
||||
return NO_TERMS;
|
||||
}
|
||||
|
@ -32,16 +32,18 @@ public class TermsLookup {
|
||||
private final String index;
|
||||
private final String type;
|
||||
private final String id;
|
||||
private final String routing;
|
||||
private final String path;
|
||||
|
||||
@Nullable
|
||||
private final QueryParseContext queryParseContext;
|
||||
|
||||
public TermsLookup(FieldMapper fieldMapper, String index, String type, String id, String path, @Nullable QueryParseContext queryParseContext) {
|
||||
public TermsLookup(FieldMapper fieldMapper, String index, String type, String id, String routing, String path, @Nullable QueryParseContext queryParseContext) {
|
||||
this.fieldMapper = fieldMapper;
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.routing = routing;
|
||||
this.path = path;
|
||||
this.queryParseContext = queryParseContext;
|
||||
}
|
||||
@ -62,6 +64,10 @@ public class TermsLookup {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getRouting() {
|
||||
return this.routing;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user