elasticsearch源码分析-07GET查询流程

Elasticsearch使用篇 - Get查询与Search查询 本文介绍Elasticsearch的Get查询与Search查询。 阅读详情

GET查询流程

ES的读取分为Get和search两种,get是根据id从索引中获取内容,而search是根据关键词从倒排索引中获取内容

get请求的处理在actionModule中进行注册

//get请求处理
registerHandler.accept(new RestGetAction());

请求的路由为

public List<Route> routes() {
    return unmodifiableList(asList(
        new Route(GET, "/{index}/_doc/{id}"),
        new Route(HEAD, "/{index}/_doc/{id}"),
        // Deprecated typed endpoints.
        new Route(GET, "/{index}/{type}/{id}"),
        new Route(HEAD, "/{index}/{type}/{id}")));
}

当节点接收到rest请求后会分发到不同的handler进行处理

void dispatchRequest(final RestRequest restRequest, final RestChannel channel, final Throwable badRequestCause) {
    final ThreadContext threadContext = threadPool.getThreadContext();
    try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
        //错误请求处理
        if (badRequestCause != null) {
            dispatcher.dispatchBadRequest(channel, threadContext, badRequestCause);
        } else {
            //正常请求处理
            dispatcher.dispatchRequest(restRequest, channel, threadContext);
        }
    }
}

public void dispatchRequest(RestRequest request, RestChannel channel, ThreadContext threadContext) {
    //小图标请求处理
    if (request.rawPath().equals("/favicon.ico")) {
        handleFavicon(request.method(), request.uri(), channel);
        return;
    }
    try {
        //处理rest请求
        tryAllHandlers(request, channel, threadContext);
    } catch (Exception e) {
        try {
            channel.sendResponse(new BytesRestResponse(channel, e));
        } catch (Exception inner) {
            inner.addSuppressed(e);
            logger.error(() ->
                         new ParameterizedMessage("failed to send failure response for uri [{}]", request.uri()), inner);
        }
    }
}

最终执行到BaseRestHandler的handleRequest方法

@Override
    public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
        // prepare the request for execution; has the side effect of touching the request parameters
        //处理请求
        final RestChannelConsumer action = prepareRequest(request, client);

        // validate unconsumed params, but we must exclude params used to format the response
        // use a sorted set so the unconsumed parameters appear in a reliable sorted order
        final SortedSet<String> unconsumedParams =
            request.unconsumedParams().stream().filter(p -> !responseParams().contains(p)).collect(Collectors.toCollection(TreeSet::new));

        // validate the non-response params
        if (!unconsumedParams.isEmpty()) {
            final Set<String> candidateParams = new HashSet<>();
            candidateParams.addAll(request.consumedParams());
            candidateParams.addAll(responseParams());
            throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter"));
        }

        if (request.hasContent() && request.isContentConsumed() == false) {
            throw new IllegalArgumentException("request [" + request.method() + " " + request.path() + "] does not support having a body");
        }

        usageCount.increment();
        // execute the action
        action.accept(channel);
    }

调用prepareRequest将请求参数封装近request中

@Override
    public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
        GetRequest getRequest;
        //处理type类型默认_doc
        if (request.hasParam("type")) {
            deprecationLogger.deprecatedAndMaybeLog("get_with_types", TYPES_DEPRECATION_MESSAGE);
            getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id"));
        } else {
            getRequest = new GetRequest(request.param("index"), request.param("id"));
        }
        //是否设置查询前需要执行refresh
        getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh()));
        //是否外部指定了路由
        getRequest.routing(request.param("routing"));
        //可以指定从主分片获取或者从本地获取,默认是从多个分片中随机选择一个
        getRequest.preference(request.param("preference"));
        //是否是实时查询,也就是不受refresh影响,如果查询时候文档已经更新但是没有执行refresh,那么会首先执行一次refresh,使文档可见
        getRequest.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
        //校验
        if (request.param("fields") != null) {
            throw new IllegalArgumentException("the parameter [fields] is no longer supported, " +
                "please use [stored_fields] to retrieve stored fields or [_source] to load the field from _source");
        }
        //mapping中store设置为true的字段,这里指定返回字段
        final String fieldsParam = request.param("stored_fields");
        if (fieldsParam != null) {
            final String[] fields = Strings.splitStringByCommaToArray(fieldsParam);
            if (fields != null) {
                getRequest.storedFields(fields);
            }
        }
        //指定查询版本号
        getRequest.version(RestActions.parseVersion(request));
        //版本号类型是内部还是外部
        getRequest.versionType(VersionType.fromString(request.param("version_type"), getRequest.versionType()));
        //指定查询_source
        getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));

        return channel -> client.get(getRequest, new RestToXContentListener<GetResponse>(channel) {
            @Override
            protected RestStatus getStatus(final GetResponse response) {
                return response.isExists() ? OK : NOT_FOUND;
            }
        });
    }

