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

Commit

Permalink
fixed #17
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 3, 2014
1 parent 296e9a9 commit 8015100
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/orientechnologies/lucene/OLuceneIndexType.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ public static Query createQueryId(OIdentifiable value) {
return new TermQuery(new Term(OLuceneIndexManagerAbstract.RID, value.toString()));
}

public static Query createFullQuery(OIndexDefinition index, OCompositeKey key, Analyzer analyzer, Version version)
throws ParseException {
public static Query createFullQuery(OIndexDefinition index, Object key, Analyzer analyzer, Version version) throws ParseException {

String query = key.getKeys().get(0).toString();
String query = "";
if (key instanceof OCompositeKey) {
query = ((OCompositeKey) key).getKeys().get(0).toString();
} else {
query = key.toString();
}

return getQueryParser(index, query, analyzer, version);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public Object get(Object key) {
Query q = null;

try {
q = OLuceneIndexType.createFullQuery(index, (OCompositeKey) key, mgrWriter.getIndexWriter().getAnalyzer(),
getVersion(metadata));
q = OLuceneIndexType.createFullQuery(index, key, mgrWriter.getIndexWriter().getAnalyzer(), getVersion(metadata));
OCommandContext context = null;
if (key instanceof OFullTextCompositeKey) {
context = ((OFullTextCompositeKey) key).getContext();
Expand Down Expand Up @@ -145,15 +144,18 @@ private Set<OIdentifiable> getResults(Query query, OCommandContext context) {
try {
IndexSearcher searcher = getSearcher();

Integer limit = (Integer) context.getVariable("$limit");
// Map<String, Float> scores = new HashMap<String, Float>();
Integer limit = null;
if (context != null) {
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);
// scores.put(rId, score.score);
}
// if (context != null) {
// context.setVariable("$luceneScore", scores);
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/orientechnologies/test/TestEmbedded.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.orientechnologies.test;

/**
* Created by enricorisa on 03/09/14.
*/
public class TestEmbedded {
}

0 comments on commit 8015100

Please sign in to comment.