Expose internal search source builder

This commit is contained in:
kimchy 2010-09-15 12:43:21 +02:00
parent 3afe4da550
commit 8db2a217c0
2 changed files with 12 additions and 9 deletions

View File

@ -47,8 +47,6 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
private SearchSourceBuilder sourceBuilder;
private HighlightBuilder highlightBuilder;
public SearchRequestBuilder(Client client) {
super(client, new SearchRequest());
}
@ -376,10 +374,11 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
return this;
}
@Override protected void doExecute(ActionListener<SearchResponse> listener) {
if (highlightBuilder != null) {
sourceBuilder().highlight(highlightBuilder);
public SearchSourceBuilder internalBuilder() {
return sourceBuilder();
}
@Override protected void doExecute(ActionListener<SearchResponse> listener) {
request.source(sourceBuilder());
client.search(request, listener);
}
@ -392,9 +391,6 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
}
private HighlightBuilder highlightBuilder() {
if (highlightBuilder == null) {
highlightBuilder = new HighlightBuilder();
}
return highlightBuilder;
return sourceBuilder().highlighter();
}
}

View File

@ -195,6 +195,13 @@ public class SearchSourceBuilder implements ToXContent {
return this;
}
public HighlightBuilder highlighter() {
if (highlightBuilder == null) {
highlightBuilder = new HighlightBuilder();
}
return highlightBuilder;
}
/**
* Adds highlight to perform as part of the search.
*/