调用doExecute方法

public <    Request extends ActionRequest,
                Response extends ActionResponse
            > Task executeLocally(ActionType<Response> action, Request request, ActionListener<Response> listener) {
        //获取transportAction开始执行
        return transportAction(action).execute(request, listener);
    }

获取action执行,这里action的注册在actionModule中

//get查询处理
actions.register(GetAction.INSTANCE, TransportGetAction.class);

而TransportGetAction继承了TransportSingleShardAction最终调用它的doExecute方法

@Override
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
    new AsyncSingleAction(request, listener).start();
}

private AsyncSingleAction(Request request, ActionListener<Response> listener) {
            this.listener = listener;

            ClusterState clusterState = clusterService.state();
            if (logger.isTraceEnabled()) {
                logger.trace("executing [{}] based on cluster state version [{}]", request, clusterState.version());
            }
            nodes = clusterState.nodes();
            ClusterBlockException blockException = checkGlobalBlock(clusterState);
            if (blockException != null) {
                throw blockException;
            }

            String concreteSingleIndex;
            //解析索引
            if (resolveIndex(request)) {
                concreteSingleIndex = indexNameExpressionResolver.concreteSingleIndex(clusterState, request).getName();
            } else {
                concreteSingleIndex = request.index();
            }
            this.internalRequest = new InternalRequest(request, concreteSingleIndex);
            //解析请求
            resolveRequest(clusterState, internalRequest);

            blockException = checkRequestBlock(clusterState, internalRequest);
            if (blockException != null) {
                throw blockException;
            }
            //查询分片如果没有指定就随机选择分片,如果是本地则为null
            this.shardIt = shards(clusterState, internalRequest);
        }

构建AsyncSingleAction调用start方法

public void start() {
            if (shardIt == null) {
                //本地执行
                // just execute it on the local node
                final Writeable.Reader<Response> reader = getResponseReader();
                transportService.sendRequest(clusterService.localNode(), transportShardAction, internalRequest.request(),
                    new TransportResponseHandler<Response>() {
                    @Override
                    public Response read(StreamInput in) throws IOException {
                        return reader.read(in);
                    }

                    @Override
                    public String executor() {
                        return ThreadPool.Names.SAME;
                    }

                    @Override
                    public void handleResponse(final Response response) {
                        listener.onResponse(response);
                    }

                    @Override
                    public void handleException(TransportException exp) {
                        listener.onFailure(exp);
                    }
                });
            } else {
                perform(null);
            }
        }

如果随机分片是本地执行调用sendRequest方法

public <T extends TransportResponse> void sendRequest(final DiscoveryNode node, final String action,
                                                                final TransportRequest request,
                                                                final TransportResponseHandler<T> handler) {
        final Transport.Connection connection;
        try {
            //获取连接分为本地和远程
            connection = getConnection(node);
        } catch (final NodeNotConnectedException ex) {
            // the caller might not handle this so we invoke the handler
            handler.handleException(ex);
            return;
        }
        sendRequest(connection, action, request, TransportRequestOptions.EMPTY, handler);
    }

public Transport.Connection getConnection(DiscoveryNode node) {
        //本地节点
        if (isLocalNode(node)) {
            return localNodeConnection;
        } else {
            return connectionManager.getConnection(node);
        }
    }

首先获取连接,连接分为本地和远程

  • 本地执行
@Override
public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options)
    throws TransportException {
    sendLocalRequest(requestId, action, request, options);
}

