Add wildcardQuery, optimize parallel queries
This commit is contained in:
parent
050d77d359
commit
9a4e0d53d3
@ -83,6 +83,12 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
120,
|
||||
true
|
||||
);
|
||||
/**
|
||||
* Lucene query scheduler.
|
||||
*/
|
||||
private final Scheduler luceneQueryScheduler = Schedulers.newBoundedElastic(Runtime
|
||||
.getRuntime()
|
||||
.availableProcessors(), Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE, "LuceneQuery", 120, true);
|
||||
|
||||
private final String luceneIndexName;
|
||||
private final SnapshotDeletionPolicy snapshotter;
|
||||
@ -408,7 +414,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
//noinspection BlockingMethodInNonBlockingContext
|
||||
return mlt.like((Map) mltDocumentFields);
|
||||
})
|
||||
.subscribeOn(luceneBlockingScheduler)
|
||||
.subscribeOn(luceneQueryScheduler)
|
||||
.flatMap(mltQuery -> Mono
|
||||
.fromCallable(() -> {
|
||||
Query luceneQuery;
|
||||
@ -431,7 +437,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
new Sort(SortField.FIELD_SCORE),
|
||||
ScoreMode.TOP_SCORES
|
||||
);
|
||||
}).subscribeOn(luceneBlockingScheduler)
|
||||
}).subscribeOn(luceneQueryScheduler)
|
||||
)
|
||||
.materialize()
|
||||
.flatMap(signal -> {
|
||||
@ -485,7 +491,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
org.apache.lucene.search.ScoreMode luceneScoreMode = LLUtils.toScoreMode(scoreMode);
|
||||
return Tuples.of(luceneQuery, Optional.ofNullable(luceneSort), luceneScoreMode);
|
||||
})
|
||||
.subscribeOn(luceneBlockingScheduler)
|
||||
.subscribeOn(luceneQueryScheduler)
|
||||
.flatMap(tuple -> Mono
|
||||
.fromCallable(() -> {
|
||||
Query luceneQuery = tuple.getT1();
|
||||
@ -502,7 +508,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
luceneSort,
|
||||
luceneScoreMode
|
||||
);
|
||||
}).subscribeOn(luceneBlockingScheduler)
|
||||
}).subscribeOn(luceneQueryScheduler)
|
||||
)
|
||||
.materialize()
|
||||
.flatMap(signal -> {
|
||||
|
@ -9,6 +9,7 @@ public enum QueryConstructorType {
|
||||
INT_POINT_EXACT_QUERY,
|
||||
LONG_POINT_EXACT_QUERY,
|
||||
TERM_QUERY,
|
||||
WILDCARD_QUERY,
|
||||
DOC_VALUES_FIELD_EXISTS_QUERY,
|
||||
FUZZY_QUERY,
|
||||
PHRASE_QUERY,
|
||||
|
@ -20,6 +20,7 @@ import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SynonymQuery;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.WildcardQuery;
|
||||
|
||||
public class QueryParser {
|
||||
|
||||
@ -191,6 +192,10 @@ public class QueryParser {
|
||||
Term term2 = (Term) parse(completeText, position);
|
||||
assert term2 != null;
|
||||
return new TermQuery(term2);
|
||||
case WILDCARD_QUERY:
|
||||
Term term3 = (Term) parse(completeText, position);
|
||||
assert term3 != null;
|
||||
return new WildcardQuery(term3);
|
||||
case DOC_VALUES_FIELD_EXISTS_QUERY:
|
||||
String fieldKey = (String) parse(completeText, position);
|
||||
assert fieldKey != null;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package it.cavallium.dbengine.lucene.serializer;
|
||||
|
||||
import it.cavallium.dbengine.database.LLTerm;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
||||
public class TermQuery implements Query {
|
||||
@ -10,6 +11,10 @@ public class TermQuery implements Query {
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
public TermQuery(LLTerm term) {
|
||||
this.term = new Term(term.getKey(), term.getValue());
|
||||
}
|
||||
|
||||
public TermQuery(String name, String val) {
|
||||
this.term = new Term(name, val);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package it.cavallium.dbengine.lucene.serializer;
|
||||
|
||||
import it.cavallium.dbengine.database.LLTerm;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
||||
public class WildcardQuery implements Query {
|
||||
|
||||
private final Term term;
|
||||
|
||||
public WildcardQuery(Term term) {
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
public WildcardQuery(LLTerm term) {
|
||||
this.term = new Term(term.getKey(), term.getValue());
|
||||
}
|
||||
|
||||
public WildcardQuery(String name, String val) {
|
||||
this.term = new Term(name, val);
|
||||
}
|
||||
|
||||
public Term getTerm() {
|
||||
return term;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stringify(StringBuilder output) {
|
||||
StringBuilder data = new StringBuilder();
|
||||
StringifyUtils.stringifyTerm(data, term);
|
||||
StringifyUtils.writeHeader(output, QueryConstructorType.WILDCARD_QUERY, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + term.field() + ":" + term.text() + ")";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user