Package org.apache.lucene.index

Examples of org.apache.lucene.index.Term


     *      match.
     */
    public FieldFilter(String field, String [] values) {
        searchTerms = new Term[values.length];
        for (int i=0; i<values.length; i++) {
            searchTerms[i] = new Term(field, values[i]);
        }
    }
View Full Code Here


    addIndex();
    IndexReader reader = IndexReader.open(lucenePath);
    System.out.println("�ĵ���:"+reader.numDocs());
    TermEnum tes = reader.terms();
    while(tes.next()){
      Term t = tes.term();
      System.out.println(t.toString());
    }
    //IndexSearcher searcher = new IndexSearcher(lucenePath);
  }
View Full Code Here

   
    IndexReader reader = null;
    try{
      reader = getReader(doc.name())
      String pvalue = getField(doc, doc.getKeywordField());
      Term keyTerm = new Term(doc.getKeywordField(), pvalue);
      return reader.deleteDocuments(keyTerm);
    }catch(Exception e){
      log.error("Error where delete index of "+ doc, e);
    }finally{
      if(reader!=null)
View Full Code Here

    else {
      BooleanQuery classFilter = new BooleanQuery();
      //annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
      classFilter.setBoost( 0 );
      for (Class clazz : classesAndSubclasses) {
        Term t = new Term( DocumentBuilder.CLASS_FIELDNAME, clazz.getName() );
        TermQuery termQuery = new TermQuery( t );
        classFilter.add( termQuery, BooleanClause.Occur.SHOULD );
      }
      BooleanQuery filteredQuery = new BooleanQuery();
      filteredQuery.add( luceneQuery, BooleanClause.Occur.MUST );
View Full Code Here

         * @param row the row
         */
        protected void delete(Object[] row) throws SQLException {
            String query = getQuery(row);
            try {
                Term term = new Term(LUCENE_FIELD_QUERY, query);
                /*## LUCENE2 begin ##
                indexAccess.modifier.deleteDocuments(term);
                ## LUCENE2 end ##*/
                //## LUCENE3 begin ##
                indexAccess.writer.deleteDocuments(term);
View Full Code Here

          new String[] { "name", "lyric" }, new StandardAnalyzer());
      Query query;
      query = parser.parse(condition);
      booleanQuery.add(query, BooleanClause.Occur.MUST);
      if(artistCityId != null){
        TermQuery tq = new TermQuery(new Term("artistCityId", artistCityId));
        booleanQuery.add(tq, BooleanClause.Occur.MUST);
      }
      org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(
          booleanQuery, Song.class);
      return hibQuery.list();
View Full Code Here

        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone(DroneConfig.getTimezone()));
        cal.setTime(parsed);

        Term begin = new Term("moment", DateField.dateToString(cal.getTime()));

        cal.set(Calendar.HOUR, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        Term end = new Term("moment", DateField.dateToString(cal.getTime()));

        query.add(new RangeQuery(begin, end, true), true, false);
      }
      catch (Exception e)
      {
        bean.addValidationError(new ValidationError.WRONGFORMAT("date"));
      }
    }

    boolean beginDatePresent = (bean.getBeginDate() != null && !bean.getBeginDate().equals(""));
    boolean endDatePresent = (bean.getEndDate() != null && !bean.getEndDate().equals(""));

    if (beginDatePresent && endDatePresent)
    {
      String beginDateFormatted = null;
      String endDateFormatted = null;
      try
      {
        Date beginDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getBeginDate());
        Date endDateParsed = Search.INPUT_DATE_FORMAT_SHORT.parse(bean.getEndDate());

        Calendar cal = Calendar.getInstance();
        cal.setTime(endDateParsed);

        cal.set(Calendar.HOUR, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);

        beginDateFormatted = DateField.dateToString(beginDateParsed);
        endDateFormatted = DateField.dateToString(cal.getTime());
      }
      catch (ParseException e)
      {
        bean.addValidationError(new ValidationError.WRONGFORMAT("beginDate"));
        bean.addValidationError(new ValidationError.WRONGFORMAT("endDate"));
      }

      if (bean.getValidationErrors().size() == 0)
      {
        Term begin = new Term("moment", beginDateFormatted);
        Term end = new Term("moment", endDateFormatted);

        query.add(new RangeQuery(begin, end, true), true, false);
      }
    }
    else if (!beginDatePresent && !endDatePresent)
View Full Code Here

      doTest(br,3,null,new String[]{"2","1","7"});
      br.setSort(new SortField[]{new SortField("name",SortField.STRING,false)});
      doTest(br,3,null,new String[]{"7","2","1"});
     
      sel.addValue("blue");
      br.setQuery(new TermQuery(new Term("shape","square")));
      br.setSort(new SortField[]{new SortField("number",SortField.CUSTOM,true)});
      doTest(br,3,null,new String[]{"5","1","7"});
      br.setSort(new SortField[]{new SortField("name",SortField.STRING,false)});
      doTest(br,3,null,new String[]{"7","1","5"});
  }
View Full Code Here

    doTest(br, 3, answer, new String[] {"1", "2", "7"});

    try
    {
      reader = newIndexReader(false);
      reader.deleteDocuments(new Term("id", "1"));
      reader.deleteDocuments(new Term("id", "2"));
     
      br = new BrowseRequest();
      br.setCount(10);
      br.setOffset(0);
View Full Code Here

      reader = (BoboIndexReader)boboReader.reopen();
      assertNotSame(boboReader, reader);
      assertEquals(numDocs+1,reader.numDocs());
      boboReader = reader;
    }
    writer.deleteDocuments(new Term("id","1"));
    writer.commit();
    int numDocs = boboReader.numDocs();
    BoboIndexReader newReader = (BoboIndexReader)boboReader.reopen();
    assertNotSame(newReader,boboReader);
    int numDocs2 = newReader.numDocs();
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.Term

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.