Skip to content

Commit

Permalink
ignore no mapping index
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <ihailong@amazon.com>
  • Loading branch information
Hailong-am committed Jan 12, 2024
1 parent 1dbaa72 commit 010ae7f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
import lombok.Setter;
import lombok.extern.log4j.Log4j2;

/**
* Take index mapping and sample data as summary, embedding it and save to k-NN index as vector store
*/
@Log4j2
public class IndexSummaryEmbeddingJob implements Runnable {

Expand Down Expand Up @@ -184,9 +187,13 @@ private List<Map<String, Object>> getAllIndexMappingAndSampleData() {
indexSummaryMap.put(ALIASES, indexMetadata.getAliases().keySet());

Map<String, Object> sourceAsMap = indexMetadata.mapping().getSourceAsMap();
// if index don't have any mapping, ignore
if (sourceAsMap == null || sourceAsMap.isEmpty()) {
log.debug("No mapping for index {}", indexName);
continue;
}
try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) {
builder.map(sourceAsMap);
// String mapping = AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> new Gson().toJson(sourceAsMap));
String mapping = builder.toString();

// sample data
Expand Down

0 comments on commit 010ae7f

Please sign in to comment.