Package org.apache.lucene.search

Examples of org.apache.lucene.search.BooleanClause


    if(strict) {
      super.addClause(clauses, conj, mods, q);
      return;
    }
    if(clauses.size() == 0) {
      clauses.add(new BooleanClause(new BooleanQuery(), BooleanClause.Occur.SHOULD));
    }
    if(q instanceof TermQuery) {
      Term t = ((TermQuery)q).getTerm();
      if(t.field().equals("txt")) {
        String queryText = t.text();
View Full Code Here


  }
 
  private Query mergeQueries(Query q1, Query q2) {
    if(q2 != null) {
      BooleanQuery bq = new BooleanQuery();
      bq.add(new BooleanClause(q2, Occur.SHOULD));
      bq.add(new BooleanClause(q1, Occur.SHOULD));
      q1 = bq;
    }
    return q1;
  }
View Full Code Here

  private Query expandTerm(String term) {
    BooleanQuery bq = new BooleanQuery();
    Set<String> myOntIDs = OBOOntology.getInstance().getIdsForTermWithDescendants(term);
    if(myOntIDs != null && myOntIDs.size() > 0) {
      OntologyQuery oq = new OntologyQuery(myOntIDs);
      bq.add(new BooleanClause(oq.getLuceneQuery(), Occur.SHOULD));
    }
    Matcher m = similarPattern.matcher(term);
    try {
      if(m.matches()) {
        String name = m.group(3);
        String smiles = lis.getSmilesFromName(name);
        ChemQuery cq = lis.makeChemQueryFromSMILES(smiles, "similarity", m.group(1));
        bq.add(new BooleanClause(cq.getLuceneQuery(), BooleanClause.Occur.SHOULD));
      } else {
        String inchi = lis.getInchiFromName(term);
        if(inchi != null) {
          bq.add(new BooleanClause(new TermQuery(new Term("InChI", inchi)), BooleanClause.Occur.SHOULD));
        }
      }     
    } catch (Exception e) {
      e.printStackTrace();
      return null;
View Full Code Here

    setToSearch();
    VectorCollector vc = new VectorCollector();
    BitSet fp = fingerprinter.getFingerprint(queryMol);
    BooleanQuery bq = new BooleanQuery();
    for(int i=fp.nextSetBit(0); i>=0; i=fp.nextSetBit(i+1)) {
      bq.add(new BooleanClause(new TermQuery(new Term("FP", Integer.toString(i))), BooleanClause.Occur.MUST));
    }
    indexSearcher.search(bq, vc);
    List<Integer> bestResults = vc.hitsByScore();
    VectorCollector newVc = new VectorCollector();
    IndexReader ir = indexSearcher.getIndexReader();
View Full Code Here

    setToSearch();
    VectorCollector vc = new VectorCollector();
    BitSet fp = fingerprinter.getFingerprint(queryMol);
    BooleanQuery bq = new BooleanQuery();
    for(int i=fp.nextSetBit(0); i>=0; i=fp.nextSetBit(i+1)) {
      bq.add(new BooleanClause(new TermQuery(new Term("FP", Integer.toString(i))), BooleanClause.Occur.MUST));
    }
    indexSearcher.search(bq, vc);
    List<Integer> bestResults = vc.hitsByScore();
    VectorCollector newVc = new VectorCollector();
    IndexReader ir = indexSearcher.getIndexReader();
View Full Code Here

    setToSearch();
    VectorCollector vc = new VectorCollector();
    BitSet fp = fingerprinter.getFingerprint(queryMol);
    BooleanQuery bq = new BooleanQuery();
    for(int i=fp.nextSetBit(0); i>=0; i=fp.nextSetBit(i+1)) {
      bq.add(new BooleanClause(new TermQuery(new Term("FP", Integer.toString(i))), BooleanClause.Occur.SHOULD));
    }
    indexSearcher.search(bq, vc);
    List<Integer> bestResults = vc.hitsByScore();
    VectorCollector newVc = new VectorCollector();
    for(Integer i : bestResults) {
View Full Code Here

    bq = new BooleanQuery();
    for(String inchi : inchis.keySet()) {
      TermQuery tq = new TermQuery(new Term("InChI", inchi));
      tq.setBoost(inchis.get(inchi));
      /* We need *at least one of* these */
      bq.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
    }
  }
View Full Code Here

      }
      else {
        this.exclude = new BooleanClause[exclude.size()];
        for( int i=0; i<exclude.size(); i++ ) {
          TermQuery tq = new TermQuery( new Term( idField, exclude.get(i) ) );
          this.exclude[i] = new BooleanClause( tq, BooleanClause.Occur.MUST_NOT );
        }
      }
    }
View Full Code Here

     * Add a clause to a boolean query.
     */
    private static void add(BooleanQuery q, String name, String value, float boost) {
        Query tq = new TermQuery(new Term(name, value));
        tq.setBoost(boost);
        q.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
    }
View Full Code Here

        tq.setBoost(boost);
        q.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
    }

    private static void add(BooleanQuery q, String name, String value, Occur occur) {
        q.add(new BooleanClause(new TermQuery(new Term(name, value)), occur));
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.BooleanClause

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.