mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
Term Vectors: Fix NPE with dfs and no tvs
Fixes a bug with dfs option for when term vectors are not stored and not generated.
This commit is contained in:
parent
9956e7721d
commit
936b4c63fc
@ -107,7 +107,7 @@ public class ShardTermVectorService extends AbstractIndexShardComponent {
|
||||
if (topLevelFields == null) {
|
||||
topLevelFields = termVectorsByField;
|
||||
}
|
||||
if (useDfs(request)) {
|
||||
if (termVectorsByField != null && useDfs(request)) {
|
||||
dfs = getAggregatedDfs(termVectorsByField, request);
|
||||
}
|
||||
termVectorResponse.setFields(termVectorsByField, request.selectedFields(), request.getFlags(), topLevelFields, dfs);
|
||||
@ -127,7 +127,7 @@ public class ShardTermVectorService extends AbstractIndexShardComponent {
|
||||
if (selectedFields != null) {
|
||||
termVectorsByField = addGeneratedTermVectors(get, termVectorsByField, request, selectedFields);
|
||||
}
|
||||
if (useDfs(request)) {
|
||||
if (termVectorsByField != null && useDfs(request)) {
|
||||
dfs = getAggregatedDfs(termVectorsByField, request);
|
||||
}
|
||||
termVectorResponse.setFields(termVectorsByField, request.selectedFields(), request.getFlags(), topLevelFields, dfs);
|
||||
|
@ -90,8 +90,7 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
|
||||
|
||||
ensureYellow();
|
||||
|
||||
// when indexing a field that simply has a question mark, the term
|
||||
// vectors will be null
|
||||
// when indexing a field that simply has a question mark, the term vectors will be null
|
||||
client().prepareIndex("test", "type1", "0").setSource("existingfield", "?").execute().actionGet();
|
||||
refresh();
|
||||
ActionFuture<TermVectorResponse> termVector = client().termVector(new TermVectorRequest(indexOrAlias(), "type1", "0")
|
||||
@ -119,12 +118,14 @@ public class GetTermVectorTests extends AbstractTermVectorTests {
|
||||
|
||||
ensureYellow();
|
||||
|
||||
// when indexing a field that simply has a question mark, the term
|
||||
// vectors will be null
|
||||
// when indexing a field that simply has a question mark, the term vectors will be null
|
||||
client().prepareIndex("test", "type1", "0").setSource("anotherexistingfield", 1).execute().actionGet();
|
||||
refresh();
|
||||
ActionFuture<TermVectorResponse> termVector = client().termVector(new TermVectorRequest(indexOrAlias(), "type1", "0")
|
||||
.selectedFields(new String[]{"existingfield"}));
|
||||
.selectedFields(randomBoolean() ? new String[]{"existingfield"} : null)
|
||||
.termStatistics(true)
|
||||
.fieldStatistics(true)
|
||||
.dfs(true));
|
||||
|
||||
// lets see if the null term vectors are caught...
|
||||
TermVectorResponse actionGet = termVector.actionGet();
|
||||
|
Loading…
x
Reference in New Issue
Block a user