public void clear() { memoryIndex.reset(); fieldStats.clear(); } /*
@Override public void close() { try { this.reader().close(); memoryIndex.reset(); } catch (IOException e) { throw new ElasticsearchException("failed to close percolator in-memory index", e); } } }
@Override public void close() { try { this.reader().close(); rootDocMemoryIndex.reset(); } catch (IOException e) { throw new ElasticsearchException("failed to close IndexReader in percolator with nested doc", e); } }
private boolean matchCollectionIndex(List iLeft, Object iRight, OLuceneFullTextIndex index, MemoryIndex memoryIndex) throws IOException, ParseException { boolean match = false; List<Object> collections = transformInput(iLeft, iRight, index, memoryIndex); for (Object collection : collections) { memoryIndex.reset(); match = match || matchField(collection, iRight, index, memoryIndex); if (match) { break; } } return match; }
private MemoryIndex getOrCreateMemoryIndex(OCommandContext ctx) { MemoryIndex memoryIndex = (MemoryIndex) ctx.getVariable(MEMORY_INDEX); if (memoryIndex == null) { memoryIndex = new MemoryIndex(); ctx.setVariable(MEMORY_INDEX, memoryIndex); } memoryIndex.reset(); return memoryIndex; }
public static MemoryIndex getOrCreateMemoryIndex(OCommandContext ctx) { MemoryIndex memoryIndex = (MemoryIndex) ctx.getVariable(MEMORY_INDEX); if (memoryIndex == null) { memoryIndex = new MemoryIndex(); ctx.setVariable(MEMORY_INDEX, memoryIndex); } memoryIndex.reset(); return memoryIndex; }
public boolean isDeleted(Document document, Object key, OIdentifiable value) { boolean match = false; List<String> strings = deleted.get(value.getIdentity().toString()); if (strings != null) { MemoryIndex memoryIndex = new MemoryIndex(); for (String string : strings) { Query q = engine.deleteQuery(string, value); memoryIndex.reset(); for (IndexableField field : document.getFields()) { memoryIndex.addField(field.name(), field.stringValue(), new KeywordAnalyzer()); } match = match || (memoryIndex.search(q) > 0.0f); } return match; } return match; }
@Override public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft, Object iRight, OCommandContext iContext, final ODocumentSerializer serializer) { OLuceneFullTextIndex index = involvedIndex(iRecord, iCurrentResult, iCondition, iLeft, iRight); if (index == null) { throw new OCommandExecutionException("Cannot evaluate lucene condition without index configuration."); } MemoryIndex memoryIndex = (MemoryIndex) iContext.getVariable(MEMORY_INDEX); if (memoryIndex == null) { memoryIndex = new MemoryIndex(); iContext.setVariable(MEMORY_INDEX, memoryIndex); } memoryIndex.reset(); try { // In case of collection field evaluate the query with every item until matched if (iLeft instanceof List && index.isCollectionIndex()) { return matchCollectionIndex((List) iLeft, iRight, index, memoryIndex); } else { return matchField(iLeft, iRight, index, memoryIndex); } } catch (ParseException e) { OLogManager.instance().error(this, "error occurred while building query", e); } catch (IOException e) { OLogManager.instance().error(this, "error occurred while building memory index", e); } return null; }
@Override public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft, Object iRight, OCommandContext iContext) { OLuceneFullTextIndex index = involvedIndex(iRecord, iCurrentResult, iCondition, iLeft, iRight); if (index == null) { throw new OCommandExecutionException("Cannot evaluate lucene condition without index configuration."); } MemoryIndex memoryIndex = (MemoryIndex) iContext.getVariable("_memoryIndex"); if (memoryIndex == null) { memoryIndex = new MemoryIndex(); iContext.setVariable("_memoryIndex", memoryIndex); } memoryIndex.reset(); Document doc = index.buildDocument(iLeft); for (IndexableField field : doc.getFields()) { memoryIndex.addField(field.name(), field.stringValue(), index.analyzer(field.name())); } Query query = null; try { query = index.buildQuery(iRight); } catch (Exception e) { throw new OCommandExecutionException("Error executing lucene query.", e); } return memoryIndex.search(query) > 0.0f; }