
com.redislabs.lettusearch.search.Document Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lettusearch Show documentation
Show all versions of lettusearch Show documentation
Java client for RediSearch based on Lettuce
package com.redislabs.lettusearch.search;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import io.lettuce.core.internal.LettuceAssert;
import lombok.*;
import lombok.experimental.Accessors;
public class Document extends LinkedHashMap {
private static final long serialVersionUID = 8972665675834263492L;
@Getter
@Setter
private K id;
@Getter
@Setter
private Double score;
@Getter
@Setter
private V payload;
public static DocumentBuilder builder() {
return new DocumentBuilder();
}
@Setter
@Accessors(fluent = true)
public static class DocumentBuilder {
private String id;
private double score = 1;
private String payload;
private Map fields = new HashMap<>();
public DocumentBuilder field(String name, String value) {
fields.put(name, value);
return this;
}
public Document build() {
LettuceAssert.notNull(id, "Id is required.");
LettuceAssert.notNull(fields, "Fields are required.");
Document document = new Document<>();
document.setId(id);
document.setScore(score);
document.setPayload(payload);
document.putAll(fields);
return document;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy