• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TermVectorsResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: executeMultiTermVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Override
protected MultiTermVectorsResponse executeMultiTermVectors(MultiTermVectorsRequest mtvRequest) {
    try {
        MultiTermVectorsItemResponse[] responses = new MultiTermVectorsItemResponse[mtvRequest.size()];
        int i = 0;
        for (TermVectorsRequest request : mtvRequest) {
            TermVectorsResponse response = new TermVectorsResponse(request.index(), request.type(), request.id());
            response.setExists(true);
            Fields generatedFields;
            if (request.doc() != null) {
                generatedFields = generateFields(randomFields, request.doc().utf8ToString());
            } else {
                generatedFields = generateFields(request.selectedFields().toArray(new String[request.selectedFields().size()]), request.id());
            }
            EnumSet<TermVectorsRequest.Flag> flags = EnumSet.of(TermVectorsRequest.Flag.Positions, TermVectorsRequest.Flag.Offsets);
            response.setFields(generatedFields, request.selectedFields(), flags, generatedFields);
            responses[i++] = new MultiTermVectorsItemResponse(response, null);
        }
        return new MultiTermVectorsResponse(responses);
    } catch (IOException ex) {
        throw new ElasticsearchException("boom", ex);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:MoreLikeThisQueryBuilderTests.java


示例2: getFieldsFor

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
private static Fields[] getFieldsFor(MultiTermVectorsResponse responses) throws IOException {
    List<Fields> likeFields = new ArrayList<>();

    for (MultiTermVectorsItemResponse response : responses) {
        if (response.isFailed()) {
            continue;
        }
        TermVectorsResponse getResponse = response.getResponse();
        if (!getResponse.isExists()) {
            continue;
        }
        likeFields.add(getResponse.getFields());
    }
    return likeFields.toArray(Fields.EMPTY_ARRAY);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:MoreLikeThisQueryBuilder.java


示例3: testTook

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
public void testTook() throws Exception {
    XContentBuilder mapping = jsonBuilder()
        .startObject()
            .startObject("type1")
                .startObject("properties")
                    .startObject("field")
                        .field("type", "text")
                        .field("term_vector", "with_positions_offsets_payloads")
                    .endObject()
                .endObject()
            .endObject()
        .endObject();
    createIndex("test", Settings.EMPTY, "type1", mapping);
    ensureGreen();

    client().prepareIndex("test", "type1", "0").setSource("field", "foo bar").setRefreshPolicy(IMMEDIATE).get();

    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    IndexService test = indicesService.indexService(resolveIndex("test"));
    IndexShard shard = test.getShardOrNull(0);
    assertThat(shard, notNullValue());

    List<Long> longs = Stream.of(abs(randomLong()), abs(randomLong())).sorted().collect(toList());

    TermVectorsRequest request = new TermVectorsRequest("test", "type1", "0");
    TermVectorsResponse response = TermVectorsService.getTermVectors(shard, request, longs.iterator()::next);

    assertThat(response, notNullValue());
    assertThat(response.getTookInMillis(), equalTo(TimeUnit.NANOSECONDS.toMillis(longs.get(1) - longs.get(0))));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:TermVectorsServiceTests.java


示例4: getFieldsFor

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
public static Fields[] getFieldsFor(MultiTermVectorsResponse responses) throws IOException {
    List<Fields> likeFields = new ArrayList<>();

    for (MultiTermVectorsItemResponse response : responses) {
        if (response.isFailed()) {
            continue;
        }
        TermVectorsResponse getResponse = response.getResponse();
        if (!getResponse.isExists()) {
            continue;
        }
        likeFields.add(getResponse.getFields());
    }
    return likeFields.toArray(Fields.EMPTY_ARRAY);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:MoreLikeThisFetchService.java


示例5: handleRequest

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
    TermVectorsRequest termVectorsRequest = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id"));
    if (RestActions.hasBodyContent(request)) {
        try (XContentParser parser = XContentFactory.xContent(RestActions.guessBodyContentType(request)).createParser(RestActions.getRestContent(request))){
            TermVectorsRequest.parseRequest(termVectorsRequest, parser);
        }
    }
    readURIParameters(termVectorsRequest, request);

    client.termVectors(termVectorsRequest, new RestToXContentListener<TermVectorsResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:RestTermVectorsAction.java


示例6: writeStandardTermVector

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
private void writeStandardTermVector(TermVectorsResponse outResponse) throws IOException {

        Directory dir = LuceneTestCase.newDirectory();
        IndexWriterConfig conf = new IndexWriterConfig(new StandardAnalyzer());

        conf.setOpenMode(OpenMode.CREATE);
        IndexWriter writer = new IndexWriter(dir, conf);
        FieldType type = new FieldType(TextField.TYPE_STORED);
        type.setStoreTermVectorOffsets(true);
        type.setStoreTermVectorPayloads(false);
        type.setStoreTermVectorPositions(true);
        type.setStoreTermVectors(true);
        type.freeze();
        Document d = new Document();
        d.add(new Field("id", "abc", StringField.TYPE_STORED));
        d.add(new Field("plaintext", "the1 quick brown fox jumps over  the1 lazy dog comment", type));
        d.add(new Field("desc", "the1 quick brown fox jumps over  the1 lazy dog comment", type));

        writer.updateDocument(new Term("id", "abc"), d);
        writer.commit();
        writer.close();
        DirectoryReader dr = DirectoryReader.open(dir);
        IndexSearcher s = new IndexSearcher(dr);
        TopDocs search = s.search(new TermQuery(new Term("id", "abc")), 1);
        ScoreDoc[] scoreDocs = search.scoreDocs;
        int doc = scoreDocs[0].doc;
        Fields termVectors = dr.getTermVectors(doc);
        EnumSet<Flag> flags = EnumSet.of(Flag.Positions, Flag.Offsets);
        outResponse.setFields(termVectors, null, flags, termVectors);
        dr.close();
        dir.close();

    }
 
开发者ID:dlcs,项目名称:the-mathmos-server,代码行数:34,代码来源:TextSearchServiceImplTest.java


示例7: getTermVectorWithException

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
private Map<Integer,String> getTermVectorWithException(String field, String id) throws IOException {
    TermVectorsResponse response = client.prepareTermVector(indexName, documentType, id)
            .setOffsets(false).setPositions(true).setFieldStatistics(false)
            .setTermStatistics(false)
            .setSelectedFields(field).
                    execute().actionGet();

    Map<Integer,String> map = new HashMap<>();
    Terms terms = response.getFields().terms(field);
    if (terms==null){
        return map;
    }
    TermsEnum iterator = terms.iterator();
    PostingsEnum postings = null;
    
    for (BytesRef termBytes = null; (termBytes = iterator.next()) != null; ) {
    	String term = termBytes.utf8ToString();
    	
    	postings = iterator.postings(postings, PostingsEnum.ALL);
    	
    	//there can only be one doc since we are getting with id. get the doc and the position 
    	postings.nextDoc();
    	
    	int tf = postings.freq();
    	
    	for (int i = 0; i < tf; i++) {
    		int pos = postings.nextPosition();
            map.put(pos,term);
    	}
    	
    }
    
    return map;
}
 
开发者ID:cheng-li,项目名称:pyramid,代码行数:35,代码来源:ESIndex.java


示例8: getTermVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
public static TermVectorsResponse getTermVectors(IndexShard indexShard, TermVectorsRequest request) {
    return getTermVectors(indexShard, request, System::nanoTime);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:TermVectorsService.java


示例9: termVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Override
public ActionFuture<TermVectorsResponse> termVectors(final TermVectorsRequest request) {
    return execute(TermVectorsAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例10: termVector

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Deprecated
@Override
public ActionFuture<TermVectorsResponse> termVector(final TermVectorsRequest request) {
    return termVectors(request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:AbstractClient.java


示例11: termVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Override
public ActionFuture<TermVectorsResponse> termVectors(TermVectorsRequest request) {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:winterstein,项目名称:elasticsearch-java-client,代码行数:6,代码来源:DummyClient.java


示例12: termVector

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
@Override
public ActionFuture<TermVectorsResponse> termVector(TermVectorsRequest request) {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:winterstein,项目名称:elasticsearch-java-client,代码行数:6,代码来源:DummyClient.java


示例13: exists

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
private boolean exists(TermVectorsResponse termVectorsResponse, GetResult getResult) {
    return ((termVectorsResponse != null && termVectorsResponse.isExists()) ||
            (getResult != null && getResult.isExists()));
}
 
开发者ID:alexksikes,项目名称:elasticsearch-vectorize,代码行数:5,代码来源:VectorizeService.java


示例14: getTermVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
private TermVectorsResponse getTermVectors(VectorizeRequest request) {
    // TODO: there is no need to actually to embed a term vector request
    return indexShard.termVectorsService().getTermVectors(request.getTermVectorsRequest(), indexShard.shardId().getIndex());
}
 
开发者ID:alexksikes,项目名称:elasticsearch-vectorize,代码行数:5,代码来源:VectorizeService.java


示例15: termVectors

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
/**
 * An action that returns the term vectors for a specific document.
 *
 * @param request The term vector request
 * @return The response future
 */
ActionFuture<TermVectorsResponse> termVectors(TermVectorsRequest request);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:Client.java


示例16: termVector

import org.elasticsearch.action.termvectors.TermVectorsResponse; //导入依赖的package包/类
/**
 * An action that returns the term vectors for a specific document.
 *
 * @param request The term vector request
 * @return The response future
 */
@Deprecated
ActionFuture<TermVectorsResponse> termVector(TermVectorsRequest request);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Client.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Iso4217CurrencyCode类代码示例发布时间:2022-05-23
下一篇:
Java SimplePagedTabsHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap