Skip to content

Commit

Permalink
issue #1026: uses indexName in DataIndex and VectorIndex to point index
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-vi committed Aug 28, 2024
1 parent 894f6a7 commit 1d59df6
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public Uni<Connection<DocType>> docTypes(


public Uni<Long> getDocCount(@Source DataIndex dataIndex) {
return dataIndexService.getCountIndexDocuments(dataIndex.getName());
return dataIndexService.getCountIndexDocuments(dataIndex.getIndexName());
}

public Uni<CatResponse> getCat(@Source DataIndex dataIndex){
return indexService.get_catIndicesFirst(dataIndex.getName());
return indexService.get_catIndicesFirst(dataIndex.getIndexName());
}

@Query
Expand All @@ -91,13 +91,13 @@ public Uni<DataIndex> getDataIndex(@Id long id) {

public Uni<String> mappings(@Source DataIndex dataIndex) {
return indexService
.getMappings(dataIndex.getName())
.getMappings(dataIndex.getIndexName())
.map(Json::encode);
}

public Uni<String> settings(@Source DataIndex dataIndex) {
return indexService
.getSettings(dataIndex.getName())
.getSettings(dataIndex.getIndexName())
.map(Json::encode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Receive<Command> createReceive() {
private Behavior<Command> onDeleteEsIndices() {
String[] names = currentChunk
.stream()
.map(DataIndex::getName)
.map(DataIndex::getIndexName)
.toArray(String[]::new);

DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(names);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ private static Behavior<Command> onCopyIndexTemplate(

DataIndex oldDataIndex = scheduler.getOldDataIndex();
DataIndex newDataIndex = scheduler.getNewDataIndex();
String newDataIndexName = newDataIndex.getName();
String newDataIndexName = newDataIndex.getIndexName();

IndicesClient indices = restHighLevelClient.indices();

indices.getIndexTemplateAsync(
new GetComposableIndexTemplateRequest(oldDataIndex.getName() + "-template"),
new GetComposableIndexTemplateRequest(oldDataIndex.getIndexName() + "-template"),
RequestOptions.DEFAULT, new ActionListener<>() {
@Override
public void onResponse(GetComposableIndexTemplatesResponse indexTemplate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ public void removeDocType(DocType docType) {
docTypes.remove(docType);
}

public String getIndexName() {
return getTenant() + "-" + name;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ public enum ChunkType {
SEMANTIC_SPLITTER
}

public String getIndexName() {
return getTenant() + "-" + name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Uni<EmbeddingChunksConfiguration> getEmbeddingChunksConfigurations(
vectorIndex.getChunkType(),
vectorIndex.getChunkWindowSize(),
vectorIndex.getJsonConfig(),
vectorIndex.getDataIndex().getName()
vectorIndex.getDataIndex().getIndexName()
))
))
.onFailure(EmbeddingServiceException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public interface SchedulerMapper {
@Mapping(source = "datasource.id", target = "datasourceId"),
@Mapping(source = "datasource.enrichPipeline", target = "enrichItems"),
@Mapping(source = "oldDataIndex.id", target = "oldDataIndexId"),
@Mapping(source = "oldDataIndex.name", target = "oldDataIndexName"),
@Mapping(source = "oldDataIndex.indexName", target = "oldDataIndexName"),
@Mapping(source = "newDataIndex.id", target = "newDataIndexId"),
@Mapping(source = "newDataIndex.name", target = "newDataIndexName"),
@Mapping(source = "newDataIndex.indexName", target = "newDataIndexName"),
@Mapping(
source = "oldDataIndex.vectorIndex.name",
source = "oldDataIndex.vectorIndex.indexName",
target = "vectorIndexName"
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public Uni<Void> generateDocTypeFields(Mutiny.Session session, DataIndex dataInd
}

return indexService
.getMappings(dataIndex.getName())
.getMappings(dataIndex.getIndexName())
.map(IndexerEvents::toDocTypeFields)
.plug(docTypeFields -> Uni.combine().all()
.unis(
docTypeFields,
_getDocumentTypes(dataIndex.getName())
_getDocumentTypes(dataIndex.getIndexName())
)
.asTuple()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,15 +1065,15 @@ private static String[] _getIndexNames(QueryParserRequest request, Bucket tenant
var vectorIndex = dataIndex.getVectorIndex();

if (vectorIndex != null) {
indexNames.add(vectorIndex.getName());
indexNames.add(vectorIndex.getIndexName());
}
}
}
else {
for (Datasource datasource : datasources) {
var dataIndex = datasource.getDataIndex();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public List<CategorySemantics> annotate(String...tokens) {
.getDatasources()
.stream()
.map(Datasource::getDataIndex)
.map(DataIndex::getName)
.map(DataIndex::getIndexName)
.toArray(String[]::new);

SearchRequest searchRequest = new SearchRequest(indexNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public List<CategorySemantics> annotate(String...tokens) {
.getDatasources()
.stream()
.map(Datasource::getDataIndex)
.map(DataIndex::getName)
.map(DataIndex::getIndexName)
.toArray(String[]::new);

SearchRequest searchRequest = new SearchRequest(indexNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public List<CategorySemantics> annotate(String...tokens) {
.getDatasources()
.stream()
.map(Datasource::getDataIndex)
.map(DataIndex::getName)
.map(DataIndex::getIndexName)
.toArray(String[]::new);

SearchRequest searchRequest = new SearchRequest(indexNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public List<CategorySemantics> annotate(String...tokens) {
.getDatasources()
.stream()
.map(Datasource::getDataIndex)
.map(DataIndex::getName)
.map(DataIndex::getIndexName)
.toArray(String[]::new);

SearchRequest searchRequest = new SearchRequest(indexNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public Uni<DataIndex> deleteById(long entityId) {
.<AcknowledgedResponse>emitter(emitter -> {

DeleteIndexRequest deleteIndexRequest =
new DeleteIndexRequest(dataIndex.getName());
new DeleteIndexRequest(dataIndex.getIndexName());

deleteIndexRequest
.indicesOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ private Uni<List<String>> indexesDiff(Scheduler scheduler) {

SearchRequest searchRequest = new SearchRequest();
searchRequest.indices(
scheduler.getOldDataIndex().getName(),
scheduler.getNewDataIndex().getName());
scheduler.getOldDataIndex().getIndexName(),
scheduler.getNewDataIndex().getIndexName()
);

SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
TermsAggregationBuilder aggregation = AggregationBuilders
Expand Down

0 comments on commit 1d59df6

Please sign in to comment.