com.orientechnologies.lucene.functions.OLuceneSearchOnClassFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of orientdb-lucene Show documentation
Show all versions of orientdb-lucene Show documentation
Lucene plugin for OrientDB NoSQL document graph dbms
The newest version!
package com.orientechnologies.lucene.functions;
import static com.orientechnologies.lucene.functions.OLuceneFunctionsUtils.getOrCreateMemoryIndex;
import com.orientechnologies.lucene.builder.OLuceneQueryBuilder;
import com.orientechnologies.lucene.collections.OLuceneCompositeKey;
import com.orientechnologies.lucene.index.OLuceneFullTextIndex;
import com.orientechnologies.lucene.query.OLuceneKeyAndMetadata;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.metadata.OMetadataInternal;
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
import com.orientechnologies.orient.core.sql.parser.OBinaryCompareOperator;
import com.orientechnologies.orient.core.sql.parser.OExpression;
import com.orientechnologies.orient.core.sql.parser.OFromClause;
import com.orientechnologies.orient.core.sql.parser.OFromItem;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.memory.MemoryIndex;
/** Created by frank on 15/01/2017. */
public class OLuceneSearchOnClassFunction extends OLuceneSearchFunctionTemplate {
public static final String NAME = "search_class";
public OLuceneSearchOnClassFunction() {
super(NAME, 1, 2);
}
@Override
public String getName() {
return NAME;
}
@Override
public boolean canExecuteInline(
OFromClause target,
OBinaryCompareOperator operator,
Object rightValue,
OCommandContext ctx,
OExpression... args) {
return true;
}
@Override
public Object execute(
Object iThis,
OIdentifiable iCurrentRecord,
Object iCurrentResult,
Object[] params,
OCommandContext ctx) {
OResult result;
if (iThis instanceof OResult) {
result = (OResult) iThis;
} else {
result = new OResultInternal((OIdentifiable) iThis);
}
if (!result.getElement().isPresent()) return false;
OElement element = result.getElement().get();
if (!element.getSchemaType().isPresent()) return false;
String className = element.getSchemaType().get().getName();
OLuceneFullTextIndex index = searchForIndex(ctx, className);
if (index == null) return false;
String query = (String) params[0];
MemoryIndex memoryIndex = getOrCreateMemoryIndex(ctx);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy