Example usage for org.apache.lucene.search.join ScoreMode None

List of usage examples for org.apache.lucene.search.join ScoreMode None

Introduction

In this page you can find the example usage for org.apache.lucene.search.join ScoreMode None.

Prototype

ScoreMode None

To view the source code for org.apache.lucene.search.join ScoreMode None.

Click Source Link

Document

Do no scoring.

Usage

From source file:com.b2international.index.es.query.EsQueryBuilder.java

License:Apache License

private void visit(NestedPredicate predicate) {
    final String nestedPath = toFieldPath(predicate);
    final DocumentMapping nestedMapping = mapping.getNestedMapping(predicate.getField());
    final EsQueryBuilder nestedQueryBuilder = new EsQueryBuilder(nestedMapping, nestedPath);
    nestedQueryBuilder.visit(predicate.getExpression());
    needsScoring = nestedQueryBuilder.needsScoring;
    final QueryBuilder nestedQuery = nestedQueryBuilder.deque.pop();
    deque.push(QueryBuilders.nestedQuery(nestedPath, nestedQuery, ScoreMode.None));
}

From source file:de.mpg.imeji.logic.search.elasticsearch.factory.ElasticQueryFactory.java

/**
 * Search for content/*from   w  w  w .j  ava 2s.c o  m*/
 * 
 * @param q
 * @return
 */
