Skip to content

Commit

Permalink
implemented #39
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Apr 29, 2015
1 parent 44c2648 commit d9ec6b3
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import com.orientechnologies.orient.core.index.*;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.serialization.serializer.stream.OStreamSerializer;
import org.apache.lucene.search.IndexSearcher;

import java.io.IOException;

public class OLuceneIndexEngine<V> extends OSharedResourceAdaptiveExternal implements OIndexEngine<V> {

Expand Down Expand Up @@ -197,4 +200,8 @@ public ODocument getIndexMetadata() {
public void setRebuilding(boolean rebuilding) {
lucene.setRebuilding(rebuilding);
}

public IndexSearcher searcher() throws IOException {
return lucene.getSearcher();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.orientechnologies.lucene.LuceneTxOperations;
import com.orientechnologies.lucene.OLuceneIndex;
import com.orientechnologies.lucene.OLuceneIndexEngine;
import com.orientechnologies.lucene.manager.OLuceneIndexManagerAbstract;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.index.OIndexDefinition;
import com.orientechnologies.orient.core.index.OIndexMultiValues;
Expand Down Expand Up @@ -198,6 +197,6 @@ protected Object getCollatingValue(Object key) {

@Override
public IndexSearcher searcher() throws IOException {
return ((OLuceneIndexManagerAbstract) indexEngine).getSearcher();
return ((OLuceneIndexEngine) indexEngine).searcher();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@ public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OS
}

}


}
125 changes: 0 additions & 125 deletions src/test/java/com/orientechnologies/test/JavaTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
*
* * Copyright 2014 Orient Technologies.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package com.orientechnologies.test;

import com.orientechnologies.lucene.index.OLuceneIndexNotUnique;
import com.orientechnologies.orient.core.index.OIndex;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OSchema;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import org.junit.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import java.io.IOException;

/**
* Created by Enrico Risa on 29/04/15.
*/
public class LuceneGetSearcherTest extends BaseLuceneTest {
@Override
protected String getDatabaseName() {
return "getSearcher";
}

@BeforeClass
public void init() {
initDB();
OSchema schema = databaseDocumentTx.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass song = schema.createClass("Person");
song.setSuperClass(v);
song.createProperty("isDeleted", OType.BOOLEAN);

databaseDocumentTx.command(new OCommandSQL("create index Person.isDeleted on Person (isDeleted) FULLTEXT ENGINE LUCENE"))
.execute();

}

@AfterClass
public void deInit() {
deInitDB();
}

public void testSearcherInstance() {

OIndex<?> index = databaseDocumentTx.getMetadata().getIndexManager().getIndex("Person.isDeleted");

Assert.assertEquals(true, index.getInternal() instanceof OLuceneIndexNotUnique);

OLuceneIndexNotUnique idx = (OLuceneIndexNotUnique) index.getInternal();

try {
Assert.assertNotNull(idx.searcher());
} catch (IOException e) {
e.printStackTrace();
}
}
}

0 comments on commit d9ec6b3

Please sign in to comment.