日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

es 插件

發布時間:2023/12/13 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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接口的類

?

轉載于:https://www.cnblogs.com/ydxblog/p/8074058.html

總結

以上是生活随笔為你收集整理的es 插件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。