当前位置: 首页>>代码示例>>Java>>正文


Java SearchHitField.getValues方法代码示例

本文整理汇总了Java中org.elasticsearch.search.SearchHitField.getValues方法的典型用法代码示例。如果您正苦于以下问题:Java SearchHitField.getValues方法的具体用法?Java SearchHitField.getValues怎么用?Java SearchHitField.getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.search.SearchHitField的用法示例。


在下文中一共展示了SearchHitField.getValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScriptFieldsForNullReturn

import org.elasticsearch.search.SearchHitField; //导入方法依赖的package包/类
public void testScriptFieldsForNullReturn() throws Exception {
    client().prepareIndex("test", "type1", "1")
            .setSource("foo", "bar")
            .setRefreshPolicy("true").get();

    SearchResponse response = client().prepareSearch()
            .setQuery(matchAllQuery())
            .addScriptField("test_script_1",
                new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return null", Collections.emptyMap()))
            .get();

    assertNoFailures(response);

    SearchHitField fieldObj = response.getHits().getAt(0).field("test_script_1");
    assertThat(fieldObj, notNullValue());
    List<?> fieldValues = fieldObj.getValues();
    assertThat(fieldValues, hasSize(1));
    assertThat(fieldValues.get(0), nullValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:SearchFieldsIT.java

示例2: buildJSONFromFields

import org.elasticsearch.search.SearchHitField; //导入方法依赖的package包/类
private String buildJSONFromFields(Collection<SearchHitField> values) {
	JsonFactory nodeFactory = new JsonFactory();
	try {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		JsonGenerator generator = nodeFactory.createGenerator(stream, JsonEncoding.UTF8);
		generator.writeStartObject();
		for (SearchHitField value : values) {
			if (value.getValues().size() > 1) {
				generator.writeArrayFieldStart(value.getName());
				for (Object val : value.getValues()) {
					generator.writeObject(val);
				}
				generator.writeEndArray();
			} else {
				generator.writeObjectField(value.getName(), value.getValue());
			}
		}
		generator.writeEndObject();
		generator.flush();
		return new String(stream.toByteArray(), Charset.forName("UTF-8"));
	} catch (IOException e) {
		return null;
	}
}
 
开发者ID:uckefu,项目名称:uckefu,代码行数:25,代码来源:UKResultMapper.java

示例3: buildJSONFromFields

import org.elasticsearch.search.SearchHitField; //导入方法依赖的package包/类
private String buildJSONFromFields(Collection<SearchHitField> values) {
JsonFactory nodeFactory = new JsonFactory();
try {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    JsonGenerator generator = nodeFactory.createGenerator(stream, JsonEncoding.UTF8);
    generator.writeStartObject();
    for (SearchHitField value : values) {
	if (value.getValues().size() > 1) {
	    generator.writeArrayFieldStart(value.getName());
	    for (Object val : value.getValues()) {
		generator.writeObject(val);
	    }
	    generator.writeEndArray();
	} else {
	    generator.writeObjectField(value.getName(), value.getValue());
	}
    }
    generator.writeEndObject();
    generator.flush();
    return new String(stream.toByteArray(), Charset.forName("UTF-8"));
} catch (IOException e) {
    LOG.error("IOException in buildJSONFromFields ", e);
    return null;
}
   }
 
开发者ID:dlcs,项目名称:the-mathmos-server,代码行数:26,代码来源:TextSearchAnnotationMapper.java

示例4: putField

import org.elasticsearch.search.SearchHitField; //导入方法依赖的package包/类
void putField(ObjectNode json, SearchHitField field) {
    String fieldName = field.getName();
    String[] nameParts = fieldName.split("\\.");
    String property = nameParts[nameParts.length - 1];
    ObjectNode obj = json;
    for (int i = 0; i < nameParts.length - 1; ++i) {
        String part = nameParts[i];
        obj = obj.with(part);
    }
    List<Object> values = field.getValues();
    Object value = values.size() > 1 ? values : values.get(0);
    obj.put(property, nodeFactory.pojoNode(value));
}
 
开发者ID:scaleset,项目名称:scaleset-search,代码行数:14,代码来源:AbstractSearchMapping.java


注:本文中的org.elasticsearch.search.SearchHitField.getValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。