Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remove] Type from Search Internals #2109

Merged
merged 4 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix failing tests
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Feb 17, 2022
commit d150bccd498f3f94905d15dc848b40ca863c54d6
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

package org.opensearch.index.query;

import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.opensearch.Version;
import org.opensearch.common.ParseField;
Expand Down Expand Up @@ -166,12 +165,9 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws

@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
MappedFieldType idField = context.fieldMapper(IdFieldMapper.NAME);
if (idField == null) {
return new MatchNoDocsQuery("No mappings");
}
if (this.ids.isEmpty()) {
return new MatchNoDocsQuery("Missing ids in \"" + this.getName() + "\" query.");
MappedFieldType idField = context.getFieldType(IdFieldMapper.NAME);
if (idField == null || ids.isEmpty()) {
throw new IllegalStateException("Rewrite first");
}
return idField.termsQuery(new ArrayList<>(ids), context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ private SearchRequest mutate(SearchRequest searchRequest) {
}

public void testDescriptionForDefault() {
assertThat(toDescription(new SearchRequest()), equalTo("indices[], types[], search_type[QUERY_THEN_FETCH], source[]"));
assertThat(toDescription(new SearchRequest()), equalTo("indices[], search_type[QUERY_THEN_FETCH], source[]"));
}

public void testDescriptionIncludesScroll() {
assertThat(
toDescription(new SearchRequest().scroll(TimeValue.timeValueMinutes(5))),
equalTo("indices[], types[], search_type[QUERY_THEN_FETCH], scroll[5m], source[]")
equalTo("indices[], search_type[QUERY_THEN_FETCH], scroll[5m], source[]")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected QueryBuilder parseQuery(XContentParser parser) throws IOException {

@Override
public void testMustRewrite() throws IOException {
super.testMustRewrite();
QueryShardContext context = createShardContextWithNoType();
context.setAllowUnmappedFields(true);
IdsQueryBuilder queryBuilder = createTestQueryBuilder();
Expand Down