Package org.apache.lucene.queryParser

Examples of org.apache.lucene.queryParser.MultiFieldQueryParser


    int arraySize = fields.size();
    fieldsArray = new String[arraySize];
    for (int ii = 0; ii < arraySize; ii++) {
      fieldsArray[ii] = (String) fields.get(ii);
    }
    MultiFieldQueryParser parser = new MultiFieldQueryParser(fieldsArray, analyzer);
    query = parser.parse(queryString);
    System.out.println("Searching for: " + query.toString());
    Hits hits = searcher.search(query);
    return (hits);

  }
View Full Code Here


    int arraySize = indexedFields.size();
    String indexedArray[] = new String[arraySize];
    for (int ii = 0; ii < arraySize; ii++) {
      indexedArray[ii] = (String) indexedFields.get(ii);
    }
    MultiFieldQueryParser parser = new MultiFieldQueryParser(indexedArray, analyzer);
    query = parser.parse(queryString);
    System.out.println("Searching for: " + query.toString());
    return (query);

  }
View Full Code Here

    int arraySize = fields.size();
    fieldsArray = new String[arraySize];
    for (int ii = 0; ii < arraySize; ii++) {
      fieldsArray[ii] = (String) fields.get(ii);
    }
    MultiFieldQueryParser parser = new MultiFieldQueryParser(fieldsArray, analyzer);
    query = parser.parse(queryString);
    System.out.println("Searching for: " + query.toString());
    Hits hits = searcher.search(query);
    return (hits);

  }
View Full Code Here

            }

            //build a query based on the fields, searchString and cached analyzer
            //NOTE: This is an area for improvement since the MultiFieldQueryParser
            // has some weirdness.
            MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
            Query query = parser.parse(searchString);
            //run the search
            Hits hits = is.search(query);
            //reset this table model with the new results
            resetSearchResults(hits);
        } catch (Exception e){
View Full Code Here

            String[] fields = {FIELD_NAME};

            //build a query based on the fields, searchString and cached analyzer
            //NOTE: This is an area for improvement since the MultiFieldQueryParser
            // has some weirdness.
            MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
            Query query =parser.parse(searchString);
            //run the search
            Hits hits = is.search(query);
            //reset this list model with the new results
            resetSearchResults(hits);
        } catch (Exception e){
View Full Code Here

          Binding.artifact().artifactId().getPath(),
          Binding.artifact().group().groupId().getPath()
      };
      Analyzer analyzer = Search.getFullTextEntityManager(getEntityManager()).getSearchFactory().getAnalyzer(Artifact.class);
     
      MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_36, fields, analyzer);
      parser.setDefaultOperator(MultiFieldQueryParser.AND_OPERATOR);

      BooleanQuery booleanQuery = new BooleanQuery();
      booleanQuery.add(parser.parse(searchTerm), BooleanClause.Occur.MUST);
     
      booleanJunction.must(booleanQuery);
    } catch (ParseException e) {
      throw new ServiceException(String.format("Error parsing request: %1$s", searchTerm), e);
    }
View Full Code Here

    SortField sf = new SortField(sortProperty, SortField.STRING, reverse);
    logger.info("searchText:" + searchText);
    Query query = new QueryParser(Version.LUCENE_34, field, analyzer).parse(entityName);
    if(searchText != null && !searchText.equals(""))
    {
      MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_34, new String[]{field, "contents"}, analyzer);
      mfqp.setDefaultOperator(MultiFieldQueryParser.AND_OPERATOR);
      query = mfqp.parse(entityName + " " + searchText + "*");
    }
   
    logger.info("query" + query);
   
    TopFieldDocs topDocs = searcher.search(query, (Filter) null, 1000000, new Sort(sf));
View Full Code Here

  }

  private org.apache.lucene.search.Query createFullTextQuery(final String[] searchFields, final QueryFilter queryFilter,
      final String searchString)
  {
    final MultiFieldQueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, searchFields, new ClassicAnalyzer(Version.LUCENE_31));
    parser.setAllowLeadingWildcard(true);
    org.apache.lucene.search.Query query = null;
    try {
      query = parser.parse(searchString);
    } catch (final org.apache.lucene.queryParser.ParseException ex) {
      final String errorMsg = "Lucene error message: "
          + ex.getMessage()
          + " (for "
          + this.getClass().getSimpleName()
View Full Code Here

  }

  public SearchResult<AgencyAndId> searchForStopsByCode(String id,
      int maxResultCount, double minScoreToKeep) throws IOException,
      ParseException {
    return search(new MultiFieldQueryParser(CODE_FIELDS, _analyzer), id,
        maxResultCount, minScoreToKeep);
  }
View Full Code Here

  }

  public SearchResult<AgencyAndId> searchForStopsByName(String name,
      int maxResultCount, double minScoreToKeep) throws IOException,
      ParseException {
    return search(new MultiFieldQueryParser(NAME_FIELDS, _analyzer), name,
        maxResultCount, minScoreToKeep);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.MultiFieldQueryParser

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.