Skip to content

Commit

Permalink
fixed #19 and #16
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 3, 2014
1 parent 68cd2de commit 296e9a9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-lucene</artifactId>
<version>1.7.5</version>
<version>1.7.8</version>
<packaging>jar</packaging>

<name>lucene</name>
Expand Down Expand Up @@ -96,7 +96,7 @@
<properties>
<javac.src.version>1.6</javac.src.version>
<javac.target.version>1.6</javac.target.version>
<orientdb.version>1.7.4</orientdb.version>
<orientdb.version>1.7.9-SNAPSHOT</orientdb.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ public V get(Object key) {
return (V) lucene.get(key);
}



@Override
public void put(Object key, V value) {
lucene.put(key, value);
Expand Down Expand Up @@ -194,6 +192,11 @@ public OIndexCursor cursor(ValuesTransformer<V> valuesTransformer) {
return lucene.cursor(valuesTransformer);
}

@Override
public OIndexCursor descCursor(ValuesTransformer<V> vValuesTransformer) {
return lucene.descCursor(vValuesTransformer);
}

@Override
public OIndexKeyCursor keyCursor() {
return lucene.keyCursor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,19 @@ private Set<OIdentifiable> getResults(Query query, OCommandContext context) {
try {
IndexSearcher searcher = getSearcher();

Map<String, Float> scores = new HashMap<String, Float>();
TopDocs docs = searcher.search(query, Integer.MAX_VALUE);
Integer limit = (Integer) context.getVariable("$limit");
// Map<String, Float> scores = new HashMap<String, Float>();
TopDocs docs = searcher.search(query, (limit != null && limit > 0) ? limit : Integer.MAX_VALUE);
ScoreDoc[] hits = docs.scoreDocs;
for (ScoreDoc score : hits) {
Document ret = searcher.doc(score.doc);
String rId = ret.get(RID);
results.add(new ORecordId(rId));
scores.put(rId, score.score);
}
if (context != null) {
context.setVariable("$luceneScore", scores);
// scores.put(rId, score.score);
}
// if (context != null) {
// context.setVariable("$luceneScore", scores);
// }
} catch (IOException e) {
throw new OIndexException("Error reading from Lucene index", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,8 @@ private ODatabaseRecord getDatabase() {
return ODatabaseRecordThreadLocal.INSTANCE.get();
}


@Override
public OIndexCursor descCursor(ValuesTransformer<V> vValuesTransformer) {
@Override
public OIndexCursor descCursor(ValuesTransformer<V> vValuesTransformer) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.ODatabaseComplex;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.index.*;
import com.orientechnologies.orient.core.metadata.schema.OClass;
Expand All @@ -50,6 +51,7 @@ public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index,
else
cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), new OFullTextCompositeKey(
keyParams));
iContext.setVariable("$luceneIndex", true);
return cursor;
}

Expand Down Expand Up @@ -84,11 +86,15 @@ public Collection<OIdentifiable> filterRecords(ODatabaseComplex<?> iRecord, List
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft,
Object iRight, OCommandContext iContext) {

Map<String, Float> scores = (Map<String, Float>) iContext.getVariable("$luceneScore");
if (scores != null) {
iContext.setVariable("$score", scores.get(iRecord.getIdentity().toString()));
// Map<String, Float> scores = (Map<String, Float>) iContext.getVariable("$luceneScore");
// if (scores != null) {
// iContext.setVariable("$score", scores.get(iRecord.getIdentity().toString()));
// }
if (iContext.getVariable("$luceneIndex") != null) {
return true;
} else {
return false;
}
return super.evaluateRecord(iRecord, iCurrentResult, iCondition, iLeft, iRight, iContext);

}
}

0 comments on commit 296e9a9

Please sign in to comment.