use of com.xiaomi.linden.thrift.common.LindenSchema in project linden by XiaoMi.
the class TestGlobalIDF method init.
@Override
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setStored(true).setTokenized(true).setOmitNorms(true));
schema.addToFields(new LindenFieldSchema().setName("field1").setIndexed(true).setStored(true).setTokenized(true).setOmitNorms(true));
schema.addToFields(new LindenFieldSchema().setName("field2").setIndexed(true).setStored(true).setTokenized(true).setOmitNorms(true));
schema.addToFields(new LindenFieldSchema().setName("rank").setType(LindenType.FLOAT).setIndexed(true).setStored(true));
schema.addToFields(new LindenFieldSchema().setName("cat1").setType(LindenType.INTEGER).setIndexed(true).setStored(true));
schema.addToFields(new LindenFieldSchema().setName("cat2").setType(LindenType.DOUBLE).setIndexed(true).setStored(true));
schema.addToFields(new LindenFieldSchema().setName("tagstr").setIndexed(true));
schema.addToFields(new LindenFieldSchema().setName("tagnum").setType(LindenType.INTEGER).setIndexed(true));
lindenConfig.setSchema(schema);
}
use of com.xiaomi.linden.thrift.common.LindenSchema in project linden by XiaoMi.
the class LindenConfigBuilder method build.
public static LindenConfig build() throws IOException {
File lindenProperties = new File("lindenProperties");
Preconditions.checkArgument(lindenProperties.exists(), "can not find linden properties file.");
try {
LindenConfig lindenConf = com.xiaomi.linden.core.LindenConfigBuilder.build(lindenProperties);
File lindenSchema = new File("lindenSchema");
Preconditions.checkArgument(lindenSchema.exists(), "can not find linden schema file.");
LindenSchema schema;
try {
schema = LindenSchemaBuilder.build(lindenSchema);
} catch (Exception e) {
logger.error("Linden schema builder exception", e);
throw new IOException(e);
}
lindenConf.setSchema(schema);
lindenConf.setIndexType(LindenConfig.IndexType.RAM);
return lindenConf;
} catch (Exception e) {
logger.error("Linden search config builder exception", e);
throw new IOException(e);
}
}
use of com.xiaomi.linden.thrift.common.LindenSchema in project linden by XiaoMi.
the class LindenSchemaBuilder method build.
public static LindenSchema build(File schemaFile) throws Exception {
Preconditions.checkNotNull(schemaFile);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(schemaFile);
dom.getDocumentElement().normalize();
NodeList table = dom.getElementsByTagName(TABLE);
Node colNode = table.item(0);
LindenSchema lindenSchema = new LindenSchema();
lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue());
NodeList colList = dom.getElementsByTagName(TABLE_COLUMN);
for (int i = 0; i < colList.getLength(); ++i) {
Element element = (Element) colList.item(i);
LindenFieldSchema fieldSchema = parseFiled(element);
verifyFieldSchema(fieldSchema);
lindenSchema.addToFields(fieldSchema);
}
return lindenSchema;
}
use of com.xiaomi.linden.thrift.common.LindenSchema in project linden by XiaoMi.
the class TestLindenWordDelimiterAnalyzer method init.
@Override
public void init() {
lindenConfig.setIndexType(LindenConfig.IndexType.RAM);
lindenConfig.setClusterUrl("127.0.0.1:2181/mock");
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setTokenized(true).setSnippet(true).setMulti(true));
lindenConfig.setSchema(schema);
lindenConfig.putToProperties("search.analyzer.class", "com.xiaomi.linden.lucene.analyzer.LindenWordDelimiterAnalyzerFactory");
lindenConfig.putToProperties("index.analyzer.class", "com.xiaomi.linden.lucene.analyzer.LindenWordDelimiterAnalyzerFactory");
lindenConfig.putToProperties("index.analyzer.luceneMatchVersion", "LUCENE_4_10_0");
lindenConfig.putToProperties("search.analyzer.luceneMatchVersion", "LUCENE_4_10_0");
}
use of com.xiaomi.linden.thrift.common.LindenSchema in project linden by XiaoMi.
the class TestFlexibleQuery method init.
@Override
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("text").setIndexed(true).setStored(true).setTokenized(true));
schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setStored(true).setTokenized(true));
lindenConfig.setSchema(schema);
}
Aggregations