use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenCore 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));
schema.addToFields(new LindenFieldSchema().setName("field1").setIndexed(true).setStored(false));
schema.addToFields(new LindenFieldSchema().setName("field2").setIndexed(true).setTokenized(true).setStored(false).setOmitFreqs(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).setMulti(true).setStored(true).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("hotwords").setStored(true));
schema.addToFields(new LindenFieldSchema().setName("tagnum").setType(LindenType.INTEGER).setIndexed(true));
lindenConfig.setSchema(schema);
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenDynamicField method testBuildField.
@Test
public void testBuildField() throws IOException {
LindenDocument lindenDocument = LindenDocumentBuilder.build(schema, JSON.parseObject(jsonStr));
List<LindenField> fields = lindenDocument.getFields();
Assert.assertEquals(true, fields.contains(new LindenField(new LindenFieldSchema().setName("mgroup").setType(LindenType.STRING).setIndexed(true).setStored(true), "misearch")));
Assert.assertEquals(true, fields.contains(new LindenField(new LindenFieldSchema().setName("cost").setType(LindenType.LONG).setIndexed(true).setStored(true), "30")));
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenFacet method init.
@Override
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("Language").setTokenized(false).setIndexed(true));
schema.addToFields(new LindenFieldSchema().setName("Title").setTokenized(true).setIndexed(true));
schema.addToFields(new LindenFieldSchema().setName("Author").setType(LindenType.FACET).setStored(true).setIndexed(true));
schema.addToFields(new LindenFieldSchema().setName("PublishDate").setType(LindenType.FACET).setStored(true));
lindenConfig.setSchema(schema);
lindenConfig.putToProperties("cluster.url", "localhost:2183/facettest");
lindenConfig.putToProperties("port", "19090");
lindenConfig.putToProperties("shard.id", "0");
lindenConfig.putToProperties("index.directory", "/tmp/linden-facet-test/index/0");
lindenConfig.putToProperties("log.path", "/tmp/linden-facet-test/log/0");
lindenConfig.putToProperties("search.timeout", "0");
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenFieldCache method init.
@Override
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setTokenized(true));
schema.addToFields(new LindenFieldSchema().setName("ids_int").setType(LindenType.INTEGER).setIndexed(true).setTokenized(true).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("ids_long").setType(LindenType.INTEGER).setIndexed(true).setTokenized(true).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("ids_str").setType(LindenType.STRING).setIndexed(true).setTokenized(true).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("ids_float").setType(LindenType.FLOAT).setIndexed(true).setTokenized(false).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("ids_double").setType(LindenType.DOUBLE).setIndexed(true).setTokenized(false).setMulti(true));
schema.addToFields(new LindenFieldSchema().setName("rank").setType(LindenType.FLOAT).setIndexed(true));
lindenConfig.setSchema(schema);
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class LindenScoreModelStrategyBuilder method isDistanceMethodNeeded.
private static boolean isDistanceMethodNeeded(LindenSchema schema) {
if (schema == null) {
return false;
}
boolean hasLat = false;
boolean hasLon = false;
for (LindenFieldSchema fieldSchema : schema.getFields()) {
if (fieldSchema.getName().equals(LATITUDE)) {
hasLat = true;
}
if (fieldSchema.getName().equals(LONGITUDE)) {
hasLon = true;
}
}
return hasLat && hasLon;
}
Aggregations