Package org.apache.lucene.queryParser

Examples of org.apache.lucene.queryParser.QueryParser$JJCalls


        StringTokenizer st = new StringTokenizer(params.getSearchKey());
        while(st.hasMoreElements()){
          String q = st.nextToken();
      String[] indexFields = searching.getIndexFields();
      for(int i=0;i<indexFields.length;i++){
        QueryParser qp = new QueryParser(indexFields[i], analyzer);
        try{
          Query subjectQuery = qp.parse(q);
          comboQuery.add(subjectQuery, BooleanClause.Occur.SHOULD);
          _query_count ++;
        }catch(Exception e){
          log.error("Add query parameter failed. key="+q, e);
        }
View Full Code Here


            // take a reference as the searcher may change
            Searcher searcher = access.searcher;
            // reuse the same analyzer; it's thread-safe;
            // also allows subclasses to control the analyzer used.
            Analyzer analyzer = access.writer.getAnalyzer();
            QueryParser parser = new QueryParser(Version.LUCENE_30,
                    LUCENE_FIELD_DATA, analyzer);
            Query query = parser.parse(text);
            // Lucene 3 insists on a hard limit and will not provide
            // a total hits value. Take at least 100 which is
            // an optimal limit for Lucene as any more
            // will trigger writing results to disk.
            int maxResults = (limit == 0 ? 100 : limit) + offset;
View Full Code Here

  }
 
  public void testQueryWithScore() throws Exception{
    BrowseRequest br=new BrowseRequest();
    br.setShowExplanation(false)// default
      QueryParser parser=new QueryParser(Version.LUCENE_29,"color",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("color:red OR shape:square"));
        br.setCount(10);
        br.setOffset(0);
       
        br.setSort(new SortField[]{SortField.FIELD_SCORE});
        BrowseResult res = doTest(br,4,null,new String[]{"1","7","2","5"});
View Full Code Here

  }

  public void testBrowseWithQuery(){
    try{
      BrowseRequest br=new BrowseRequest();
      QueryParser parser=new QueryParser(Version.LUCENE_29,"shape",new StandardAnalyzer(Version.LUCENE_29));
      br.setQuery(parser.parse("square OR circle"));
        br.setCount(10);
        br.setOffset(0);
       
        BrowseSelection sel=new BrowseSelection("color");
        sel.addValue("red");
View Full Code Here

//    System.out.println("request after conversion to msg:\n" + req.toString());
    String reqString = TextFormat.printToString(req);
    reqString = reqString.replace('\r', ' ').replace('\n', ' ');
//    System.out.println(reqString);
    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
    QueryParser _qparser = new QueryParser(Version.LUCENE_CURRENT,"", analyzer);
//    System.out.println("msg to req");
    BrowseRequest boboReqAfter = BrowseProtobufConverter.convert(req, _qparser);
//    System.out.println("get query 2: "
//        + (boboReqAfter.getQuery() != null ? boboReqAfter.getQuery().getClass()
//            : "null query"));
View Full Code Here

  }
 
  static void doBrowse(BoboBrowser browser) throws Exception
  {
    String q="java";
    QueryParser parser=new QueryParser(Version.LUCENE_CURRENT,"b",new StandardAnalyzer(Version.LUCENE_CURRENT));
    Query query=parser.parse(q);
    BrowseRequest br=new BrowseRequest();
    //br.setQuery(query);
    br.setOffset(0);
    br.setCount(0);
View Full Code Here

          }
        }
 
        // Check whether the document is in the index
        Analyzer analyzer = new WhitespaceAnalyzer();
        QueryParser parser = new QueryParser(Version.LUCENE_30, "url", analyzer);
        String queryString = "\"" + transformedFileUrl + "\"";
       
        try {
          query = parser.parse(queryString);
        } catch (ParseException ex) {
          throw new RegainException("Parsing of url lookup-query failed.", ex);
        }
       
        ScoreDoc[] hits = manager.search(query);
View Full Code Here

          for (int k = 0; k < indexConfigs.length; k++) {

            String[] searchFieldArr = indexConfigs[k].getSearchFieldList();
            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

    IndexSearcher searcher = null;
    try {
      File directory = searchIndexManager.getIndexDirectory();
      searcher = new IndexSearcher(IndexReader.open(directory));
      Analyzer analyzer = DocumentCreator.createDocumentAnalyzer();
      QueryParser parser = new QueryParser(DocumentCreator.FIELD_TEXT,analyzer);
      Hits hits = searcher.search(parser.parse(query));
      List<BookmarkDoc> bmDocs = new ArrayList<BookmarkDoc>();
      if (offset >= 0 && offset < hits.length()) {
        if (count > 0) {         
          for (int i = offset; i < hits.length() && bmDocs.size() < count; i++) {
            BookmarkDoc doc = createBookmarkDoc(hits.doc(i));
View Full Code Here

    IndexSearcher searcher = null;
    try {
      File directory = searchIndexManager.getIndexDirectory();
      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

TOP

Related Classes of org.apache.lucene.queryParser.QueryParser$JJCalls

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.