获取线程池然后执行,最终都会调用processMessageReceived方法

reg.processMessageReceived(request, channel);

public void processMessageReceived(Request request, TransportChannel channel) throws Exception {
    //注册没有父任务的任务
    final Task task = taskManager.register(channel.getChannelType(), action, request);
    boolean success = false;
    try {
        handler.messageReceived(request, new TaskTransportChannel(taskManager, task, channel), task);
        success = true;
    } finally {
        if (success == false) {
            taskManager.unregister(task);
        }
    }
}

这里的handler在创建TransportSingleShardAction中

//注册请求的处理器
        transportService.registerRequestHandler(transportShardAction, ThreadPool.Names.SAME, request, new ShardTransportHandler());

protected void asyncShardOperation(Request request, ShardId shardId, ActionListener<Response> listener) throws IOException {
        threadPool.executor(getExecutor(request, shardId))
            .execute(ActionRunnable.supply(listener, () -> shardOperation(request, shardId)));
    }

继续调用TransportGetAction的shardOperation方法

@Override
protected GetResponse shardOperation(GetRequest request, ShardId shardId) {
    IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
    IndexShard indexShard = indexService.getShard(shardId.id());

    if (request.refresh() && !request.realtime()) {
        indexShard.refresh("refresh_flag_get");
    }
    //调用get查询
    GetResult result = indexShard.getService().get(request.type(), request.id(), request.storedFields(),
                                                   request.realtime(), request.version(), request.versionType(), request.fetchSourceContext());
    return new GetResponse(result);
}

最终调用innerGet方法

private GetResult get(String type, String id, String[] gFields, boolean realtime, long version, VersionType versionType,
                          long ifSeqNo, long ifPrimaryTerm, FetchSourceContext fetchSourceContext) {
        currentMetric.inc();
        try {
            long now = System.nanoTime();
            GetResult getResult =
                //查询
                innerGet(type, id, gFields, realtime, version, versionType, ifSeqNo, ifPrimaryTerm, fetchSourceContext);

            if (getResult.isExists()) {
                existsMetric.inc(System.nanoTime() - now);
            } else {
                missingMetric.inc(System.nanoTime() - now);
            }
            return getResult;
        } finally {
            currentMetric.dec();
        }
    }

调用engine读取数据信息

public GetResult get(Get get, BiFunction<String, SearcherScope, Engine.Searcher> searcherFactory) throws EngineException {
        assert Objects.equals(get.uid().field(), IdFieldMapper.NAME) : get.uid().field();
        try (ReleasableLock ignored = readLock.acquire()) {
            ensureOpen();
            SearcherScope scope;
            //处理实时查询
            if (get.realtime()) {
                VersionValue versionValue = null;
                try (Releasable ignore = versionMap.acquireLock(get.uid().bytes())) {
                    // we need to lock here to access the version map to do this truly in RT
                    versionValue = getVersionFromMap(get.uid().bytes());
                }
                //处理查询时候指定的版本号
                if (versionValue != null) {
                    if (versionValue.isDelete()) {
                        return GetResult.NOT_EXISTS;
                    }
                    if (get.versionType().isVersionConflictForReads(versionValue.version, get.version())) {
                        throw new VersionConflictEngineException(shardId, get.id(),
                            get.versionType().explainConflictForReads(versionValue.version, get.version()));
                    }
                    if (get.getIfSeqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO && (
                        get.getIfSeqNo() != versionValue.seqNo || get.getIfPrimaryTerm() != versionValue.term
                        )) {
                        throw new VersionConflictEngineException(shardId, get.id(),
                            get.getIfSeqNo(), get.getIfPrimaryTerm(), versionValue.seqNo, versionValue.term);
                    }
                    if (get.isReadFromTranslog()) {
                        // this is only used for updates - API _GET calls will always read form a reader for consistency
                        // the update call doesn't need the consistency since it's source only + _parent but parent can go away in 7.0
                        if (versionValue.getLocation() != null) {
                            try {
                                Translog.Operation operation = translog.readOperation(versionValue.getLocation());
                                if (operation != null) {
                                    // in the case of a already pruned translog generation we might get null here - yet very unlikely
                                    final Translog.Index index = (Translog.Index) operation;
                                    TranslogLeafReader reader = new TranslogLeafReader(index);
                                    return new GetResult(new Engine.Searcher("realtime_get", reader,
                                        IndexSearcher.getDefaultSimilarity(), null, IndexSearcher.getDefaultQueryCachingPolicy(), reader),
                                        new VersionsAndSeqNoResolver.DocIdAndVersion(0, index.version(), index.seqNo(), index.primaryTerm(),
                                            reader, 0), true);
                                }
                            } catch (IOException e) {
                                maybeFailEngine("realtime_get", e); // lets check if the translog has failed with a tragic event
                                throw new EngineException(shardId, "failed to read operation from translog", e);
                            }
                        } else {
                            trackTranslogLocation.set(true);
                        }
                    }
                    assert versionValue.seqNo >= 0 : versionValue;
                    refreshIfNeeded("realtime_get", versionValue.seqNo);
                }
                //内部
                scope = SearcherScope.INTERNAL;
            } else {
                // we expose what has been externally expose in a point in time snapshot via an explicit refresh
                //外部
                scope = SearcherScope.EXTERNAL;
            }

            // no version, get the version from the index, we know that we refresh on flush
            //调用searcher读取数据
            return getFromSearcher(get, searcherFactory, scope);
        }
    }

