Exemple #1
0
  public CObjList searchFiles(String comid, String share, String qstr, Sort srt) {
    BooleanQuery query = new BooleanQuery();

    Term pstterm = new Term(CObj.PARAM_TYPE, CObj.FILE);
    query.add(new TermQuery(pstterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    query.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(
            CObj.docNumber(CObj.NUMBER_HAS), 0L, Long.MAX_VALUE, false, true);
    query.add(nq, BooleanClause.Occur.MUST);

    if (share != null) {
      Term shareterm = new Term(CObj.docString(CObj.SHARE_NAME), share);
      query.add(new TermQuery(shareterm), BooleanClause.Occur.MUST);
    }

    Matcher m = Pattern.compile("\\S+").matcher(qstr);

    if (m.find()) {
      StringBuilder sb = new StringBuilder();
      sb.append(CObj.docStringText(CObj.NAME));
      sb.append(":\"");
      sb.append(qstr);
      sb.append("\"");
      return search(query, sb.toString(), Integer.MAX_VALUE, srt);
    } else {
      return search(query, Integer.MAX_VALUE, srt);
    }
  }
Exemple #2
0
  // Could be based on creator and sequence number, but
  // not enough to worry about.  Just send all.
  public CObjList getCommunities(String creator, long first, long last) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.COMMUNITY);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), creator);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(CObj.docNumber(CObj.SEQNUM), first, last, true, true);
    bq.add(nq, BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }
Exemple #3
0
  public CObjList getFragments(String wdig, String pdig) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.FRAGMENT);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term dig = new Term(CObj.docString(CObj.FILEDIGEST), wdig);
    bq.add(new TermQuery(dig), BooleanClause.Occur.MUST);

    Term ddig = new Term(CObj.docString(CObj.FRAGDIGEST), pdig);
    bq.add(new TermQuery(ddig), BooleanClause.Occur.MUST);

    SortField field = new SortField(CObj.docNumber(CObj.FRAGOFFSET), SortField.Type.LONG);
    Sort sort = new Sort(field);

    return search(bq, Integer.MAX_VALUE, sort);
  }
Exemple #4
0
  public CObjList getHasFiles(String comid, String memid, long first, long last) {
    BooleanQuery bq = new BooleanQuery();
    Term typterm = new Term(CObj.PARAM_TYPE, CObj.HASFILE);
    bq.add(new TermQuery(typterm), BooleanClause.Occur.MUST);

    Term comterm = new Term(CObj.docString(CObj.COMMUNITYID), comid);
    bq.add(new TermQuery(comterm), BooleanClause.Occur.MUST);

    Term memterm = new Term(CObj.docString(CObj.CREATOR), memid);
    bq.add(new TermQuery(memterm), BooleanClause.Occur.MUST);

    NumericRangeQuery<Long> nq =
        NumericRangeQuery.newLongRange(CObj.docNumber(CObj.SEQNUM), first, last, true, true);
    bq.add(nq, BooleanClause.Occur.MUST);

    return search(bq, Integer.MAX_VALUE);
  }