use of com.orientechnologies.orient.core.index.OIndexFullText in project orientdb by orientechnologies.
the class OQueryOperatorContainsText method filterRecords.
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public Collection<OIdentifiable> filterRecords(final ODatabase<?> iDatabase, final List<String> iTargetClasses, final OSQLFilterCondition iCondition, final Object iLeft, final Object iRight) {
final String fieldName;
if (iCondition.getLeft() instanceof OSQLFilterItemField)
fieldName = iCondition.getLeft().toString();
else
fieldName = iCondition.getRight().toString();
final String fieldValue;
if (iCondition.getLeft() instanceof OSQLFilterItemField)
fieldValue = iCondition.getRight().toString();
else
fieldValue = iCondition.getLeft().toString();
final String className = iTargetClasses.get(0);
final OProperty prop = ((OMetadataInternal) iDatabase.getMetadata()).getImmutableSchemaSnapshot().getClass(className).getProperty(fieldName);
if (prop == null)
// NO PROPERTY DEFINED
return null;
OIndex<?> fullTextIndex = null;
for (final OIndex<?> indexDefinition : prop.getIndexes()) {
if (indexDefinition instanceof OIndexFullText) {
fullTextIndex = indexDefinition;
break;
}
}
if (fullTextIndex == null) {
return null;
}
return (Collection<OIdentifiable>) fullTextIndex.get(fieldValue);
}
use of com.orientechnologies.orient.core.index.OIndexFullText in project orientdb by orientechnologies.
the class OChainedIndexProxyFindBestIndexTest method mockFullTextIndex.
private OIndexFullText mockFullTextIndex() {
final OIndexFullText uniqueIndex = mock(OIndexFullText.class);
when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);
final OIndexDefinition definition = mock(OIndexDefinition.class);
when(definition.getParamCount()).thenReturn(1);
when(uniqueIndex.getDefinition()).thenReturn(definition);
return uniqueIndex;
}
use of com.orientechnologies.orient.core.index.OIndexFullText in project orientdb by orientechnologies.
the class OQueryOperatorContainsText method executeIndexQuery.
@Override
public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {
final OIndexDefinition indexDefinition = index.getDefinition();
if (indexDefinition.getParamCount() > 1)
return null;
final OIndex<?> internalIndex = index.getInternal();
OIndexCursor cursor;
if (internalIndex instanceof OIndexFullText) {
final Object key = indexDefinition.createValue(keyParams);
final Object indexResult = index.get(key);
if (indexResult == null || indexResult instanceof OIdentifiable)
cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, key);
else
cursor = new OIndexCursorCollectionValue((Collection<OIdentifiable>) indexResult, key);
} else
return null;
updateProfiler(iContext, internalIndex, keyParams, indexDefinition);
return cursor;
}
Aggregations