use of org.apache.lucene.store.RAMDirectory in project querydsl by querydsl.
the class LuceneSerializerNotTokenizedTest method before.
@Before
public void before() throws Exception {
serializer = new LuceneSerializer(false, false);
idx = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_30)).setOpenMode(IndexWriterConfig.OpenMode.CREATE);
writer = new IndexWriter(idx, config);
writer.addDocument(createDocument(clooney));
writer.addDocument(createDocument(pitt));
Document document = new Document();
for (String movie : Arrays.asList("Interview with the Vampire", "Up in the Air")) {
document.add(new Field("movie", movie, Store.YES, Index.NOT_ANALYZED));
}
writer.addDocument(document);
writer.close();
IndexReader reader = IndexReader.open(idx);
searcher = new IndexSearcher(reader);
}
use of org.apache.lucene.store.RAMDirectory in project querydsl by querydsl.
the class LuceneQueryTest method setUp.
@Before
public void setUp() throws Exception {
final QDocument entityPath = new QDocument("doc");
title = entityPath.title;
year = entityPath.year;
gross = entityPath.gross;
idx = new RAMDirectory();
writer = createWriter(idx);
writer.addDocument(createDocument("Jurassic Park", "Michael Crichton", "It's a UNIX system! I know this!", 1990, 90.00));
writer.addDocument(createDocument("Nummisuutarit", "Aleksis Kivi", "ESKO. Ja iloitset ja riemuitset?", 1864, 10.00));
writer.addDocument(createDocument("The Lord of the Rings", "John R. R. Tolkien", "One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them", 1954, 89.00));
writer.addDocument(createDocument("Introduction to Algorithms", "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein", "Bubble sort", 1990, 30.50));
writer.close();
IndexReader reader = IndexReader.open(idx);
searcher = new IndexSearcher(reader);
query = new LuceneQuery(new LuceneSerializer(true, true), searcher);
}
use of org.apache.lucene.store.RAMDirectory in project querydsl by querydsl.
the class LuceneQueryTest method empty_index_should_return_empty_list.
@Test
public void empty_index_should_return_empty_list() throws Exception {
idx = new RAMDirectory();
writer = createWriter(idx);
writer.close();
IndexReader reader = IndexReader.open(idx);
searcher = new IndexSearcher(reader);
query = new LuceneQuery(new LuceneSerializer(true, true), searcher);
assertTrue(query.fetch().isEmpty());
}
use of org.apache.lucene.store.RAMDirectory in project querydsl by querydsl.
the class LuceneSerializerNotTokenizedTest method before.
@Before
public void before() throws Exception {
serializer = new LuceneSerializer(false, false);
idx = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(new StandardAnalyzer()).setOpenMode(IndexWriterConfig.OpenMode.CREATE);
writer = new IndexWriter(idx, config);
writer.addDocument(createDocument(clooney));
writer.addDocument(createDocument(pitt));
Document document = new Document();
for (String movie : Arrays.asList("Interview with the Vampire", "Up in the Air")) {
document.add(new Field("movie", movie, Store.YES, Index.NOT_ANALYZED));
}
writer.addDocument(document);
writer.close();
IndexReader reader = DirectoryReader.open(idx);
searcher = new IndexSearcher(reader);
}
use of org.apache.lucene.store.RAMDirectory in project querydsl by querydsl.
the class LuceneSerializerTest method setUp.
@Before
public void setUp() throws Exception {
serializer = new LuceneSerializer(true, true);
entityPath = new PathBuilder<Object>(Object.class, "obj");
title = entityPath.getString("title");
author = entityPath.getString("author");
text = entityPath.getString("text");
publisher = entityPath.getString("publisher");
year = entityPath.getNumber("year", Integer.class);
rating = entityPath.getString("rating");
gross = entityPath.getNumber("gross", Double.class);
titles = entityPath.getCollection("title", String.class, StringPath.class);
longField = entityPath.getNumber("longField", Long.class);
shortField = entityPath.getNumber("shortField", Short.class);
byteField = entityPath.getNumber("byteField", Byte.class);
floatField = entityPath.getNumber("floatField", Float.class);
idx = new RAMDirectory();
config = new IndexWriterConfig(Version.LUCENE_42, new StandardAnalyzer(Version.LUCENE_42)).setOpenMode(IndexWriterConfig.OpenMode.CREATE);
writer = new IndexWriter(idx, config);
writer.addDocument(createDocument());
writer.close();
IndexReader reader = IndexReader.open(idx);
searcher = new IndexSearcher(reader);
}
Aggregations