Search in sources :

Example 6 with ResultDocBuilder

use of io.zulia.doc.ResultDocBuilder in project zuliasearch by zuliaio.

the class StatTest method indexRecord.

private void indexRecord(int id, String title, String pathFacet, String normalFacet, int authorCount, List<Double> rating) throws Exception {
    String uniqueId = "" + id;
    Document mongoDocument = new Document();
    mongoDocument.put("id", uniqueId);
    mongoDocument.put("title", title);
    mongoDocument.put("pathFacet", pathFacet);
    mongoDocument.put("normalFacet", normalFacet);
    mongoDocument.put("authorCount", authorCount);
    mongoDocument.put("rating", rating);
    Store s = new Store(uniqueId, STAT_TEST_INDEX);
    ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument);
    s.setResultDocument(resultDocumentBuilder);
    zuliaWorkPool.store(s);
}
Also used : Store(io.zulia.client.command.Store) Document(org.bson.Document) ResultDocBuilder(io.zulia.doc.ResultDocBuilder)

Example 7 with ResultDocBuilder

use of io.zulia.doc.ResultDocBuilder in project zuliasearch by zuliaio.

the class HierarchicalFacetTest method indexRecord.

private void indexRecord(int id, String path, int i) throws Exception {
    boolean half = (i % 2 == 0);
    boolean tenth = (i % 10 == 0);
    String uniqueId = "mySpecialId-" + id;
    Document mongoDocument = new Document();
    mongoDocument.put("path", path);
    mongoDocument.put("path2", path);
    mongoDocument.put("normalFacet", path);
    mongoDocument.put("id", id);
    if (tenth) {
        // 1/10 of input
        Date d = Date.from(LocalDate.of(2014, Month.OCTOBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
        mongoDocument.put("date", d);
    } else if (half) {
        // 2/5 of input
        Date d = Date.from(LocalDate.of(2013, Month.SEPTEMBER, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
        mongoDocument.put("date", d);
        mongoDocument.put("normalFacetList", Arrays.asList("value1", "something"));
    } else {
        // 1/2 of input
        Date d = Date.from(LocalDate.of(2012, 8, 4).atStartOfDay(ZoneId.of("UTC")).toInstant());
        mongoDocument.put("date", d);
        mongoDocument.put("normalFacetList", Arrays.asList("value2", "something2"));
    }
    Store s = new Store(uniqueId, FACET_TEST_INDEX);
    ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument);
    s.setResultDocument(resultDocumentBuilder);
    zuliaWorkPool.store(s);
}
Also used : Store(io.zulia.client.command.Store) Document(org.bson.Document) Date(java.util.Date) LocalDate(java.time.LocalDate) ResultDocBuilder(io.zulia.doc.ResultDocBuilder)

Example 8 with ResultDocBuilder

use of io.zulia.doc.ResultDocBuilder in project zuliasearch by zuliaio.

the class Mapper method toResultDocumentBuilder.

public ResultDocBuilder toResultDocumentBuilder(T object) throws Exception {
    String uniqueId = uniqueIdField.build(object);
    Document document = toDocument(object);
    ResultDocBuilder resultDocumentBuilder = new ResultDocBuilder();
    resultDocumentBuilder.setDocument(document).setUniqueId(uniqueId);
    return resultDocumentBuilder;
}
Also used : Document(org.bson.Document) ResultDocBuilder(io.zulia.doc.ResultDocBuilder)

Aggregations

ResultDocBuilder (io.zulia.doc.ResultDocBuilder)8 Store (io.zulia.client.command.Store)7 Document (org.bson.Document)6 Date (java.util.Date)3 LocalDate (java.time.LocalDate)2 WorkPool (io.zulia.client.pool.WorkPool)1 ZuliaWorkPool (io.zulia.client.pool.ZuliaWorkPool)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)1 ZipArchiveInputStream (org.apache.commons.compress.archivers.zip.ZipArchiveInputStream)1