Skip to content

Commit

Permalink
Use TermsFilter for lucene test queries. This should be faster and al…
Browse files Browse the repository at this point in the history
…so fixes the unit tests.

Revert the default property cardinality to single.
  • Loading branch information
BrynCooke committed Apr 13, 2015
1 parent 40ae31f commit 6deeea7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Expand Up @@ -102,7 +102,7 @@ public TitanVertex addVertex(Object... keyValues) {
} }


final TitanVertex vertex = addVertex(null,label); final TitanVertex vertex = addVertex(null,label);
ElementHelper.attachProperties(vertex, VertexProperty.Cardinality.list, keyValues); ElementHelper.attachProperties(vertex, VertexProperty.Cardinality.single, keyValues);
return vertex; return vertex;
} }


Expand Down
Expand Up @@ -47,6 +47,7 @@
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;


/** /**
* @author Matthias Broecheler (me@matthiasb.com) * @author Matthias Broecheler (me@matthiasb.com)
Expand All @@ -60,12 +61,12 @@ public class LuceneIndex implements IndexProvider {
private static final String GEOID = "_____geo"; private static final String GEOID = "_____geo";
private static final int MAX_STRING_FIELD_LEN = 256; private static final int MAX_STRING_FIELD_LEN = 256;


private static final Version LUCENE_VERSION = Version.LUCENE_41; private static final Version LUCENE_VERSION = Version.LUCENE_4_10_4;
private static final IndexFeatures LUCENE_FEATURES = new IndexFeatures.Builder().supportedStringMappings(Mapping.TEXT, Mapping.STRING).build(); private static final IndexFeatures LUCENE_FEATURES = new IndexFeatures.Builder().supportedStringMappings(Mapping.TEXT, Mapping.STRING).build();


private static final int GEO_MAX_LEVELS = 11; private static final int GEO_MAX_LEVELS = 11;


private final Analyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); private final Analyzer analyzer = new StandardAnalyzer();


private final Map<String, IndexWriter> writers = new HashMap<String, IndexWriter>(4); private final Map<String, IndexWriter> writers = new HashMap<String, IndexWriter>(4);
private final ReentrantLock writerLock = new ReentrantLock(); private final ReentrantLock writerLock = new ReentrantLock();
Expand Down Expand Up @@ -444,11 +445,9 @@ private final SearchParams convertQuery(Condition<?> condition, KeyInformation.S


if (titanPredicate == Text.CONTAINS) { if (titanPredicate == Text.CONTAINS) {
value = ((String) value).toLowerCase(); value = ((String) value).toLowerCase();
BooleanFilter b = new BooleanFilter(); List<String> terms = Text.tokenize((String) value);
for (String term : Text.tokenize((String)value)) { TermsFilter termsFilter = new TermsFilter(terms.stream().map(s->new Term(key, s)).collect(Collectors.toList()));
b.add(new TermsFilter(new Term(key, term)), BooleanClause.Occur.MUST); params.addFilter(termsFilter);
}
params.addFilter(b);
} else if (titanPredicate == Text.CONTAINS_PREFIX) { } else if (titanPredicate == Text.CONTAINS_PREFIX) {
value = ((String) value).toLowerCase(); value = ((String) value).toLowerCase();
params.addFilter(new PrefixFilter(new Term(key, (String) value))); params.addFilter(new PrefixFilter(new Term(key, (String) value)));
Expand Down

0 comments on commit 6deeea7

Please sign in to comment.