コード例 #1
0
ファイル: TweetQuery.java プロジェクト: neville-agius/Jetwick
  @Override
  protected XContentQueryBuilder createQuery(String queryStr) {
    XContentQueryBuilder qb;
    if (queryStr == null || queryStr.isEmpty()) qb = QueryBuilders.matchAllQuery();
    else {
      // fields can also contain patterns like so name.* to match more fields
      qb =
          QueryBuilders.queryString(queryStr)
              .defaultOperator(Operator.AND)
              .field(ElasticTweetSearch.TWEET_TEXT)
              .field("dest_title_t")
              .field("user", 0)
              .allowLeadingWildcard(false)
              .analyzer(getDefaultAnalyzer())
              .useDisMax(true);
    }

    return qb;
    //        return QueryBuilders.customScoreQuery(qb).script("_score *
    // doc['relevancy'].value").lang("js");

    //        long time = new MyDate().castToHour().getTime();
    //        return customScoreQuery(qb)
    //                .script(
    //                "var boost = _score;"
    //                + "if(doc['tw_i'].value <= 30) boost *= 0.1;"
    //                + "if(doc['quality_i'].value <= 65) boost *= 0.1;"
    //                + "var retweet = doc['retw_i'].value;"
    //                + "var scale = 10000;"// time vs. retweet -> what should be more important?
    // +0.1 because boost should end up to be 0 for 0 retweets
    //                + "if(retweet <= 100) boost *= 0.1 + retweet / scale; else boost *= 0.1 + 100
    // / scale;"
    //                + "boost / (3.6e-9 * (mynow - doc['dt'].value) + 1);"
    //                ).
    //                lang("js").param("mynow", time);
  }
コード例 #2
0
 public StringQuery(String query) {
   _builder = QueryBuilders.queryString(query);
 }