Package org.apache.lucene.search

Examples of org.apache.lucene.search.Query


            for (int i = 0; i < searchFieldArr.length; i++) {

              QueryParser parser = new QueryParser(Version.LUCENE_30, searchFieldArr[i], mAnalyzer);
              parser.setDefaultOperator(QueryParser.AND_OPERATOR);
              parser.setAllowLeadingWildcard(true);
              Query fieldQuery = parser.parse(queryText);

              // Add as OR
              mQuery.add(fieldQuery, Occur.SHOULD);
            }
            //System.out.println("Query: '" + queryText + "' -> '" + mQuery.toString() + "'");
View Full Code Here


  public void highlightHitDocument(int index) throws RegainException {

    try {
      IndexSearcherManager manager = IndexSearcherManager.getInstance(mIndexConfig.getDirectory());
      // The highlighter needs a rewritten query to work with wildcard and fuzzy queries
      Query rewrittenQuery = manager.rewrite(mQuery);
      QueryScorer queryScorer = new QueryScorer(rewrittenQuery);
      // End added by Anders

      Highlighter highlighter = new Highlighter(
              new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>"), queryScorer);
View Full Code Here

      searcher = new IndexSearcher(IndexReader.open(directory));
      Analyzer analyzer = DocumentCreator.createDocumentAnalyzer();
      QueryParser parser = new QueryParser(DocumentCreator.FIELD_TEXT,analyzer);
     
      TermQuery matchUserQuery = new TermQuery(new Term(DocumentCreator.FIELD_USER,username));
      Query inputQuery = parser.parse(query);
      BooleanQuery boolQuery = new BooleanQuery();
      boolQuery.add(matchUserQuery, BooleanClause.Occur.MUST);
      boolQuery.add(inputQuery,BooleanClause.Occur.MUST);
     
      Hits hits = searcher.search(boolQuery);
View Full Code Here

                     int start) throws BrowseException
  {
    Weight w = null;
    try
    {
      Query q = req.getQuery();
      if (q == null)
      {
        q = new MatchAllDocsQuery();
      }
      w = createWeight(q);
View Full Code Here

    catch (IOException e){
      logger.error(e.getMessage(), e);
      hits = new BrowseHit[0];
    }
   
    Query q = req.getQuery();
    if (q == null){
      q = new MatchAllDocsQuery();
    }
    if (req.isShowExplanation()){
      for (BrowseHit hit : hits){
View Full Code Here

    BrowseRequest breq = new BrowseRequest();
    String query = req.getQuery();
   
    if (qparser!=null && query!=null && query.length() > 0){
      try{
        Query q = qparser.parse(query);
        breq.setQuery(q);
      }
      catch(Exception e){
        throw new ParseException(e.getMessage());
      }
View Full Code Here

    }
    return selBuilder.build();
  }
 
  public static BrowseRequestBPO.Request convert(BrowseRequest req){
    Query q = req.getQuery();
    String qString = null;
    if (q!=null){
      if (q instanceof MatchAllDocsQuery)
        qString = "*:*";
      else
        qString = q.toString();
    }
   
    BrowseRequestBPO.Request.Builder reqBuilder = BrowseRequestBPO.Request.newBuilder();
    reqBuilder.setOffset(req.getOffset());
    reqBuilder.setCount(req.getCount());
View Full Code Here

    _allFacetHandlerMap = null;
  }
 
  private boolean isNoQueryNoFilter(BrowseRequest req)
  {
    Query q = req.getQuery();
    Filter filter = req.getFilter();
    return ((q == null || q instanceof MatchAllDocsQuery) && filter == null && !_reader.hasDeletions());
  }
View Full Code Here

                     int start) throws BrowseException
  {
    Weight w = null;
    try
    {
      Query q = req.getQuery();
      if (q == null)
      {
        q = new MatchAllDocsQuery();
      }
      w = createWeight(q);
View Full Code Here

      try
      {
        if (weight == null)
        {
          Query q = req.getQuery();
          if (q==null)
          {
            q = new MatchAllDocsQuery();
          }
          weight = createWeight(q);
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.