根据查询信息读取lucene数据

//根据上面getResult的信息获取数据
            return innerGetLoadFromStoredFields(type, id, gFields, fetchSourceContext, get, mapperService);

最后将查询到的数据返回

  • 分片为非本地分片
//远端
perform(null);

private void perform(@Nullable final Exception currentFailure) {
            Exception lastFailure = this.lastFailure;
            if (lastFailure == null || TransportActions.isReadOverrideException(currentFailure)) {
                lastFailure = currentFailure;
                this.lastFailure = currentFailure;
            }
            //路由信息
            final ShardRouting shardRouting = shardIt.nextOrNull();
            if (shardRouting == null) {
                Exception failure = lastFailure;
                if (failure == null || isShardNotAvailableException(failure)) {
                    failure = new NoShardAvailableActionException(null,
                        LoggerMessageFormat.format("No shard available for [{}]", internalRequest.request()), failure);
                } else {
                    logger.debug(() -> new ParameterizedMessage("{}: failed to execute [{}]", null,
                        internalRequest.request()), failure);
                }
                listener.onFailure(failure);
                return;
            }
            //node节点
            DiscoveryNode node = nodes.get(shardRouting.currentNodeId());
            if (node == null) {
                onFailure(shardRouting, new NoShardAvailableActionException(shardRouting.shardId()));
            } else {
                internalRequest.request().internalShardId = shardRouting.shardId();
                if (logger.isTraceEnabled()) {
                    logger.trace(
                            "sending request [{}] to shard [{}] on node [{}]",
                            internalRequest.request(),
                            internalRequest.request().internalShardId,
                            node
                    );
                }
                final Writeable.Reader<Response> reader = getResponseReader();
                transportService.sendRequest(node, transportShardAction, internalRequest.request(),
                    new TransportResponseHandler<Response>() {

                        @Override
                        public Response read(StreamInput in) throws IOException {
                            return reader.read(in);
                        }

                        @Override
                        public String executor() {
                            return ThreadPool.Names.SAME;
                        }

                        @Override
                        public void handleResponse(final Response response) {
                            listener.onResponse(response);
                        }

                        @Override
                        public void handleException(TransportException exp) {
                            onFailure(shardRouting, exp);
                        }
                });
            }
        }
    }

就是将请求转发到其他节点执行,处理逻辑和上面的逻辑一致,其他节点执行后会把数据返回,然后节点把数据返回给用户请求

Elasticsearch搜索流程解析 文章目录背景协调节点流程Query阶段Fetch阶段数据节点流程响应Query请求响应Fetch请求 背景 ES的读取分为GET和Search两种操作,这两种读取操作有较大的差异,GET/MGET必须指定三元组:_index、_type、_id。也就是说,根据文档id从正排索引中获取内容。而Search不指定_id,根据关键词从倒排索引中获取内容。 可接收客户端请求的节点称为协调节点。在协调节点,搜索任务被执行成一个两阶段过程,即query then fetch。真正执行搜索任务的节点称为数据节点。当搜索任 阅读详情

