Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder optio
}
groupSource.explain(options.isExplain());
groupSource.trackScores(options.isTrackScores());
groupSource.version(options.isVersion());
return groupSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.action.search;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.document.DocumentField;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.Text;
Expand Down Expand Up @@ -248,6 +247,8 @@ public void run() throws IOException {

public void testExpandRequestOptions() throws IOException {
MockSearchPhaseContext mockSearchPhaseContext = new MockSearchPhaseContext(1);
boolean version = randomBoolean();

mockSearchPhaseContext.searchTransport = new SearchTransportService(
Settings.builder().put("search.remote.connect", false).build(), null, null) {

Expand All @@ -256,13 +257,14 @@ void sendExecuteMultiSearch(MultiSearchRequest request, SearchTask task, ActionL
final QueryBuilder postFilter = QueryBuilders.existsQuery("foo");
assertTrue(request.requests().stream().allMatch((r) -> "foo".equals(r.preference())));
assertTrue(request.requests().stream().allMatch((r) -> "baz".equals(r.routing())));
assertTrue(request.requests().stream().allMatch((r) -> version == r.source().version()));
assertTrue(request.requests().stream().allMatch((r) -> postFilter.equals(r.source().postFilter())));
}
};
mockSearchPhaseContext.getRequest().source(new SearchSourceBuilder()
.collapse(
new CollapseBuilder("someField")
.setInnerHits(new InnerHitBuilder().setName("foobarbaz"))
.setInnerHits(new InnerHitBuilder().setName("foobarbaz").setVersion(version))
)
.postFilter(QueryBuilders.existsQuery("foo")))
.preference("foobar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,48 @@ setup:
index: test
type: test
id: 1
version_type: external
version: 11
body: { numeric_group: 1, sort: 10 }
- do:
index:
index: test
type: test
id: 2
version_type: external
version: 22
body: { numeric_group: 1, sort: 6 }
- do:
index:
index: test
type: test
id: 3
version_type: external
version: 33
body: { numeric_group: 1, sort: 24 }
- do:
index:
index: test
type: test
id: 4
version_type: external
version: 44
body: { numeric_group: 25, sort: 10 }
- do:
index:
index: test
type: test
id: 5
version_type: external
version: 55
body: { numeric_group: 25, sort: 5 }
- do:
index:
index: test
type: test
id: 6
version_type: external
version: 66
body: { numeric_group: 3, sort: 36 }
- do:
indices.refresh:
Expand Down Expand Up @@ -322,3 +334,56 @@ setup:
- match: { hits.hits.2.inner_hits.sub_hits_desc.hits.total: 2 }
- length: { hits.hits.2.inner_hits.sub_hits_desc.hits.hits: 1 }
- match: { hits.hits.2.inner_hits.sub_hits_desc.hits.hits.0._id: "4" }

---
"field collapsing, inner_hits and version":

- skip:
version: " - 6.99.99"
reason: "bug fixed in 7.0.0"

- do:
search:
index: test
type: test
body:
collapse: { field: numeric_group, inner_hits: { name: sub_hits, version: true, size: 2, sort: [{ sort: asc }] } }
sort: [{ sort: desc }]
version: true

- match: { hits.total: 6 }
- length: { hits.hits: 3 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._type: test }
- match: { hits.hits.0.fields.numeric_group: [3] }
- match: { hits.hits.0.sort: [36] }
- match: { hits.hits.0._id: "6" }
- match: { hits.hits.0._version: 66 }
- match: { hits.hits.0.inner_hits.sub_hits.hits.total: 1 }
- length: { hits.hits.0.inner_hits.sub_hits.hits.hits: 1 }
- match: { hits.hits.0.inner_hits.sub_hits.hits.hits.0._id: "6" }
- match: { hits.hits.0.inner_hits.sub_hits.hits.hits.0._version: 66 }
- match: { hits.hits.1._index: test }
- match: { hits.hits.1._type: test }
- match: { hits.hits.1.fields.numeric_group: [1] }
- match: { hits.hits.1.sort: [24] }
- match: { hits.hits.1._id: "3" }
- match: { hits.hits.1._version: 33 }
- match: { hits.hits.1.inner_hits.sub_hits.hits.total: 3 }
- length: { hits.hits.1.inner_hits.sub_hits.hits.hits: 2 }
- match: { hits.hits.1.inner_hits.sub_hits.hits.hits.0._id: "2" }
- match: { hits.hits.1.inner_hits.sub_hits.hits.hits.0._version: 22 }
- match: { hits.hits.1.inner_hits.sub_hits.hits.hits.1._id: "1" }
- match: { hits.hits.1.inner_hits.sub_hits.hits.hits.1._version: 11 }
- match: { hits.hits.2._index: test }
- match: { hits.hits.2._type: test }
- match: { hits.hits.2.fields.numeric_group: [25] }
- match: { hits.hits.2.sort: [10] }
- match: { hits.hits.2._id: "4" }
- match: { hits.hits.2._version: 44 }
- match: { hits.hits.2.inner_hits.sub_hits.hits.total: 2 }
- length: { hits.hits.2.inner_hits.sub_hits.hits.hits: 2 }
- match: { hits.hits.2.inner_hits.sub_hits.hits.hits.0._id: "5" }
- match: { hits.hits.2.inner_hits.sub_hits.hits.hits.0._version: 55 }
- match: { hits.hits.2.inner_hits.sub_hits.hits.hits.1._id: "4" }
- match: { hits.hits.2.inner_hits.sub_hits.hits.hits.1._version: 44 }