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


Java GetField类代码示例

本文整理汇总了Java中org.elasticsearch.index.get.GetField的典型用法代码示例。如果您正苦于以下问题:Java GetField类的具体用法?Java GetField怎么用?Java GetField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDocument

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
/**
 * This method get the matched document
 */
@Override
public void getDocument() {
    try {
        client = ESclient.getInstant();
        GetResponse response = client.prepareGet("school", "tytenthpe", "1")
                .setOperationThreaded(false)
                .get();
        if (response != null) {
            Map<String, GetField> FieldsMap = response.getFields();
            log.info("Response Data : " + FieldsMap.toString());
        }
    } catch (Exception ex) {
        log.error("Exception occurred while get Document : " + ex, ex);
    }
}
 
开发者ID:sundarcse1216,项目名称:es-crud,代码行数:19,代码来源:ElasticSearchCrudImpl.java

示例2: generateTermVectors

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
private Fields generateTermVectors(Collection<GetField> getFields, boolean withOffsets, @Nullable Map<String, String> perFieldAnalyzer, Set<String> fields)
        throws IOException {
    /* store document in memory index */
    MemoryIndex index = new MemoryIndex(withOffsets);
    for (GetField getField : getFields) {
        String field = getField.getName();
        if (fields.contains(field) == false) {
            // some fields are returned even when not asked for, eg. _timestamp
            continue;
        }
        Analyzer analyzer = getAnalyzerAtField(field, perFieldAnalyzer);
        for (Object text : getField.getValues()) {
            index.addField(field, text.toString(), analyzer);
        }
    }
    /* and read vectors from it */
    return MultiFields.getFields(index.createSearcher().getIndexReader());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:ShardTermVectorsService.java

示例3: get

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@Override
public String get(String workflowInstanceId, String fieldToGet) {
	Object value = null;
	GetRequest request = new GetRequest(indexName, WORKFLOW_DOC_TYPE, workflowInstanceId).storedFields(fieldToGet);
	GetResponse response = client.get(request).actionGet();
	Map<String, GetField> fields = response.getFields();
	if(fields == null) {
		return null;
	}
	GetField field = fields.get(fieldToGet);		
	if(field != null) value = field.getValue();
	if(value != null) {
		return value.toString();
	}
	return null;
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:17,代码来源:ElasticSearchDAO.java

示例4: getResultToMapOfGetFields

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
private static Map<String, GetField> getResultToMapOfGetFields(@Nullable Map<String, Object> fieldsAsMap) {
    if (fieldsAsMap == null) {
        return ImmutableMap.of();
    }
    Map<String, GetField> result = new HashMap<>();
    for (Map.Entry<String, Object> entry : fieldsAsMap.entrySet()) {
        String name = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof List) {
            result.put(name, new GetField(name, (List<Object>) value));
        } else {
            result.put(name, new GetField(name, Collections.singletonList(value)));
        }
    }
    return result;
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:17,代码来源:ResponseWrapper.java

示例5: test_get

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
private void test_get(final Client client, final String index,
        final String type, final String id, final byte[] hash1,
        final byte[] hash2, final byte[] hash3) {
    final GetResponse response = client
            .prepareGet(index, type, id)
            .setFields("_source", "minhash_value1", "minhash_value2",
                    "minhash_value3").execute().actionGet();
    assertTrue(response.isExists());
    final Map<String, Object> source = response.getSourceAsMap();
    assertEquals("test " + Integer.parseInt(id) % 100, source.get("msg"));

    final GetField field1 = response.getField("minhash_value1");
    final BytesArray value1 = (BytesArray) field1.getValue();
    assertEquals(hash1.length, value1.length());
    Assert.assertArrayEquals(hash1, value1.array());

    final GetField field2 = response.getField("minhash_value2");
    final BytesArray value2 = (BytesArray) field2.getValue();
    assertEquals(hash2.length, value2.length());
    Assert.assertArrayEquals(hash2, value2.array());

    final GetField field3 = response.getField("minhash_value3");
    final BytesArray value3 = (BytesArray) field3.getValue();
    assertEquals(hash3.length, value3.length());
    Assert.assertArrayEquals(hash3, value3.array());
}
 
开发者ID:sherlok,项目名称:sherlastic,代码行数:27,代码来源:SherlokPluginTest.java

示例6: getListFieldValueOrNull

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected List<String> getListFieldValueOrNull(GetField field)
{
    if(field !=null)
    {
        final List<String> list = new ArrayList<String>();
        for (final Object object : field.getValues())
        {
            if(object instanceof List)
            {
                for (final String valueString : (List<String>)object)
                {
                    list.add(String.valueOf(valueString));
                }
            }
            else
            {
                list.add(String.valueOf(object));
            }
        }
        return list;
    }
    return null;
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:25,代码来源:ProductQueryServiceImpl.java

示例7: getListFieldValueOrNull

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected List<String> getListFieldValueOrNull(final GetField field)
{
    if (field != null)
    {
        final List<String> list = new ArrayList<String>();
        for (final Object object : field.getValues())
        {
            if (object instanceof List)
            {
                for (final String valueString : (List<String>) object)
                {
                    list.add(String.valueOf(valueString));
                }
            }
            else
            {
                list.add(String.valueOf(object));
            }
        }
        return list;
    }
    return null;
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-akka,代码行数:25,代码来源:ProductQueryServiceImpl.java

示例8: getListFieldValueOrNull

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected List<String> getListFieldValueOrNull(final GetField field) {
	if (field != null) {
		final List<String> list = new ArrayList<String>();
		for (final Object object : field.getValues()) {
			if (object instanceof List) {
				for (final String valueString : (List<String>) object) {
					list.add(String.valueOf(valueString));
				}
			} else {
				list.add(String.valueOf(object));
			}
		}
		return list;
	}
	return null;
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:18,代码来源:ProductQueryServiceImpl.java

示例9: testToString

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
public void testToString() {
    GetResponse getResponse = new GetResponse(
            new GetResult("index", "type", "id", 1, true, new BytesArray("{ \"field1\" : " + "\"value1\", \"field2\":\"value2\"}"),
                    Collections.singletonMap("field1", new GetField("field1", Collections.singletonList("value1")))));
    assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"found\":true,\"_source\":{ \"field1\" "
            + ": \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", getResponse.toString());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:GetResponseTests.java

示例10: build

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
public GetResult build() {
    // Check for .kibana.* in the source
    BytesReference replacedContent = null;
    if (response != null && !response.isSourceEmpty() && replacedIndex != null && index != null) {
        String source = response.getSourceAsBytesRef().toUtf8();
        String replaced = source.replaceAll(replacedIndex, index);
        replacedContent = new BytesArray(replaced);
    }
    // Check for .kibana.* in the fields
    for (String key : responseFields.keySet()) {

        GetField replacedField = responseFields.get(key);

        for (Object o : replacedField.getValues()) {
            if (o instanceof String) {
                String value = (String) o;

                if (value.contains(replacedIndex)) {
                    replacedField.getValues().remove(o);
                    replacedField.getValues().add(value.replaceAll(replacedIndex, index));
                }
            }
        }

    }
    GetResult result = new GetResult(index, type, id, version, exists, replacedContent, responseFields);
    LOG.debug("Built GetResult: {}", result);
    return result;
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:30,代码来源:GetResultBuilder.java

示例11: testBuildWhenResponseFieldsAreNotNull

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@Test
public void testBuildWhenResponseFieldsAreNotNull() {
    Object [] values = new String [] {"bar"};
    GetField field = new GetField("aField", new ArrayList<Object>(Arrays.asList(values)));
    Map<String, GetField> fields = new HashMap<>();
    fields.put("aField", field);
    when(response.getFields()).thenReturn(fields );
    when(response.isSourceEmpty()).thenReturn(true);
    givenAnInitializedBuilder();

    GetResult result = builder.build();
    assertNotNull(result);
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:14,代码来源:GetResultBuilderTest.java

示例12: fields

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
public static Map<String, GetField> fields(XContentParser parser) {
    try {
        Map<String, Object> map = parser.mapOrdered();
        return toGetFieldMap(map);
    } catch (IOException e) {
        throw new RuntimeException("Unable to parse source", e);
    }
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:9,代码来源:FieldsParser.java

示例13: toGetFieldMap

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
private static Map<String, GetField> toGetFieldMap(@Nullable Map<String, Object> fieldsAsMap) {
    if (fieldsAsMap == null) {
        return ImmutableMap.of();
    }
    Map<String, GetField> result = new HashMap<>();
    for (Map.Entry<String, Object> entry : fieldsAsMap.entrySet()) {
        String name = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof List) {
            result.put(name, new GetField(name, (List<Object>) value));
        } else {
            result.put(name, new GetField(name, Collections.singletonList(value)));
        }
    }
    return result;
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:17,代码来源:FieldsParser.java

示例14: getProduct

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Product getProduct(ElasticSearchIndexConfig config, Long productId)
{
    GetResponse getResponse = searchClientService.getClient().prepareGet(config.getIndexAliasName(), config.getDocumentType(), String.valueOf(productId))
                                                             .setFields(SearchDocumentFieldName.productDocumentFields)
                                                             .get();
    if(getResponse.isExists())
    {
        Product product = new Product();
        product.setId(Long.valueOf(getResponse.getId()));
        product.setTitle(getResponse.getField(SearchDocumentFieldName.TITLE.getFieldName()).getValue().toString());
        product.setDescription(getResponse.getField(SearchDocumentFieldName.DESCRIPTION.getFieldName()).getValue().toString());
        product.setSoldOut(Boolean.valueOf(getResponse.getField(SearchDocumentFieldName.SOLD_OUT.getFieldName()).getValue().toString()));
        product.setAvailableOn(SearchDateUtils.getFormattedDate(getResponse.getField(SearchDocumentFieldName.AVAILABLE_DATE.getFieldName()).getValue().toString()));
        product.setKeywords(getListFieldValueOrNull(getResponse.getField(SearchDocumentFieldName.KEYWORDS.getFieldName())));
        product.setPrice(BigDecimal.valueOf(Double.valueOf(getResponse.getField(SearchDocumentFieldName.PRICE.getFieldName()).getValue().toString())));
        product.setBoostFactor(Float.valueOf(getResponse.getField(SearchDocumentFieldName.BOOSTFACTOR.getFieldName()).getValue().toString()));
        GetField catField = getResponse.getField(SearchDocumentFieldName.CATEGORIES_ARRAY.getFieldName());
        if(catField !=null)
        {
            for (Object ListOfMapValues : catField.getValues())
            {
                for (final java.util.Map.Entry<String, String> entry : ((Map<String, String>)ListOfMapValues).entrySet())
                {
                    //Only main facet values should be set.key ending with a number.
                    if(entry.getKey().matches("^.*.facet$"))
                    {
                        product.addCategory(new Category(entry.getValue(), null, entry.getKey().split("\\.facet")[0]));
                    }
                }
            }
        }
        
        return product;
    }
    return null;
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:39,代码来源:ProductQueryServiceImpl.java

示例15: getStringFieldValue

import org.elasticsearch.index.get.GetField; //导入依赖的package包/类
protected String getStringFieldValue(GetField field)
{
    if(field !=null)
    {
        return String.valueOf(field.getValue());
    }
    return null;
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:9,代码来源:ProductQueryServiceImpl.java


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