use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.
the class AggregatorFactoriesBuilderTests method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
// register aggregations as NamedWriteable
SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
namedXContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.
the class AggregatorFactoriesTests method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, emptyList()).getNamedXContents());
}
use of org.opensearch.search.SearchModule in project ml-commons by opensearch-project.
the class AnomalyLocalizationInputTests method testXContentMissingAnomalyStartFilter.
@Test
public void testXContentMissingAnomalyStartFilter() throws Exception {
AnomalyLocalizationInput input = new AnomalyLocalizationInput("indexName", Arrays.asList("attribute"), Arrays.asList(AggregationBuilders.max("max").field("field")), "@timestamp", 0L, 10L, 1L, 2, Optional.empty(), Optional.empty());
XContentBuilder builder = XContentFactory.jsonBuilder();
builder = input.toXContent(builder, null);
String json = Strings.toString(builder);
XContentParser parser = XContentType.JSON.xContent().createParser(new NamedXContentRegistry(new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedXContents()), null, json);
parser.nextToken();
AnomalyLocalizationInput newInput = AnomalyLocalizationInput.parse(parser);
assertEquals(input, newInput);
}
use of org.opensearch.search.SearchModule in project ml-commons by opensearch-project.
the class AnomalyLocalizationInputTests method testXContentFullObject.
@Test
public void testXContentFullObject() throws Exception {
AnomalyLocalizationInput input = new AnomalyLocalizationInput("indexName", Arrays.asList("attribute"), Arrays.asList(AggregationBuilders.max("max").field("field"), AggregationBuilders.min("min").field("field")), "@timestamp", 0L, 10L, 1L, 2, Optional.of(3L), Optional.of(QueryBuilders.matchAllQuery()));
XContentBuilder builder = XContentFactory.jsonBuilder();
builder = input.toXContent(builder, null);
String json = Strings.toString(builder);
XContentParser parser = XContentType.JSON.xContent().createParser(new NamedXContentRegistry(new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedXContents()), null, json);
parser.nextToken();
AnomalyLocalizationInput newInput = AnomalyLocalizationInput.parse(parser);
assertEquals(input, newInput);
}
use of org.opensearch.search.SearchModule in project OpenSearch by opensearch-project.
the class InnerHitBuilderTests method init.
@BeforeClass
public static void init() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Aggregations