Package org.apache.lucene.index

Examples of org.apache.lucene.index.Term


                    new StandardAnalyzer().tokenStream(null, new StringReader(escape(terms).toLowerCase()));

            while (true) {
                Token t = includeStream.next();
                if (t == null) break;
                query.add( new Term(fieldName, t.termText()) );
            }

            return query.getTerms().length > 0 ? query : null;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
View Full Code Here


    private Query buildTermQuery(String fieldName, String terms) {
        String[] termsArray = escape(terms).toLowerCase().split("\\s"); // Just split user input by whitespace
        if (termsArray.length > 1) {
            BooleanQuery query = new BooleanQuery();
            for (String s: termsArray) {
                TermQuery termQuery = new TermQuery(new Term(fieldName, s) );
                query.add(termQuery, BooleanClause.Occur.SHOULD);
            }
            return query.getClauses().length > 0 ? query : null;
        } else {
            return termsArray.length != 0 ? new TermQuery(new Term(fieldName, termsArray[0])) : null;
        }
    }
View Full Code Here

    MailRecord[] aRetArr;

  BooleanQuery oFld = new BooleanQuery();
  for (int f=0; f<aFolderName.length; f++)
    oFld.add(new TermQuery(new Term("container",aFolderName[f])),BooleanClause.Occur.SHOULD);

  BooleanQuery oQry = new BooleanQuery();

  oQry.add(new TermQuery(new Term("workarea",sWorkArea)),BooleanClause.Occur.MUST);
    oQry.add(oFld, BooleanClause.Occur.MUST);

    if (null!=sSender)
      oQry.add(new TermQuery(new Term("author",Gadgets.ASCIIEncode(sSender))),BooleanClause.Occur.MUST);
    
    if (null!=sRecipient)
      oQry.add(new TermQuery(new Term("recipients",sRecipient)),BooleanClause.Occur.MUST);
     
    if (null!=sSubject)
      oQry.add(new TermQuery(new Term("title",Gadgets.ASCIIEncode(sSubject))),BooleanClause.Occur.MUST);
  
    if (dtFromDate!=null && dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtFromDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(dtFromDate, DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(new Date(299,11,31), DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);   
    else if (dtToDate!=null)
    oQry.add(new RangeQuery(new Term("created",DateTools.dateToString(new Date(79,11,31), DateTools.Resolution.DAY)),
                  new Term("created",DateTools.dateToString(dtToDate, DateTools.Resolution.DAY)), true), BooleanClause.Occur.MUST);

    if (null!=sText)
      oQry.add(new TermQuery(new Term("text",sText)),BooleanClause.Occur.SHOULD);

  String sSegments = Gadgets.chomp(sLuceneIndexPath,File.separator)+"k_mime_msgs"+File.separator+sWorkArea; 
    if (DebugFile.trace) DebugFile.writeln("new IndexSearcher("+sSegments+")");
    IndexSearcher oSearch = new IndexSearcher(sSegments);
View Full Code Here

        log.info("befor delete: indexReader.numDocs()=" + indexReader.numDocs());
        // 2. Delete old Document
        // loop over all documents in updateQueue
        for (int i = 0; i < updateCopy.size(); i++) {
          String resourceUrl = updateCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
          log.info("updateQueue:delete documents with resourceUrl=" + resourceUrl );
          indexReader.deleteDocuments(term);         
        }
        // loop over all documents in deleteQueue
        for (int i = 0; i < deleteCopy.size(); i++) {
          String resourceUrl = deleteCopy.get(i).get(OlatDocument.RESOURCEURL_FIELD_NAME);
          Term term = new Term(OlatDocument.RESOURCEURL_FIELD_NAME, resourceUrl );
          log.info("deleteQueue:delete documents with resourceUrl='" + resourceUrl + "'");
          indexReader.deleteDocuments(term);
         
        }
        log.info("after delete: indexReader.numDocs()=" + indexReader.numDocs());
View Full Code Here

    if(field == null){
      throw new IllegalArgumentException("parameter \"field\" is null");
    }

    if(query == null || "".equals(query.trim())){
      return new TermQuery(new Term(field));
    }
   
    //从缓存中取出已经解析的query生产的TokenBranch
    TokenBranch root = getCachedTokenBranch(query);
    if(root != null){
View Full Code Here

     */
    List<Query> toQueries(String fieldName){     
      List<Query> queries = new ArrayList<Query>(1);     
       //生成当前branch 的query
      if(lexeme != null){
        queries.add(new TermQuery(new Term(fieldName , lexeme.getLexemeText())));
      }     
      //生成child branch 的query
      if(acceptedBranchs != null && acceptedBranchs.size() > 0){
        if(acceptedBranchs.size() == 1){
          Query onlyOneQuery = optimizeQueries(acceptedBranchs.get(0).toQueries(fieldName));
View Full Code Here

          Element e3 = this.elements.get(i + 2);
          //处理 = 和 : 运算
          if('\'' == e3.type){
            i+=2;
            if('=' == e2.type){
              TermQuery tQuery = new TermQuery(new Term(e.toString() , e3.toString()));
              this.querys.push(tQuery);
            }else if(':' == e2.type){
              String keyword = e3.toString();
              if(keyword.startsWith("^") && keyword.endsWith("$")){
                Query pQuery = this.luceneQueryParse(e.toString(), keyword);
View Full Code Here

    {
        if (!create)
        {                 // incrementally update

            reader = IndexReader.open(index);         // open existing index
            uidIter = reader.terms(new Term("uid", "")); // init uid iterator

            indexDocs(file);

            if (deleting)
            {                 // delete rest of stale docs
View Full Code Here

     * @param value the value of the field that search results must match.
     */
    public FieldFilter(String field, String value) {
        this.field = field;
        this.value = value;
        searchTerm = new Term(field, value);
    }
View Full Code Here

            // logger.info("adding doc to"+indexName);

            if (logger.isDebugEnabled())
                logger.debug("Adding " + shardedId + " to " + indexName);

            Term idTerm = this.idTerm.createTerm(cmd.indexedId);

            if (isUpdate)
            {
                writer.updateDocument(indexName, idTerm, cmd.getLuceneDocument(schema), schema.getAnalyzer(),
                        shardedId, false);
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.