當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryParser.setLowercaseExpandedTerms方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:Bibliome,項目名稱:bibliome-java-utils,代碼行數:18,代碼來源:PubMedIndexSearcher.java

示例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 );
    }
}
 
開發者ID:neo4j-contrib,項目名稱:neo4j-mobile-android,代碼行數:24,代碼來源:IndexType.java

示例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;
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:17,代碼來源:RelativeDateFilter.java

示例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;
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:15,代碼來源:QueryFilter.java

示例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"));
}
 
開發者ID:xuzhikethinker,項目名稱:t4f-data,代碼行數:8,代碼來源:QueryParserTest.java

示例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"));
}
 
開發者ID:xuzhikethinker,項目名稱:t4f-data,代碼行數:14,代碼來源:QueryParserTest.java

示例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);
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:51,代碼來源:CommonDaoImplWithoutSpringTest.java

示例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());
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:65,代碼來源:Index.java


注:本文中的org.apache.lucene.queryParser.QueryParser.setLowercaseExpandedTerms方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。