Skip to content

Commit ee942fc

Browse files
committed
refactored rdfbean-lucene to use Compass as the API layer on top of Lucene
1 parent ed1d700 commit ee942fc

24 files changed

Lines changed: 278 additions & 759 deletions

‎rdfbean-lucene/pom.xml‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
</parent>
1616

1717
<properties>
18-
<luceneVersion>3.0.0</luceneVersion>
18+
<!-- <luceneVersion>3.0.0</luceneVersion> -->
19+
<compass.version>2.2.0</compass.version>
1920
</properties>
2021

2122
<dependencies>
@@ -25,11 +26,11 @@
2526
<version>${project.parent.version}</version>
2627
</dependency>
2728

28-
<dependency>
29-
<groupId>org.apache.lucene</groupId>
30-
<artifactId>lucene-core</artifactId>
31-
<version>${luceneVersion}</version>
32-
</dependency>
29+
<dependency>
30+
<groupId>org.compass-project</groupId>
31+
<artifactId>compass</artifactId>
32+
<version>2.2.0</version>
33+
</dependency>
3334

3435
<!-- test deps -->
3536
<dependency>
@@ -39,14 +40,7 @@
3940
<type>test-jar</type>
4041
<scope>test</scope>
4142
</dependency>
42-
<!--
43-
<dependency>
44-
<groupId>com.mysema.rdf</groupId>
45-
<artifactId>rdfbean-sesame</artifactId>
46-
<version>${project.version}</version>
47-
<scope>test</scope>
48-
</dependency>
49-
-->
43+
5044
</dependencies>
5145

5246
<build>

‎rdfbean-lucene/src/main/java/com/mysema/rdfbean/lucene/BooleanQueryBuilder.java‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎rdfbean-lucene/src/main/java/com/mysema/rdfbean/lucene/Constants.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ public interface Constants {
2323

2424
String TEXT_FIELD_NAME = "text";
2525

26+
String ALL_FIELD_NAME = "all";
2627
}

‎rdfbean-lucene/src/main/java/com/mysema/rdfbean/lucene/LuceneConfiguration.java‎

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
*/
66
package com.mysema.rdfbean.lucene;
77

8-
import org.apache.lucene.analysis.Analyzer;
9-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
10-
import org.apache.lucene.store.Directory;
11-
import org.apache.lucene.util.Version;
8+
import static org.compass.core.mapping.rsem.builder.RSEM.id;
9+
import static org.compass.core.mapping.rsem.builder.RSEM.property;
10+
import static org.compass.core.mapping.rsem.builder.RSEM.resource;
11+
12+
import org.compass.core.Property.Index;
13+
import org.compass.core.Property.Store;
14+
import org.compass.core.config.CompassConfiguration;
15+
1216

1317
/**
1418
* LuceneConfiguration provides
@@ -17,14 +21,12 @@
1721
* @version $Id$
1822
*/
1923
public class LuceneConfiguration {
20-
21-
private static final Analyzer DEFAULT_ANALYZER = new StandardAnalyzer(Version.LUCENE_30);
22-
24+
2325
private NodeConverter converter = NodeConverter.DEFAULT;
2426

25-
private Analyzer analyzer = DEFAULT_ANALYZER;
27+
private CompassConfiguration compassConfig;
2628

27-
private Directory directory;
29+
private boolean allIndexed = true;
2830

2931
private boolean fullTextIndexed = true;
3032

@@ -48,22 +50,6 @@ public void setStored(boolean stored) {
4850
this.stored = stored;
4951
}
5052

51-
public Analyzer getAnalyzer() {
52-
return analyzer;
53-
}
54-
55-
public void setAnalyzer(Analyzer analyzer) {
56-
this.analyzer = analyzer;
57-
}
58-
59-
public Directory getDirectory() {
60-
return directory;
61-
}
62-
63-
public void setDirectory(Directory directory) {
64-
this.directory = directory;
65-
}
66-
6753
public boolean isFullTextIndexed() {
6854
return fullTextIndexed;
6955
}
@@ -79,7 +65,37 @@ public boolean isContextsStored() {
7965
public void setContextsStored(boolean contextsStored) {
8066
this.contextsStored = contextsStored;
8167
}
82-
83-
68+
69+
public CompassConfiguration getCompassConfig() {
70+
return compassConfig;
71+
}
72+
73+
public void setCompassConfig(CompassConfiguration compassConfig) {
74+
this.compassConfig = compassConfig;
75+
}
76+
77+
public boolean isAllIndexed() {
78+
return allIndexed;
79+
}
80+
81+
public void setAllIndexed(boolean allIndexed) {
82+
this.allIndexed = allIndexed;
83+
}
84+
85+
public void initialize() {
86+
// mapping for general resources
87+
compassConfig.addMapping(
88+
resource("resource")
89+
// if field
90+
.add(id(Constants.ID_FIELD_NAME))
91+
// context data
92+
.add(property(Constants.CONTEXT_FIELD_NAME).store(Store.YES).index(Index.NOT_ANALYZED))
93+
// all field for Object data
94+
.add(property(Constants.ALL_FIELD_NAME).store(Store.NO).index(Index.NOT_ANALYZED))
95+
// full text for String literals
96+
.add(property(Constants.TEXT_FIELD_NAME).store(Store.NO).index(Index.ANALYZED)));
97+
98+
// TODO : rdf:type
99+
}
84100

85101
}

0 commit comments

Comments
 (0)