Examples of TermQuery


Examples of org.apache.lucene.search.TermQuery

          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

Examples of org.apache.lucene.search.TermQuery

    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

Examples of org.apache.lucene.search.TermQuery

     */
    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

Examples of org.apache.lucene.search.TermQuery

      addDoc(modifier, ++id, value);
      if (0 == t)
        modifier.deleteDocuments(new Term("value", String.valueOf(value)));
      else
        modifier.deleteDocuments(new TermQuery(new Term("value", String.valueOf(value))));
      addDoc(modifier, ++id, value);
      if (0 == t) {
        modifier.deleteDocuments(new Term("value", String.valueOf(value)));
        assertEquals(2, modifier.getNumBufferedDeleteTerms());
        assertEquals(1, modifier.getBufferedDeleteTermsSize());
      }
      else
        modifier.deleteDocuments(new TermQuery(new Term("value", String.valueOf(value))));

      addDoc(modifier, ++id, value);
      assertEquals(0, modifier.getSegmentCount());
      modifier.commit();
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

    modifier.addDocument(doc);
  }

  private int getHitCount(Directory dir, Term term) throws IOException {
    IndexSearcher searcher = new IndexSearcher(dir, true);
    int hitCount = searcher.search(new TermQuery(term), null, 1000).totalHits;
    searcher.close();
    return hitCount;
  }
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

        }

        IndexSearcher searcher = newSearcher(newReader);
        ScoreDoc[] hits = null;
        try {
          hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
        }
        catch (IOException e) {
          e.printStackTrace();
          fail(testName + ": exception when searching: " + e);
        }
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

        setUseCompoundFile(mp, useCompoundFile);
      }
      IndexWriter writer = new IndexWriter(dir, conf);
      writer.close();
      Term searchTerm = new Term("content", "aaa");       
      Query query = new TermQuery(searchTerm);

      for(int i=0;i<N+1;i++) {
        if (VERBOSE) {
          System.out.println("\nTEST: cycle i=" + i);
        }
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

        setUseCompoundFile(mp, useCompoundFile);
      }
      IndexWriter writer = new IndexWriter(dir, conf);
      writer.close();
      Term searchTerm = new Term("content", "aaa");       
      Query query = new TermQuery(searchTerm);

      for(int i=0;i<N+1;i++) {

        conf = newIndexWriterConfig(
            TEST_VERSION_CURRENT, new MockAnalyzer(random))
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

    doc.add(new Field("f", "a", Field.Store.NO, Field.Index.NOT_ANALYZED));
    writer.addDocument(doc);
    writer.commit();

    collector = new Collector();
    searcher.search(new TermQuery(new Term("f", "a")), collector);
    assertEquals(1, collector.hits);

    doc = new Document();
    doc.add(new Field("f", "a", Field.Store.NO, Field.Index.NOT_ANALYZED));
    writer.addDocument(doc);
    writer.commit();

    collector = new Collector();
    searcher.search(new TermQuery(new Term("f", "a")), collector);
    assertEquals(2, collector.hits);

  }
View Full Code Here

Examples of org.apache.lucene.search.TermQuery

  public void testOffByOne() throws Exception {
    TestHighlightRunner helper = new TestHighlightRunner() {

      @Override
      public void run() throws Exception {
        TermQuery query = new TermQuery(new Term("data", "help"));
        Highlighter hg = new Highlighter(new SimpleHTMLFormatter(), new QueryTermScorer(query));
        hg.setTextFragmenter(new NullFragmenter());

        String match = null;
        match = hg.getBestFragment(analyzer, "data", "help me [54-65]");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.