本文整理汇总了Java中io.searchbox.core.Index.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Index.Builder方法的具体用法?Java Index.Builder怎么用?Java Index.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.searchbox.core.Index
的用法示例。
在下文中一共展示了Index.Builder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveIndex
import io.searchbox.core.Index; //导入方法依赖的package包/类
@Override
public IEsItem saveIndex(IEsItem doc) throws Exception {
Index.Builder builder = new Index.Builder(doc);
if (doc.getIndex() != null) {
builder.index(doc.getIndex());
}
if (doc.getType() != null) {
builder.type(doc.getType());
}
if (doc.getId() != null) {
builder.id(doc.getId());
}
DocumentResult result = _exec(builder.build());
if (result != null) {
doc.setIndex(result.getIndex());
doc.setType(result.getType());
doc.setId(result.getId());
return doc;
}
return null;
}
示例2: toIndexRequest
import io.searchbox.core.Index; //导入方法依赖的package包/类
public Index toIndexRequest() {
Index.Builder req = new Index.Builder(payload)
.index(key.index)
.type(key.type)
.id(key.id);
if (version != null) {
req.setParameter("version_type", "external").setParameter("version", version);
}
return req.build();
}
示例3: addElement
import io.searchbox.core.Index; //导入方法依赖的package包/类
@Override
public BulkableAction<DocumentResult> addElement(E element, boolean create) {
Document document = toDocument(element);
if (document == null) return null;
Index.Builder builder = new Index.Builder(document.getFields())
.index(document.getIndex())
.type(document.getType())
.id(document.getId());
return builder.build();
}
示例4: executeIndexAsString
import io.searchbox.core.Index; //导入方法依赖的package包/类
protected final Tuple<JestResult, HttpResponse> executeIndexAsString(final String string, final String index, final String type,
final String id, final boolean mustBeSuccesfull, final boolean connectFromLocalhost) throws Exception {
client = getJestClient(getServerUri(connectFromLocalhost), username, password);
Index.Builder builder = new Index.Builder(string).index(index).type(type)/*.refresh(true)*/.setHeader(headers);
if (id != null && id.length() > 0) {
builder = builder.id(id);
}
final Tuple<JestResult, HttpResponse> restu = client.executeE(builder.build());
final JestResult res = restu.v1();
if (mustBeSuccesfull) {
if (res.getErrorMessage() != null) {
log.error("Index operation result: " + res.getErrorMessage());
}
Assert.assertTrue("Error msg: " + res.getErrorMessage() + res.getJsonString(), res.isSucceeded());
} else {
log.error(res.getJsonString());
log.error("Index operation result fails as expected: " + res.getErrorMessage());
Assert.assertTrue(!res.isSucceeded());
}
return restu;
}
示例5: saveToIndex
import io.searchbox.core.Index; //导入方法依赖的package包/类
public void saveToIndex(SearchEntry entry) {
Index.Builder indexEntryBuilder = new Index.Builder(entry).id(entry.getId()).index(index).type(entry.getType());
if (useRefresh) {
indexEntryBuilder.refresh(true);
}
logger.debug("Indexing " + entry.getPath());
execute(indexEntryBuilder.build());
}
示例6: buildIndex
import io.searchbox.core.Index; //导入方法依赖的package包/类
private Index buildIndex(String indexName, String type, String source, String id) {
Index.Builder builder = new Index.Builder(source).index(indexName).type(type).id(id);
return builder.build();
}