相关推荐

【Elasticsearch源码】查询源码分析(一)

1 前言 前言分析过ES的写入流程源码,详情见【Elasticsearch源码】写入源码分析。 Elasticsearch(ES)的查询接口具有分布式的数据检索、聚合分析能力,数据检索能力用于支持全文检索、日志分析等场景,如Github平台上的代码搜索、基于ES的各类日志分析服务等;聚合分析能力用于支持指标分析、APM等场景,如监控场景、应用的日活/留存分析等。 本文基于6.7.1版本,主要分...

wudingmei1023 1万+

es的语法操作命令

es的操作命令

qq_19891197的博客 2937

ElasticSearch 源码分析七 ES读取索引 Get操作

GET或者MGET,必须指定三元组 _index, _type,_id , 是根据_id从正排索引中获取内容。而search不指定_id, 根据关键词从倒排索引中获取内容。 程序入口TransportSingleShardAction的doExecute方法 可以看到是调用异步AsyncSingleAction 先看下异步action的构造函数 1.获取当前es的集群状态c...

郭传志的博客 1503

测试用到的es查询语法这一篇就够~

最近测的项目数据流是先缓存到MQ,可通过es查询,以下是es查询语法做的笔记。

weixin_44857268的博客 3831

【Elasticsearch源码】查询源码分析(二)