private QueryBuilder contentQuery(QueryBuilder q) {
    return JoinQueryBuilders.hasChildQuery("content", q, ScoreMode.None);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertDao.java

License:Apache License

@Override
public SearchResponse getAllMetaAlertsForAlert(String guid) throws InvalidSearchException {
    if (guid == null || guid.trim().isEmpty()) {
        throw new InvalidSearchException("Guid cannot be empty");
    }/*from w ww .  j  a  v a  2  s .c o m*/
    // Searches for all alerts containing the meta alert guid in it's "metalerts" array
    QueryBuilder qb = boolQuery()
            .must(nestedQuery(ALERT_FIELD, boolQuery().must(termQuery(ALERT_FIELD + "." + GUID, guid)),
                    ScoreMode.None).innerHit(new InnerHitBuilder()))
            .must(termQuery(STATUS_FIELD, MetaAlertStatus.ACTIVE.getStatusString()));
    return queryAllResults(qb);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertDao.java

License:Apache License

@Override
public SearchResponse search(SearchRequest searchRequest) throws InvalidSearchException {
    // Wrap the query to also get any meta-alerts.
    QueryBuilder qb = constantScoreQuery(boolQuery()
            .must(boolQuery().should(new QueryStringQueryBuilder(searchRequest.getQuery()))
                    .should(nestedQuery(ALERT_FIELD, new QueryStringQueryBuilder(searchRequest.getQuery()),
                            ScoreMode.None)))
            // Ensures that it's a meta alert with active status or that it's an alert (signified by
            // having no status field)
            .must(boolQuery()/*from w  w  w . j  a  v a 2  s  .co  m*/
                    .should(termQuery(MetaAlertDao.STATUS_FIELD, MetaAlertStatus.ACTIVE.getStatusString()))
                    .should(boolQuery().mustNot(existsQuery(MetaAlertDao.STATUS_FIELD))))
            .mustNot(existsQuery(MetaAlertDao.METAALERT_FIELD)));
    return elasticsearchDao.search(searchRequest, qb);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertDao.java

License:Apache License

/**
 * Given an alert GUID, retrieve all associated meta alerts.
 * @param alertGuid The GUID of the child alert
 * @return The Elasticsearch response containing the meta alerts
 *//*ww  w. ja v a 2 s  . com*/
protected SearchResponse getMetaAlertsForAlert(String alertGuid) {
    QueryBuilder qb = boolQuery()
            .must(nestedQuery(ALERT_FIELD,
                    boolQuery().must(termQuery(ALERT_FIELD + "." + Constants.GUID, alertGuid)), ScoreMode.None)
                            .innerHit(new InnerHitBuilder()))
            .must(termQuery(STATUS_FIELD, MetaAlertStatus.ACTIVE.getStatusString()));
    return queryAllResults(qb);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertSearchDao.java

License:Apache License

@Override
public SearchResponse search(SearchRequest searchRequest) throws InvalidSearchException {
    // Wrap the query to also get any meta-alerts.
    QueryBuilder qb = constantScoreQuery(boolQuery()
            .must(boolQuery().should(new QueryStringQueryBuilder(searchRequest.getQuery()))
                    .should(nestedQuery(MetaAlertConstants.ALERT_FIELD,
                            new QueryStringQueryBuilder(searchRequest.getQuery()), ScoreMode.None)))
            // Ensures that it's a meta alert with active status or that it's an alert (signified by
            // having no status field)
            .must(boolQuery()//  ww  w.j  a  v a2s.  co m
                    .should(termQuery(MetaAlertConstants.STATUS_FIELD,
                            MetaAlertStatus.ACTIVE.getStatusString()))
                    .should(boolQuery().mustNot(existsQuery(MetaAlertConstants.STATUS_FIELD))))
            .mustNot(existsQuery(MetaAlertConstants.METAALERT_FIELD)));
    return elasticsearchDao.search(searchRequest, qb);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertSearchDao.java

License:Apache License

@Override
public SearchResponse getAllMetaAlertsForAlert(String guid) throws InvalidSearchException {
    if (guid == null || guid.trim().isEmpty()) {
        throw new InvalidSearchException("Guid cannot be empty");
    }/*from w  ww.jav a 2 s.com*/
    // Searches for all alerts containing the meta alert guid in it's "metalerts" array
    QueryBuilder qb = boolQuery()
            .must(nestedQuery(MetaAlertConstants.ALERT_FIELD,
                    boolQuery().must(termQuery(MetaAlertConstants.ALERT_FIELD + "." + GUID, guid)),
                    ScoreMode.None).innerHit(new InnerHitBuilder()))
            .must(termQuery(MetaAlertConstants.STATUS_FIELD, MetaAlertStatus.ACTIVE.getStatusString()));
    return queryAllResults(elasticsearchDao.getClient(), qb, config.getMetaAlertIndex(), pageSize);
}

From source file:org.apache.metron.elasticsearch.dao.ElasticsearchMetaAlertUpdateDao.java

License:Apache License

/**
 * Given an alert GUID, retrieve all associated meta alerts.
 * @param alertGuid The GUID of the child alert
 * @return The Elasticsearch response containing the meta alerts
 *//*from  www.j  a v a2  s.co  m*/
protected SearchResponse getMetaAlertsForAlert(String alertGuid) {
    QueryBuilder qb = boolQuery()
            .must(nestedQuery(MetaAlertConstants.ALERT_FIELD,
                    boolQuery()
                            .must(termQuery(MetaAlertConstants.ALERT_FIELD + "." + Constants.GUID, alertGuid)),
                    ScoreMode.None).innerHit(new InnerHitBuilder()))
            .must(termQuery(MetaAlertConstants.STATUS_FIELD, MetaAlertStatus.ACTIVE.getStatusString()));
    return ElasticsearchUtils.queryAllResults(elasticsearchDao.getClient(), qb, getConfig().getMetaAlertIndex(),
            pageSize);
}

From source file:org.apache.solr.search.join.BJQParserTest.java

License:Apache License

public void testScoresForParent() throws Exception {
    final ArrayList<ScoreMode> noNone = new ArrayList<>(Arrays.asList(ScoreMode.values()));
    noNone.remove(ScoreMode.None);
    final String notNoneMode = (noNone.get(random().nextInt(noNone.size()))).name();

    String leastScore = getLeastScore("child_s:l");
    assertTrue(leastScore + " > 0.0", Float.parseFloat(leastScore) > 0.0);
    final String notNoneLower = usually() ? notNoneMode : notNoneMode.toLowerCase(Locale.ROOT);

    assertQ(req("q", "{!parent which=\"parent_s:[* TO *]\" score=" + notNoneLower + "}child_s:l", "fl",
            "score"), "//*[@numFound='6']",
            "(//float[@name='score'])[" + (random().nextInt(6) + 1) + "]>='" + leastScore + "'");
}

From source file:org.apache.solr.search.join.BlockJoinParentQParser.java

License:Apache License

protected Query createQuery(Query parentList, Query query) {
    return new ToParentBlockJoinQuery(query, getFilter(parentList), ScoreMode.None);
}