Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
fixed bug #10
Browse files Browse the repository at this point in the history
  • Loading branch information
maggiolo00 authored and maggiolo00 committed May 28, 2014
1 parent 48ed5d9 commit e21febd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.record.impl.ODocument;


public class OLuceneIndexFactory implements OIndexFactory {

private static final Set<String> TYPES;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/com/orientechnologies/lucene/OLuceneIndexType.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,25 @@ public static Query createFullQuery(OIndexDefinition index, Object key, Analyzer
String query = null;
if (key instanceof String) {
query = (String) key;
queryParser = getQueryParser(index, query, analyzer, version);
return getQueryParser(index, query, analyzer, version);
} else if (key instanceof OCompositeKey) {
query = ((OCompositeKey) key).getKeys().get(0).toString();
queryParser = getQueryParser(index, query, analyzer, version);
return getQueryParser(index, query, analyzer, version);
}
return queryParser.parse(query);
return null;
}

protected static QueryParser getQueryParser(OIndexDefinition index, String key, Analyzer analyzer, Version version) {
protected static Query getQueryParser(OIndexDefinition index, String key, Analyzer analyzer, Version version)
throws ParseException {
QueryParser queryParser;
if (((String) key).startsWith("(")) {
if ((key).startsWith("(")) {
queryParser = new QueryParser(version, "", analyzer);

} else {
queryParser = new MultiFieldQueryParser(version, index.getFields().toArray(new String[index.getFields().size()]), analyzer);
key = QueryParser.escape(key);
}
return queryParser;
return queryParser.parse(key);
}

public static Sort sort(Query query, OIndexDefinition index, boolean ascSortOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.orientechnologies.common.listener.OProgressListener;
import com.orientechnologies.lucene.OLuceneIndex;
import com.orientechnologies.lucene.OLuceneIndexEngine;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ridbag.sbtree.OIndexRIDContainer;
import com.orientechnologies.orient.core.index.ODefaultIndexFactory;
import com.orientechnologies.orient.core.index.OIndexDefinition;
import com.orientechnologies.orient.core.index.OIndexFullText;
import com.orientechnologies.orient.core.index.OIndexMultiValues;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.type.tree.OMVRBTreeRIDSet;

public class OLuceneFullTextIndex extends OIndexMultiValues implements OLuceneIndex {

Expand Down Expand Up @@ -131,6 +136,35 @@ public boolean canBeUsedInEqualityOperators() {
return true;
}

@Override
protected void putInSnapshot(Object key, OIdentifiable value, Map<Object, Object> snapshot) {
key = getCollatingValue(key);

Object snapshotValue = snapshot.get(key);

Set<OIdentifiable> values;
if (snapshotValue == null)
values = null;
else if (snapshotValue.equals(RemovedValue.INSTANCE))
values = null;
else
values = (Set<OIdentifiable>) snapshotValue;

if (values == null) {
if (ODefaultIndexFactory.SBTREEBONSAI_VALUE_CONTAINER.equals(valueContainerAlgorithm)) {
values = new OIndexRIDContainer(getName());
} else {
values = new OMVRBTreeRIDSet(OGlobalConfiguration.MVRBTREE_RID_BINARY_THRESHOLD.getValueAsInteger());
((OMVRBTreeRIDSet) values).setAutoConvertToRecord(false);
}

snapshot.put(key, values);
}

values.add(value.getIdentity());
snapshot.put(key, values);
}

@Override
public long rebuild(OProgressListener iProgressListener) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,20 @@ public boolean remove(Object key, OIdentifiable value) {
modificationLock.releaseModificationLock();
}
}

@Override
public long rebuild(OProgressListener iProgressListener) {

long size = 0;
OLuceneIndexEngine engine = (OLuceneIndexEngine) indexEngine;
try {
engine.setRebuilding(true);
super.rebuild(iProgressListener);
} finally {
engine.setRebuilding(false);
}

return size;

}
}

0 comments on commit e21febd

Please sign in to comment.