接上一篇:【Elasticsearch源码】查询源码分析(一)。 上篇讲到请求通过遍历每个shard发送请求,执行executePhaseOnShard方法,转发请求的同时定义了一个Listener,用于监听处理结果。 private void performPhaseOnShard(final int shardIndex, final SearchShardIterator sha...

wudingmei1023 9919

ElasticSearch 源码分析十 ES搜索实现 Search(三)

fetch阶段的步骤 :通过文档id获取完整的文档内容 (1)首先对query结果进行排序,获取要fetch的doc id (2)按shard把这些id填充到docIdsToLoad对象中 (3)按shard去elasticsearch获取文档详情,因为此时已经有了文档的id,所以就发送GET请求获取 (4)将第一步中已经排好序的文档与fetch到的结果按照顺序合并 (5)如果请求中有scr...

郭传志的博客 865

Es初步检索命令

Es初步检索命令大全一步到位

一个菜鸡的博客 3639

Selenium实战:突破反爬,自动化抓取国家知识产权局专利数据

网络爬虫是数据采集的核心技术,其原理是通过程序模拟浏览器行为,自动访问网页并提取结构化信息。在数据驱动决策的今天,高效获取公开数据对市场分析、技术调研和竞争情报至关重要。然而,面对广泛应用的JavaScript动态渲染和反爬虫机制,传统的静态页面抓取方法往往失效。Selenium作为浏览器自动化工具,通过驱动真实浏览器执行JavaScript,能够有效绕过前端反爬,实现“可见即可得”的数据抓取,在需要与页面进行复杂交互或处理动态内容的场景中价值显著。本文以【专利数据】抓取为例,结合【Selenium】工具,

weixin_33881140的博客 392

Elasticsearch GET请求流程源码分析

首先看一下一个GET请求是什么样的(参考官网): GET twitter/_doc/0 { "_index" : "twitter", "_type" : "_doc", "_id" : "0", "_version" : 1, "_seq_no" : 10, "_primary_term" : 1, "found": true, "_source" : { "user" : "kimchy", "date"

FFFro的博客 1130

[EDA系列]二、Altium Designer异形封装实战:从CAD导入到PCB布局

本文详细介绍了在Altium Designer中实现异形封装的实战流程。通过五步核心操作,将CAD软件中的复杂二维轮廓精准导入并转换为可直接用于PCB布局的智能封装,解决了不规则形状铺铜的难题,特别适用于射频天线、传感器外壳等对机械尺寸有严苛要求的设计场景。

weixin_29194817的博客 142

论文阅读笔记(一)细粒度图像检索

0、参考文献 [1]见微知著 http://geek.youkuaiyun.com/news/detail/191718 [2]Xiu-Shen Wei 《Selective Convolutional Descriptor Aggregation for Fine-Grained Image Retrieval》 [3]Lingxi Xie 《Fine-Grained Image Search》 1...

huang2818138的博客 1万+

elasticsearch源码分析-08Serch查询流程

这里可以看到首先会执行lucene的查询,然后对查询结果进行打分、执行聚合逻辑,然后生成SearchPhaseResult返回。和Get查询一样,请求会经过转发dispatchRequest,查询路由对应的handler处理类,然后执行处理。数据节点查询数据后返回协调节点,我们继续回到executePhaseOnShard方法执行回调。search操作会发送请求到索引下的所有分片,相同分片只会发送到主分片或副本分片。这里收集本集群和跨集群及其他集群需要查询的索引,这里我们主要是分析本集群搜索。

GeekerJava的博客 756

《网络安全自学教程》- Nmap使用及扫描原理分析

使用Nmap进行端口扫描、主机发现、服务识别、操作系统识别、指定脚本、结果导出文件,使用wireshark抓包分析扫描原理。

wangyuxiang946的博客 1万+

Elasticsearch(ES)简介

Elasticsearch(ES)简介

weixin_42267411的博客 1135

【OpenClaw从入门到精通】第15篇:国产芯片适配实战——昇腾/龙芯/天数智芯全流程跑通(2026实测版)

2026年国产芯片AI适配迎来爆发期,OpenClaw作为轻量化本地AI智能体,已实现华为昇腾、龙芯、天数智芯等主流国产平台的全流程适配。本文基于实测数据,从背景解析、核心原理、算法优化、实操部署四个维度,详细讲解OpenClaw在香橙派昇腾开发板、龙芯3B6000M、天数彤央TY1200及联想开天X7h的部署流程,同时提供统一工具玄武CLI的使用指南。文中包含完整代码、执行结果、避坑技巧及虚拟实战案例,兼顾新手入门与进阶提升,帮助读者快速掌握国产芯片上的本地AI部署能力,实现数据隐私保护与低成本AI落地。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1004

达摩院高清人像美肤模型ABPN的深入解析及编程实现

本文深入解析了达摩院高清人像美肤模型ABPN的原理,并提供了相应的源代码实现。ABPN模型通过自适应的反投影网络,有效地实现了人像图像的美肤处理。通过进一步的研究和优化,ABPN模型有望在人像美肤领域发挥更大的作用。低频特征提取器用于提取输入图像的低频信息,而反投影网络则负责将低频信息与原始图像结合,生成美肤后的输出图像。通过将输入图像送入ABPN模型,即可得到经过美肤处理后的输出图像。通过对输入图像进行美肤处理,可以有效地去除皮肤上的瑕疵和噪点,提升图像质量和美感。

TechPulseZ的博客 711

【Elasticsearch源码】 GET分析

带着疑问学源码,第四篇:Elasticsearch GET 代码分析基于:https://github.com/jiankunking/elasticsearch Elasticsearch 7.10.2+ 通过前3篇的学习,可以稍微总结一下Elasticsearch: ES是一个集群,所以每个Node都需要和其他的Nodes 进行交互,这些交互是通过NodeClient来完成。 ES中RPC、HTTP请求都是基于Netty自行封装的: NettyTransport 对应RPC协议支持 Netty.

勿忘初心 2473

TXS0104EPWR 4通道电平转换模块原理图设计,已量产

在嵌入式系统设计中,不同模块间的电平不兼容是常见问题 —— 比如 1.8V 的 MCU 与 3.3V 的传感器通信,或是 3.3V 的外设与 5V 的主控交互。这类场景下,一款高效、低功耗的双向电平转换器就成了关键组件。本文将结合实际原理图,深度解析 TI TXS0104 这款 4 通道双向电平转换器的设计要点与应用实践。

不脱发的程序猿 486

elasticsearch-js 的 Get API 实战指南:按 ID 从 Elasticsearch 获取文档

本文基于 [docs/reference/get_examples.md](https://link.gitcode.com/i/ea187f60016d04094b8610063d455063) 官方示例,深入讲解 Node.js 官方客户端 `@elastic/elasticsearch` 中 `client.get()` 方法的完整用法。你将掌握:如何按文档 ID 从指定索引取回 JSON

gitblog_00791的博客 1059

1. SAP Business Application Studio 里创建一个基于 CAP 模型的最简单的 OData 服务

本文基于 SAP Cloud Application Programming 编程模型的 OData 服务开发教程的第一步,简述了 SAP Business Technology Platform 里 Business Application Studio 开发工具的打开方式,创建 Dev Space 以及 CAP 项目的创建步骤,以及如何通过 schema.cds 和 service.cds 分别创建 OData 模型和 OData 服务,最后通过 ports preview 打开 OData 服务预览页

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1795

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Elasticsearch源码分析-关于action

ES源码分析-关于action ES源码版本 7.10 启动过程中的action 比如我们有个搜索请求: curl -X GET "localhost:9200/blogs/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "function_score": { "query": { "match": { "content": "elasticsearch"

lucasma的博客 809

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Elasticsearch - Elasticsearch 性能诊断 从源码角度分析慢查询

Elasticsearch 慢查询诊断:从源码到优化(摘要) 本文系统分析Elasticsearch慢查询问题,提供从源码层面的深度诊断方法。主要内容包括: 问题识别:分析高延迟、资源耗尽等典型症状及潜在危害 执行模型:通过流程图展示Elasticsearch查询的两阶段处理过程(Query Phase和Fetch Phase) 诊断工具:介绍Profile API的使用方法及关键指标解读,如build_scorer和score耗时分析 底层机制:解析Lucene核心查询类(Query/Weight/Sco

千淘万漉虽辛苦,吹尽狂沙始到金 2万+

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

《Elasticsearch 源码解析与优化实战》第9章:Search流程

文章目录简介索引和搜索建立索引执行搜索search type分布式搜索过程协调节点流程1\. Query阶段2\. Fetch阶段执行搜索的数据节点流程1\. 响应Query请求2\. 响应Fetch请求小结 简介 GET操作只能对单个文档进行处理,由_ index、_type 和id 三元组来确定唯一文档。 但搜索需要一种更复杂的模型,因为不知道查询会命中哪些文档。 找到匹配文档仅仅完成了搜索流程的一半,因为多分片中的结果必须组合成单个排序列表。集群的任意节点都可以接收搜索请求,接收客户端请求的节点称为

chbxw 1564

Searx 索引器引擎接入实战:Elasticsearch、Meilisearch 与 Solr 配置详解

> 导读:本文基于 [docs/admin/indexer-engines.rst](https://link.gitcode.com/i/41c3e4240541135892e02f3e0508c2c2),系统讲解如何在 Searx 元搜索引擎中接入三类自建/私有索引器——Elasticsearch、Meilisearch 与 Solr,覆盖完整配置示例、全部可用参数、认证与分页机制,并结合仓库

gitblog_00177的博客 241

调度器是怎么选节点的?Rusternetes Scheduler 的 Filter/Score 插件架构与抢占机制详解

Rusternetes 是一个用 Rust 重写的 Kubernetes 实现,它的 Rusternetes Scheduler(调度器)负责决定每个 Pod 应该落在哪个 Node 上。本文面向新手,用尽量少的代码讲清楚三件事:调度器是如何"选节点"的、Filter/Score 插件架构如何工作、以及资源不够时抢占(Preemption)机制如何触发。读完你会明白:一个 Pending 状态的

gitblog_00997的博客 904

ES查询流程源码解析

  一些基础知识 早先ES的HTTP协议支持还是依赖Jetty的,现在不管是Rest还是RPC都是直接基于Netty了。 另外值得一提的是,ES 是使用Google的Guice 进行模块管理,所以了解Guice的基本使用方式有助于你了解ES的代码组织。 ES 的启动类是 org.elasticsearch.bootstrap.Bootstrap。在这里进行一些配置和环境初始化后会启动org...

赵英超的博客 2370
上一篇: elasticsearch源码分析-06索引恢复
下一篇: elasticsearch源码分析-08Serch查询流程
胖柯G
博客等级 码龄10年 453粉丝 57原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值