forked from opensearch-project/neural-search
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yuye-aws <[email protected]>
- Loading branch information
Showing
8 changed files
with
236 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
.../java/org/opensearch/neuralsearch/processor/factory/DocumentChunkingProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.neuralsearch.processor.factory; | ||
|
||
import java.util.Map; | ||
|
||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.env.Environment; | ||
import org.opensearch.index.analysis.AnalysisRegistry; | ||
import org.opensearch.indices.IndicesService; | ||
import org.opensearch.ingest.Processor; | ||
import org.opensearch.neuralsearch.processor.DocumentChunkingProcessor; | ||
import static org.opensearch.neuralsearch.processor.DocumentChunkingProcessor.TYPE; | ||
import static org.opensearch.neuralsearch.processor.DocumentChunkingProcessor.FIELD_MAP_FIELD; | ||
import static org.opensearch.neuralsearch.processor.DocumentChunkingProcessor.ALGORITHM_FIELD; | ||
import static org.opensearch.ingest.ConfigurationUtils.readMap; | ||
|
||
/** | ||
* Factory for chunking ingest processor for ingestion pipeline. | ||
* Instantiates processor based on user provided input. | ||
*/ | ||
public class DocumentChunkingProcessorFactory implements Processor.Factory { | ||
|
||
private final Environment environment; | ||
|
||
private final ClusterService clusterService; | ||
|
||
private final IndicesService indicesService; | ||
|
||
private final AnalysisRegistry analysisRegistry; | ||
|
||
public DocumentChunkingProcessorFactory( | ||
Environment environment, | ||
ClusterService clusterService, | ||
IndicesService indicesService, | ||
AnalysisRegistry analysisRegistry | ||
) { | ||
this.environment = environment; | ||
this.clusterService = clusterService; | ||
this.indicesService = indicesService; | ||
this.analysisRegistry = analysisRegistry; | ||
} | ||
|
||
@Override | ||
public DocumentChunkingProcessor create( | ||
Map<String, Processor.Factory> registry, | ||
String processorTag, | ||
String description, | ||
Map<String, Object> config | ||
) throws Exception { | ||
Map<String, Object> fieldMap = readMap(TYPE, processorTag, config, FIELD_MAP_FIELD); | ||
Map<String, Object> algorithmMap = readMap(TYPE, processorTag, config, ALGORITHM_FIELD); | ||
return new DocumentChunkingProcessor( | ||
processorTag, | ||
description, | ||
fieldMap, | ||
algorithmMap, | ||
environment, | ||
clusterService, | ||
indicesService, | ||
analysisRegistry | ||
); | ||
} | ||
} |
Oops, something went wrong.