/** Set the current document to run the script on next. */ public void setDocument(int docid) { // TODO: remove leniency when painless does not implement SearchScript for executable script cases if (leafLookup != null) { leafLookup.setDocument(docid); } }
/** * Return the parameters for this script. */ public Map<String, Object> getParams() { this.params.putAll(leafLookup.asMap()); return params; }
public LeafSearchLookup getLeafSearchLookup(LeafReaderContext context) { return new LeafSearchLookup(context, docMap.getLeafDocLookup(context), sourceLookup, fieldsLookup.getLeafFieldsLookup(context)); }
/** * The doc lookup for the Lucene segment this script was created for. */ public Map<String, ScriptDocValues<?>> getDoc() { return leafLookup.doc(); }
public void initialize(Engine.Searcher docSearcher, ParsedDocument parsedDocument) { this.docSearcher = docSearcher; IndexReader indexReader = docSearcher.reader(); LeafReaderContext atomicReaderContext = indexReader.leaves().get(0); LeafSearchLookup leafLookup = lookup().getLeafSearchLookup(atomicReaderContext); leafLookup.setDocument(0); leafLookup.source().setSource(parsedDocument.source()); Map<String, SearchHitField> fields = new HashMap<>(); for (IndexableField field : parsedDocument.rootDoc().getFields()) { fields.put(field.name(), new InternalSearchHitField(field.name(), Collections.emptyList())); } hitContext().reset( new InternalSearchHit(0, "unknown", new Text(parsedDocument.type()), fields), atomicReaderContext, 0, docSearcher.searcher() ); }
/** * Allows to access the actual source (loaded and parsed). */ protected final SourceLookup source() { return lookup.source(); }
/** * Allows to access statistics on terms and fields. */ protected final LeafIndexLookup indexLookup() { return lookup.indexLookup(); }
/** * Allows to access the *stored* fields. */ protected final LeafFieldsLookup fields() { return lookup.fields(); }
/** The doc lookup for the Lucene segment this script was created for. */ public final LeafDocLookup getDoc() { // TODO: remove leniency when painless does not implement SearchScript for executable script cases return leafLookup == null ? null : leafLookup.doc(); }
/** * Allows to access the actual source (loaded and parsed). */ protected final SourceLookup source() { return lookup.source(); }
/** * Allows to access statistics on terms and fields. */ protected final LeafIndexLookup indexLookup() { return lookup.indexLookup(); }
/** * Allows to access the *stored* fields. */ protected final LeafFieldsLookup fields() { return lookup.fields(); }
/** * Set the current document to run the script on next. */ public void setDocument(int docid) { leafLookup.setDocument(docid); }
public MapScript(Map<String, Object> params, Object state, SearchLookup lookup, LeafReaderContext leafContext) { this.state = state; this.leafLookup = leafContext == null ? null : lookup.getLeafSearchLookup(leafContext); if (leafLookup != null) { params = new HashMap<>(params); // copy params so we aren't modifying input params.putAll(leafLookup.asMap()); // add lookup vars params = new ParameterMap(params, DEPRECATIONS); // wrap with deprecations } this.params = params; }
public Map<String, ScriptDocValues<?>> getDoc() { return leafLookup == null ? null : leafLookup.doc(); }
public LeafSearchLookup getLeafSearchLookup(LeafReaderContext context) { return new LeafSearchLookup(context, docMap.getLeafDocLookup(context), sourceLookup, fieldsLookup.getLeafFieldsLookup(context)); }
@Override public void setSource(Map<String, Object> source) { if (lookup != null) { lookup.source().setSource(source); } }
public void setDocument(int docId) { if (leafLookup != null) { leafLookup.setDocument(docId); } }
public ScoreScript(Map<String, Object> params, SearchLookup lookup, LeafReaderContext leafContext) { // null check needed b/c of expression engine subclass if (lookup == null) { assert params == null; assert leafContext == null; this.params = null; this.leafLookup = null; } else { this.leafLookup = lookup.getLeafSearchLookup(leafContext); params = new HashMap<>(params); params.putAll(leafLookup.asMap()); this.params = new ParameterMap(params, DEPRECATIONS); } }
/** The doc lookup for the Lucene segment this script was created for. */ public final Map<String, ScriptDocValues<?>> getDoc() { return leafLookup.doc(); }