Search in sources :

Example 1 with LindenFieldSchema

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);
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema)

Example 2 with LindenFieldSchema

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")));
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenField(com.xiaomi.linden.thrift.common.LindenField) LindenDocument(com.xiaomi.linden.thrift.common.LindenDocument) Test(org.junit.Test)

Example 3 with LindenFieldSchema

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");
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema)

Example 4 with LindenFieldSchema

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);
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema) LindenSchema(com.xiaomi.linden.thrift.common.LindenSchema)

Example 5 with LindenFieldSchema

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;
}
Also used : LindenFieldSchema(com.xiaomi.linden.thrift.common.LindenFieldSchema)

Aggregations

LindenFieldSchema (com.xiaomi.linden.thrift.common.LindenFieldSchema)31 LindenSchema (com.xiaomi.linden.thrift.common.LindenSchema)17 LindenField (com.xiaomi.linden.thrift.common.LindenField)4 JSONObject (com.alibaba.fastjson.JSONObject)3 LindenDocument (com.xiaomi.linden.thrift.common.LindenDocument)3 IOException (java.io.IOException)3 JSONArray (com.alibaba.fastjson.JSONArray)2 Coordinate (com.xiaomi.linden.thrift.common.Coordinate)2 LindenType (com.xiaomi.linden.thrift.common.LindenType)2 Document (org.apache.lucene.document.Document)2 IndexableField (org.apache.lucene.index.IndexableField)2 Shape (com.spatial4j.core.shape.Shape)1 LindenValue (com.xiaomi.linden.thrift.common.LindenValue)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1