es 插件
类 若 实现NativeScriptFactory接口。A factory to create instances of either {@link ExecutableScript} or {@link SearchScript}
只是一个工厂类,仍需要 创建 上面二者之一。实际中 需 创建 类 继承 SearchScript接口的实现类AbstractSearchScript 的 子类@ AbstractLongSearchScript @AbstractDoubleSearchScript。
我们使用 它是因为public List<NativeScriptFactory> getNativeScripts() 需要返回的是工厂。
NativeScriptFactory
/**
* A factory to create instances of either {@link ExecutableScript} or {@link SearchScript}. Note,
* if this factory creates {@link SearchScript}, it must extend {@link AbstractSearchScript}.
*
* @see AbstractExecutableScript
* @see AbstractSearchScript
* @see AbstractLongSearchScript
* @see AbstractDoubleSearchScript
*/
public interface NativeScriptFactory {
ExecutableScript (一般不用,忽略)
* An executable script, can't be used concurrently.
SearchScript 接口
AbstractSearchScript (核心类,提供了绝大部分功能的实现)
/**
* A base class for any script type that is used during the search process (custom score, aggs, and so on).
* <p>
* If the script returns a specific numeric type, consider overriding the type specific base classes
* such as {@link AbstractDoubleSearchScript} and {@link AbstractLongSearchScript}
* for better performance.
* <p>
* The use is required to implement the {@link #run()} method.
*/
public abstract class AbstractSearchScript extends AbstractExecutableScript implements LeafSearchScript {
它 的核心是 属性:
private LeafSearchLookup lookup;
private Scorer scorer;
所有方法的实现同和这两个属性有关。
setLookup()实现lookup的初始化
通过SearchLookup调用lookup.getLeafSearchLookup(context)实现
searchLookUp则通过DefaultSearchContext.lookup()实现初始化
lookup(): getQueryShardContext().lookup();
DefaultSearchContext则通过createContext实现初始化
也就是通过QueryShardContext.lookup() 实现。
QueryShardContext : lookup = new SearchLookup(getMapperService(), indexFieldDataService, types);
其主要属性 及初始化:
public class SearchLookup {
final DocLookup docMap;
final SourceLookup sourceLookup;
final FieldsLookup fieldsLookup;
public SearchLookup(MapperService mapperService, IndexFieldDataService fieldDataService, @Nullable String[] types) {
docMap = new DocLookup(mapperService, fieldDataService, types);
sourceLookup = new SourceLookup();
fieldsLookup = new FieldsLookup(mapperService, types);
}
public class FieldsLookup {
private final MapperService mapperService;
@Nullable
private final String[] types;
FieldsLookup(MapperService mapperService, @Nullable String[] types) {
this.mapperService = mapperService;
this.types = types;
}
然后追踪 传参的来源:
queryShardContext.setTypes(ShardSearchRequest.types());
LocalTransport.sendRequest()
targetTransport.receiveMessage(version, data, action, requestId, this);
processReceivedMessage(data, action, sourceTransport, version, requestId);
StreamInput stream = StreamInput.wrap(data);
handleRequest(stream, requestId, data.length, sourceTransport, version);
request.readFrom(stream);
TaskId.readFromStream(in);
ShardSearchTransportRequest.readFrom()
shardSearchLocalRequest.innerReadFrom(in);
types = in.readStringArray();
总结: 数据有了,直接用
plsSearchScript 继承自AbstractSearchScript 类。
覆写了run(),run方法会执行plsExScript接口的run().
我们只需要提供一个实现plsExScirpt接口的类
es 插件的更多相关文章
- 批量搞机(二):分布式ELK平台、Elasticsearch介绍、Elasticsearch集群安装、ES 插件的安装与使用
一.分布式ELK平台 ELK的介绍: ELK 是什么? Sina.饿了么.携程.华为.美团.freewheel.畅捷通 .新浪微博.大讲台.魅族.IBM...... 这些公司都在使用 ELK!ELK! ...
- ELK搭建<二>:安装ES插件head
1.去github下载head,针对ES版本不同,安装方式也不一样, =>在2.x以前版本可以通过插件安装 for Elasticsearch 2.x: sudo elasticsearch/b ...
- ES插件elasticsearch-mapper-attachments 2.3.4及各个版本正确下载地址
ES版本更新那么快,文档链接你也倒是跟上啊, 插件zip包下载,都是error link...难不成是我网络原因? 下载zip页面报错信息: This XML file does not appear ...
- es插件安装
首先安装找到一样版本的地址: Release v7.6.1 · medcl/elasticsearch-analysis-ik (github.com) 下载最上面的编译版 将文件解压到plugins ...
- ES插件升级
#!/bin/bash mkdir -p /home/esuser cd /home/esuser wget http://10.12.xx.xx:8090/search_plugins/sd_wai ...
- #研发解决方案介绍#基于ES的搜索+筛选+排序解决方案
郑昀 基于胡耀华和王超的设计文档 最后更新于2014/12/3 关键词:ElasticSearch.Lucene.solr.搜索.facet.高可用.可伸缩.mongodb.SearchHub.商品中 ...
- elasticsearch集群管理工具head插件(转)
elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es 插件安装方法1: 1.elasticsearc ...
- ES的安装运行
一.安装,运行 1. 检查java的版本环境 Elasticsearch依赖Java,在书写本文档的时候,推荐使用Oracle JDK 1.8.0_20 或 1.7.0_55以后的版本. 在安装Ela ...
- Elasticsarch及插件安装
Elasticsarch及插件安装 一.环境介绍与安装准备 1.环境说明 OS为Centos 6.5,elasticsearch-1.1.X.tar.gz, 注:mongo river ...
随机推荐
- bzoj2006: [NOI2010]超级钢琴(堆+RMQ)
和上一道题同类型...都是用堆求第k大 考虑对于每一个r,怎么求出一个最优的l.显然只需要求出前缀和,用RMQ查询前面最小的l的前缀和就好了.但是对于一个r,每个l只能选一次,选了一次之后,考虑怎么把 ...
- 解题:ZJOI 2014 力
题面 事实说明只会FFT板子是没有用的,还要把式子推成能用FFT/转化一下卷积的方式 虽然这个题不算难的多项式卷积 稍微化简一下可以发现实际是$q_i$和$\frac{1}{(i-j)^2}$在卷,然 ...
- 【CodeChef】Chef and Graph Queries
Portal --> CC Chef and Graph Queries Solution 快乐数据结构题(然而好像有十分优秀的莫队+可撤销并查集搞法qwq) 首先考虑一种方式来方便一点地..计 ...
- python基础----__next__和__iter__实现迭代器协议
#_*_coding:utf-8_*_ __author__ = 'Linhaifeng' class Foo: def __init__(self,x): self.x=x def __iter__ ...
- maven 启动 tomcat 及 跳过 test 安装
1.先在pom文件中配置 tomcat插件 <!-- 文件上传组件 --> <dependency> <groupId>commons-fileupload< ...
- iOS之富文本(二)
之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结 ...
- tf.session.run()单函数运行和多函数运行区别
tf.session.run()单函数运行和多函数运行区别 觉得有用的话,欢迎一起讨论相互学习~Follow Me problem instruction sess.run([a,b]) # (1)同 ...
- Ubuntu+NDK编译支持HTTPS的libcurl
参考文章:1.NDK环境配置 http://blog.csdn.net/smfwuxiao/article/details/65877092.libcurl的配置修改 http://piggyq.co ...
- Excel 报表导入导出
使用 Excel 进行报表的导入导出,首先下载相关的 jar 和 excel util. Excel Util 下载地址 引入依赖: <!-- poi office --> <dep ...
- Redhat安装配置VNC服务器
1. 检查安装VNC服务器 # rpm -qa|grep vnc 如果返回信息中有tigervnc-server,说明已安装了VNC:如果没有: # yum install tigervnc # yu ...