use of com.qlangtech.tis.solrdao.ISchema in project plugins by qlangtech.
the class TestDataXElasticsearchWriter method testProjectionFromExpertModel.
public void testProjectionFromExpertModel() {
DataXElasticsearchWriter dataXWriter = new DataXElasticsearchWriter();
JSONObject body = new JSONObject();
body.put("content", IOUtils.loadResourceFromClasspath(DataXElasticsearchWriter.class, "mergeFromStupidModel_assert.json"));
ISchema schema = dataXWriter.projectionFromExpertModel(body);
assertNotNull(schema);
List<ESField> fields = schema.getSchemaFields();
assertEquals(2, fields.size());
ESField aaa = fields.get(0);
assertEquals("aaa", aaa.getName());
assertEquals(EsTokenizerType.visualTypeMap.get("long").type, aaa.getTisFieldTypeName());
assertTrue(aaa.isDocValue());
assertTrue(aaa.isIndexed());
assertTrue(aaa.isStored());
ESField bbb = fields.get(1);
assertEquals("bbb", bbb.getName());
assertEquals(DataXElasticsearchWriter.ES_TYPE_TEXT.getType(), bbb.getTisFieldTypeName());
assertEquals(EsTokenizerType.NULL.getKey(), bbb.getTokenizerType());
assertTrue(bbb.isDocValue());
assertTrue(bbb.isIndexed());
assertTrue(bbb.isStored());
SchemaMetaContent schemaContent = new SchemaMetaContent();
schemaContent.content = StringUtils.EMPTY.getBytes(TisUTF8.get());
schemaContent.parseResult = schema;
JSONObject schemaContentJson = schemaContent.toJSON();
// System.out.println(JsonUtil.toString(schemaContentJson));
JsonUtil.assertJSONEqual(DataXElasticsearchWriter.class, "projectionFromExpertModel_assert.json", schemaContentJson, (m, e, a) -> {
assertEquals(m, e, a);
});
}
Aggregations