本文整理汇总了Java中org.apache.lucene.util.automaton.RegExp.ALL属性的典型用法代码示例。如果您正苦于以下问题:Java RegExp.ALL属性的具体用法?Java RegExp.ALL怎么用?Java RegExp.ALL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.lucene.util.automaton.RegExp
的用法示例。
在下文中一共展示了RegExp.ALL属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomProvider
public void testCustomProvider() throws IOException {
AutomatonProvider myProvider = new AutomatonProvider() {
// automaton that matches quick or brown
private Automaton quickBrownAutomaton = Operations.union(Arrays
.asList(Automata.makeString("quick"),
Automata.makeString("brown"),
Automata.makeString("bob")));
@Override
public Automaton getAutomaton(String name) {
if (name.equals("quickBrown")) return quickBrownAutomaton;
else return null;
}
};
RegexpQuery query = new RegexpQuery(newTerm("<quickBrown>"), RegExp.ALL,
myProvider, DEFAULT_MAX_DETERMINIZED_STATES);
assertEquals(1, searcher.search(query, 5).totalHits);
}
示例2: testCustomProvider
public void testCustomProvider() throws IOException {
AutomatonProvider myProvider = new AutomatonProvider() {
// automaton that matches quick or brown
private Automaton quickBrownAutomaton = BasicOperations.union(Arrays
.asList(BasicAutomata.makeString("quick"),
BasicAutomata.makeString("brown"),
BasicAutomata.makeString("bob")));
@Override
public Automaton getAutomaton(String name) {
if (name.equals("quickBrown")) return quickBrownAutomaton;
else return null;
}
};
RegexpQuery query = new RegexpQuery(newTerm("<quickBrown>"), RegExp.ALL,
myProvider);
assertEquals(1, searcher.search(query, 5).totalHits);
}
示例3: newRegexpQuery
/**
* Builds a new RegexpQuery instance
* @param regexp Regexp term
* @return new RegexpQuery instance
*/
protected Query newRegexpQuery(Term regexp) {
RegexpQuery query = new RegexpQuery(regexp, RegExp.ALL,
maxDeterminizedStates);
query.setRewriteMethod(multiTermRewriteMethod);
return query;
}
示例4: toLuceneRegexpQuery
private Query toLuceneRegexpQuery(String fieldName, BytesRef value, Context context) {
return new ConstantScoreQuery(
new RegexpQuery(new Term(fieldName, value), RegExp.ALL));
}
示例5: SpanRegexQueryWrapper
public SpanRegexQueryWrapper (String field, String re) {
this(field, re, RegExp.ALL, false);
}
示例6: testQueryRewriteBug
/**
* Query rewrite bug
*
* Warning: This is not armoured by <base/s=t>!
*
* @throws IOException
*/
@Test
public void testQueryRewriteBug () throws IOException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createFieldDoc0()); // ceccecdeec
/*
ki.addDoc(createFieldDoc1()); // bbccdd || only not clause
ki.addDoc(createFieldDoc2()); // beccea | only main clause
*/
ki.commit();
// See /queries/bugs/repetition_group_rewrite
RegexpQuery requery = new RegexpQuery(new Term("base", "s:[ac]"),
RegExp.ALL);
SpanMultiTermQueryWrapper<RegexpQuery> query = new SpanMultiTermQueryWrapper<RegexpQuery>(
requery);
SpanExpansionQuery seq = new SpanExpansionQuery(query, 1, 1, 1, true);
SpanRepetitionQuery rep = new SpanRepetitionQuery(seq, 2, 2, true);
// spanRepetition(
// spanExpansion(
// SpanMultiTermQueryWrapper(base:/s:[ac]/),
// []{1, 1},
// right
// ){2,2}
// )
kr = ki.search(query, (short) 20);
assertEquals(5, kr.getTotalResults());
assertEquals(0, kr.getMatch(0).getStartPos());
assertEquals(1, kr.getMatch(0).getEndPos());
assertEquals(2, kr.getMatch(1).getStartPos());
assertEquals(3, kr.getMatch(1).getEndPos());
assertEquals(3, kr.getMatch(2).getStartPos());
assertEquals(4, kr.getMatch(2).getEndPos());
assertEquals(5, kr.getMatch(3).getStartPos());
assertEquals(6, kr.getMatch(3).getEndPos());
assertEquals(9, kr.getMatch(4).getStartPos());
assertEquals(10, kr.getMatch(4).getEndPos());
kr = ki.search(seq, (short) 20);
assertEquals(5, kr.getTotalResults());
assertEquals(0, kr.getMatch(0).getStartPos());
assertEquals(2, kr.getMatch(0).getEndPos());
assertEquals(2, kr.getMatch(1).getStartPos());
assertEquals(4, kr.getMatch(1).getEndPos());
assertEquals(3, kr.getMatch(2).getStartPos());
assertEquals(5, kr.getMatch(2).getEndPos());
assertEquals(5, kr.getMatch(3).getStartPos());
assertEquals(7, kr.getMatch(3).getEndPos());
assertEquals(9, kr.getMatch(4).getStartPos());
assertEquals(11, kr.getMatch(4).getEndPos());
kr = ki.search(rep, (short) 20);
// for (Match km : kr.getMatches()){
// System.out.println(
// km.getStartPos() +
// "," +
// km.getEndPos() +
// " " +
// km.getSnippetBrackets()
// );
// };
assertEquals("[[cecc]]ecdeec", kr.getMatch(0).getSnippetBrackets());
assertEquals("cec[[cecd]]eec", kr.getMatch(1).getSnippetBrackets());
assertEquals((long) 2, kr.getTotalResults());
}
示例7: RegexpQuery
/**
* Constructs a query for terms matching <code>term</code>.
* <p>
* By default, all regular expression features are enabled.
* </p>
*
* @param term regular expression.
*/
public RegexpQuery(Term term) {
this(term, RegExp.ALL);
}
示例8: newRegexpQuery
/**
* Builds a new RegexpQuery instance
*
* @param regexp
* Regexp term
* @return new RegexpQuery instance
*/
protected Query newRegexpQuery(Term regexp) {
RegexpQuery query = new RegexpQuery(regexp, RegExp.ALL, maxDeterminizedStates);
query.setRewriteMethod(multiTermRewriteMethod);
return query;
}