本文整理汇总了Java中org.apache.lucene.queryParser.QueryParser.setLowercaseExpandedTerms方法的典型用法代码示例。如果您正苦于以下问题:Java QueryParser.setLowercaseExpandedTerms方法的具体用法?Java QueryParser.setLowercaseExpandedTerms怎么用?Java QueryParser.setLowercaseExpandedTerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryParser.QueryParser
的用法示例。
在下文中一共展示了QueryParser.setLowercaseExpandedTerms方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processArgument
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
@Override
protected boolean processArgument(String arg) throws CLIOException {
try {
Analyzer analyzer = PubMedIndexUtils.getGlobalAnalyzer();
QueryParser parser = new QueryParser(PubMedIndexUtils.LUCENE_VERSION, PubMedIndexField.ABSTRACT.fieldName, analyzer);
parser.setDefaultOperator(QueryParser.AND_OPERATOR);
parser.setLowercaseExpandedTerms(false);
PubMedIndexUtils.log("parsing query: %s", arg);
Query q = parser.parse(arg);
PubMedIndexUtils.log("query: %s", q);
addClause(q);
return false;
}
catch (ParseException e) {
throw new CLIOException(e);
}
}
示例2: query
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
Query query( String keyOrNull, Object value, QueryContext contextOrNull )
{
if ( value instanceof Query )
{
return (Query) value;
}
QueryParser parser = new QueryParser( Version.LUCENE_30, keyOrNull, analyzer );
parser.setAllowLeadingWildcard( true );
parser.setLowercaseExpandedTerms( toLowerCase );
if ( contextOrNull != null && contextOrNull.getDefaultOperator() != null )
{
parser.setDefaultOperator( contextOrNull.getDefaultOperator() );
}
try
{
return parser.parse( value.toString() );
}
catch ( ParseException e )
{
throw new RuntimeException( e );
}
}
示例3: getQuery
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
private Query getQuery(SchemaField defaultField, Analyzer analyzer)
throws ParseException {
String queryString = getQueryString();
if (query != null)
if (queryString.equals(cachedQueryString))
return query;
QueryParser queryParser = new QueryParser(Version.LUCENE_36,
defaultField.getName(), analyzer);
queryParser.setLowercaseExpandedTerms(false);
try {
query = queryParser.parse(queryString);
} catch (org.apache.lucene.queryParser.ParseException e) {
throw new ParseException(e);
}
return query;
}
示例4: getQuery
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
protected Query getQuery(SchemaField defaultField, Analyzer analyzer)
throws ParseException {
if (query != null)
return query;
QueryParser queryParser = new QueryParser(Version.LUCENE_36,
defaultField.getName(), analyzer);
queryParser.setLowercaseExpandedTerms(false);
try {
query = queryParser.parse(queryString);
} catch (org.apache.lucene.queryParser.ParseException e) {
throw new ParseException(e);
}
return query;
}
示例5: testPrefixQuery
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
public void testPrefixQuery() throws Exception {
QueryParser parser = new QueryParser(Version.LUCENE_41,
"category",
new StandardAnalyzer(Version.LUCENE_41));
parser.setLowercaseExpandedTerms(false);
LOGGER.info(parser.parse("/Computers/technology*").toString("category"));
}
示例6: testLowercasing
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
public void testLowercasing() throws Exception {
Query q = new QueryParser(Version.LUCENE_41,
"field", analyzer).parse("PrefixQuery*");
assertEquals("lowercased",
"prefixquery*", q.toString("field"));
QueryParser qp = new QueryParser(Version.LUCENE_41,
"field", analyzer);
qp.setLowercaseExpandedTerms(false);
q = qp.parse("PrefixQuery*");
assertEquals("not lowercased",
"PrefixQuery*", q.toString("field"));
}
示例7: search
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
@Test
// 1000 times: 2973 mills.
// 1000 times: 2927 mills.
// 1000 times: 2967 mills.
//
// 10000 times: 21268 mills.
// verified: ok
public void search() throws Exception {
createCommonDaoImpl();
//
FullTextSession fullTextSession = Search.getFullTextSession(sessionFactory.openSession());
// StopAnalyzer 完全相同才能找到資料,同=,無法查中文
// StandardAnalyzer 能找到資料,同like
Analyzer analyzer = new KeywordAnalyzer();
// Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
QueryParser parser = new QueryParser(Version.LUCENE_31, "id", analyzer);
parser.setAllowLeadingWildcard(true);
parser.setLowercaseExpandedTerms(true);
//
// name:Marry
// name:瑪莉
// String search = String.Format("name:{0} AND title:{1}", "中国建设银行",
// "doc1");
StringBuilder lql = new StringBuilder();
// #issue: 大寫找不到???
// lql.append("id:*a*");
// lql.append("audit:*sys*");
lql.append("names:*a*");
org.apache.lucene.search.Query luceneQuery = parser.parse(lql.toString());
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, DogPoImpl.class);
//
List result = null;
int count = 1;
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
result = fullTextQuery.list();
}
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
System.out.println(result.size() + ", " + result);
assertNotNull(result);
}
示例8: doSearch
import org.apache.lucene.queryParser.QueryParser; //导入方法依赖的package包/类
/**
* @see org.olat.lms.search.SearchService#doSearch(String, List, Identity, Roles, int, int, boolean)
*/
public SearchResults doSearch(final String queryString, final List<String> condQueries, final Identity identity, final Roles roles, final int firstResult,
final int maxResults, final boolean doHighlighting) throws ServiceNotAvailableException, QueryException {
synchronized (createIndexSearcherLock) {// o_clusterOK by:fj if service is only configured on one vm, which is recommended way
if (searcher == null) {
log.warn("Index does not exist, can't search for queryString: " + queryString);
throw new ServiceNotAvailableException("Index does not exist");
}
}
try {
log.info("queryString=" + queryString);
final BooleanQuery query = new BooleanQuery();
if (StringHelper.containsNonWhitespace(queryString)) {
final QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_30, fields, analyzer);
queryParser.setLowercaseExpandedTerms(false);// some add. fields are not tokenized and not lowered case
final Query multiFieldQuery = queryParser.parse(queryString.toLowerCase());
query.add(multiFieldQuery, Occur.MUST);
}
if (condQueries != null && !condQueries.isEmpty()) {
for (final String condQueryString : condQueries) {
final QueryParser condQueryParser = new QueryParser(Version.LUCENE_30, condQueryString, analyzer);
condQueryParser.setLowercaseExpandedTerms(false);
final Query condQuery = condQueryParser.parse(condQueryString);
query.add(condQuery, Occur.MUST);
}
}
if (log.isDebugEnabled()) {
log.debug("query=" + query);
}
// TODO: 14.06.2010/cg : fellowig cide fragment can be removed later, do no longer call rewrite(query) because wildcard-search problem (OLAT-5359)
// Query query = null;
// try {
// query = searcher.rewrite(query);
// log.debug("after 'searcher.rewrite(query)' query=" + query);
// } catch (Exception ex) {
// throw new QueryException("Rewrite-Exception query because too many clauses. Query=" + query);
// }
final long startTime = System.currentTimeMillis();
final int n = SearchServiceFactory.getService().getSearchModuleConfig().getMaxHits();
final TopDocs docs = searcher.search(query, n);
final long queryTime = System.currentTimeMillis() - startTime;
if (log.isDebugEnabled()) {
log.debug("hits.length()=" + docs.totalHits);
}
final SearchResultsImpl searchResult = new SearchResultsImpl(mainIndexer, searcher, docs, query, analyzer, identity, roles, firstResult, maxResults,
doHighlighting);
searchResult.setQueryTime(queryTime);
searchResult.setNumberOfIndexDocuments(searcher.maxDoc());
queryCount++;
return searchResult;
} catch (final ParseException pex) {
throw new QueryException("can not parse query=" + queryString);
} catch (final Exception ex) {
log.warn("Exception in search", ex);
throw new ServiceNotAvailableException(ex.getMessage());
}
}