Skip to content

Commit

Permalink
issue #1040: fixes npe on getting vectorindex name
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-vi committed Jul 31, 2024
1 parent 1a4e798 commit e091e20
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

import io.openk9.client.grpc.common.StructUtils;
import io.openk9.datasource.model.Bucket;
import io.openk9.datasource.model.DataIndex;
import io.openk9.datasource.model.Datasource;
import io.openk9.datasource.model.DocTypeField;
import io.openk9.datasource.model.FieldType;
import io.openk9.datasource.model.Language;
import io.openk9.datasource.model.SearchConfig;
import io.openk9.datasource.model.SuggestionCategory;
import io.openk9.datasource.model.VectorIndex;
import io.openk9.datasource.model.util.JWT;
import io.openk9.datasource.searcher.parser.ParserContext;
import io.openk9.datasource.searcher.parser.impl.HybridQueryParser;
Expand Down Expand Up @@ -96,7 +94,6 @@

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -1058,25 +1055,29 @@ private Map<String, List<String>> _getExtraParams(Map<String, Value> extraMap) {


private static String[] _getIndexNames(QueryParserRequest request, Bucket tenant) {
String[] indexNames;
var dataIndices = tenant.getDatasources()
.stream()
.map(Datasource::getDataIndex)
.distinct()
.toArray(DataIndex[]::new);
var indexNames = new HashSet<String>();

var datasources = tenant.getDatasources();

if (request.hasVectorIndices() && request.getVectorIndices()) {
indexNames = Arrays.stream(dataIndices)
.map(DataIndex::getVectorIndex)
.map(VectorIndex::getName)
.toArray(String[]::new);
for (Datasource datasource : datasources) {
var dataIndex = datasource.getDataIndex();
var vectorIndex = dataIndex.getVectorIndex();

if (vectorIndex != null) {
indexNames.add(vectorIndex.getName());
}
}
}
else {
indexNames = Arrays.stream(dataIndices)
.map(DataIndex::getName)
.toArray(String[]::new);
for (Datasource datasource : datasources) {
var dataIndex = datasource.getDataIndex();

indexNames.add(dataIndex.getName());
}
}
return indexNames;

return indexNames.toArray(String[]::new);
}

@Inject
Expand Down

0 comments on commit e091e20

Please sign in to comment.