org.elasticsearch.index.query.QueryBuilder.getName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.elasticsearch.index.query.QueryBuilder.getName方法的一些代码示例,展示了QueryBuilder.getName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryBuilder.getName方法的具体详情如下:
包路径:org.elasticsearch.index.query.QueryBuilder
类名称:QueryBuilder
方法名:getName

QueryBuilder.getName介绍

[英]Returns the name that identifies uniquely the query
[中]返回唯一标识查询的名称

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
  ScoreFunction[] filterFunctions = new ScoreFunction[filterFunctionBuilders.length];
  int i = 0;
  for (FilterFunctionBuilder filterFunctionBuilder : filterFunctionBuilders) {
    ScoreFunction scoreFunction = filterFunctionBuilder.getScoreFunction().toFunction(context);
    if (filterFunctionBuilder.getFilter().getName().equals(MatchAllQueryBuilder.NAME)) {
      filterFunctions[i++] = scoreFunction;
    } else {
      Query filter = filterFunctionBuilder.getFilter().toQuery(context);
      filterFunctions[i++] = new FunctionScoreQuery.FilterScoreFunction(filter, scoreFunction);
    }
  }
  Query query = this.query.toQuery(context);
  if (query == null) {
    query = new MatchAllDocsQuery();
  }
  CombineFunction boostMode = this.boostMode == null ? DEFAULT_BOOST_MODE : this.boostMode;
  // handle cases where only one score function and no filter was provided. In this case we create a FunctionScoreQuery.
  if (filterFunctions.length == 0) {
    return new FunctionScoreQuery(query, minScore, maxBoost);
  } else if (filterFunctions.length == 1 && filterFunctions[0] instanceof FunctionScoreQuery.FilterScoreFunction == false) {
    return new FunctionScoreQuery(query, filterFunctions[0], boostMode, minScore, maxBoost);
  }
  // in all other cases we create a FunctionScoreQuery with filters
  return new FunctionScoreQuery(query, scoreMode, filterFunctions, boostMode, minScore, maxBoost);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
  protected void doBuild(SearchContext parentSearchContext,
           InnerHitsContext innerHitsContext) throws IOException {
    QueryShardContext queryShardContext = parentSearchContext.getQueryShardContext();
    ObjectMapper nestedObjectMapper = queryShardContext.getObjectMapper(path);
    if (nestedObjectMapper == null) {
      if (innerHitBuilder.isIgnoreUnmapped() == false) {
        throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + path + "]");
      } else {
        return;
      }
    }
    String name =  innerHitBuilder.getName() != null ? innerHitBuilder.getName() : nestedObjectMapper.fullPath();
    ObjectMapper parentObjectMapper = queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
    NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
      name, parentSearchContext, parentObjectMapper, nestedObjectMapper
    );
    setupInnerHitsContext(queryShardContext, nestedInnerHits);
    queryShardContext.nestedScope().previousLevel();
    innerHitsContext.addInnerHitDefinition(nestedInnerHits);
  }
}

代码示例来源:origin: apache/incubator-unomi

QueryBuilder andFilter = dispatcher.buildFilter(conditions.get(i), context);
if (andFilter != null) {
  if (andFilter.getName().equals("range")) {
    boolQueryBuilder.filter(andFilter);
  } else {
QueryBuilder orFilter = dispatcher.buildFilter(conditions.get(i), context);
if (orFilter != null) {
  if (orFilter.getName().equals("range")) {
    boolQueryBuilder.filter(orFilter);
  } else {

代码示例来源:origin: org.elasticsearch.plugin/percolator-client

if (queryBuilder.getName().equals("has_child")) {
  throw new IllegalArgumentException("the [has_child] query is unsupported inside a percolator query");
} else if (queryBuilder.getName().equals("has_parent")) {
  throw new IllegalArgumentException("the [has_parent] query is unsupported inside a percolator query");
} else if (queryBuilder instanceof BoolQueryBuilder) {

代码示例来源:origin: org.codelibs.elasticsearch.module/percolator

if (queryBuilder.getName().equals("has_child")) {
  throw new IllegalArgumentException("the [has_child] query is unsupported inside a percolator query");
} else if (queryBuilder.getName().equals("has_parent")) {
  throw new IllegalArgumentException("the [has_parent] query is unsupported inside a percolator query");
} else if (queryBuilder instanceof BoolQueryBuilder) {

代码示例来源:origin: apache/servicemix-bundles

@Override
  protected void doBuild(SearchContext parentSearchContext,
           InnerHitsContext innerHitsContext) throws IOException {
    QueryShardContext queryShardContext = parentSearchContext.getQueryShardContext();
    ObjectMapper nestedObjectMapper = queryShardContext.getObjectMapper(path);
    if (nestedObjectMapper == null) {
      if (innerHitBuilder.isIgnoreUnmapped() == false) {
        throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + path + "]");
      } else {
        return;
      }
    }
    String name =  innerHitBuilder.getName() != null ? innerHitBuilder.getName() : nestedObjectMapper.fullPath();
    ObjectMapper parentObjectMapper = queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
    NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
      name, parentSearchContext, parentObjectMapper, nestedObjectMapper
    );
    setupInnerHitsContext(queryShardContext, nestedInnerHits);
    queryShardContext.nestedScope().previousLevel();
    innerHitsContext.addInnerHitDefinition(nestedInnerHits);
  }
}

代码示例来源:origin: org.codelibs.elasticsearch.module/parent-join

private void handleParentFieldInnerHits(SearchContext context, InnerHitsContext innerHitsContext) throws IOException {
  QueryShardContext queryShardContext = context.getQueryShardContext();
  DocumentMapper documentMapper = queryShardContext.documentMapper(typeName);
  if (documentMapper == null) {
    if (innerHitBuilder.isIgnoreUnmapped() == false) {
      throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + typeName + "]");
    } else {
      return;
    }
  }
  String name = innerHitBuilder.getName() != null ? innerHitBuilder.getName() : documentMapper.type();
  ParentChildInnerHitSubContext parentChildInnerHits = new ParentChildInnerHitSubContext(
    name, context, queryShardContext.getMapperService(), documentMapper
  );
  setupInnerHitsContext(queryShardContext, parentChildInnerHits);
  innerHitsContext.addInnerHitDefinition(parentChildInnerHits);
}

代码示例来源:origin: org.elasticsearch.plugin/parent-join-client

private void handleParentFieldInnerHits(SearchContext context, InnerHitsContext innerHitsContext) throws IOException {
  QueryShardContext queryShardContext = context.getQueryShardContext();
  DocumentMapper documentMapper = queryShardContext.documentMapper(typeName);
  if (documentMapper == null) {
    if (innerHitBuilder.isIgnoreUnmapped() == false) {
      throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + typeName + "]");
    } else {
      return;
    }
  }
  String name = innerHitBuilder.getName() != null ? innerHitBuilder.getName() : documentMapper.type();
  ParentChildInnerHitSubContext parentChildInnerHits = new ParentChildInnerHitSubContext(
    name, context, queryShardContext.getMapperService(), documentMapper
  );
  setupInnerHitsContext(queryShardContext, parentChildInnerHits);
  innerHitsContext.addInnerHitDefinition(parentChildInnerHits);
}

代码示例来源:origin: com.strapdata.elasticsearch.plugin/parent-join

private void handleParentFieldInnerHits(SearchContext context, InnerHitsContext innerHitsContext) throws IOException {
  QueryShardContext queryShardContext = context.getQueryShardContext();
  DocumentMapper documentMapper = queryShardContext.documentMapper(typeName);
  if (documentMapper == null) {
    if (innerHitBuilder.isIgnoreUnmapped() == false) {
      throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + typeName + "]");
    } else {
      return;
    }
  }
  String name = innerHitBuilder.getName() != null ? innerHitBuilder.getName() : documentMapper.type();
  ParentChildInnerHitSubContext parentChildInnerHits = new ParentChildInnerHitSubContext(
    name, context, queryShardContext.getMapperService(), documentMapper
  );
  setupInnerHitsContext(queryShardContext, parentChildInnerHits);
  innerHitsContext.addInnerHitDefinition(parentChildInnerHits);
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

&& (this.filterFunctionBuilders[0].getFilter().getName().equals(MatchAllQueryBuilder.NAME))) {
ScoreFunction function = filterFunctions.length == 0 ? null : filterFunctions[0].function;
CombineFunction combineFunction = this.boostMode;

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
  public void build(SearchContext parentSearchContext,
           InnerHitsContext innerHitsContext) throws IOException {
    QueryShardContext queryShardContext = parentSearchContext.getQueryShardContext();
    ObjectMapper nestedObjectMapper = queryShardContext.getObjectMapper(path);
    if (nestedObjectMapper == null) {
      if (innerHitBuilder.isIgnoreUnmapped() == false) {
        throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + path + "]");
      } else {
        return;
      }
    }
    String name =  innerHitBuilder.getName() != null ? innerHitBuilder.getName() : nestedObjectMapper.fullPath();
    ObjectMapper parentObjectMapper = queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
    NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
      name, parentSearchContext, parentObjectMapper, nestedObjectMapper
    );
    setupInnerHitsContext(queryShardContext, nestedInnerHits);
    queryShardContext.nestedScope().previousLevel();
    innerHitsContext.addInnerHitDefinition(nestedInnerHits);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
  protected void doBuild(SearchContext parentSearchContext,
           InnerHitsContext innerHitsContext) throws IOException {
    QueryShardContext queryShardContext = parentSearchContext.getQueryShardContext();
    ObjectMapper nestedObjectMapper = queryShardContext.getObjectMapper(path);
    if (nestedObjectMapper == null) {
      if (innerHitBuilder.isIgnoreUnmapped() == false) {
        throw new IllegalStateException("[" + query.getName() + "] no mapping found for type [" + path + "]");
      } else {
        return;
      }
    }
    String name =  innerHitBuilder.getName() != null ? innerHitBuilder.getName() : nestedObjectMapper.fullPath();
    ObjectMapper parentObjectMapper = queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
    NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
      name, parentSearchContext, parentObjectMapper, nestedObjectMapper
    );
    setupInnerHitsContext(queryShardContext, nestedInnerHits);
    queryShardContext.nestedScope().previousLevel();
    innerHitsContext.addInnerHitDefinition(nestedInnerHits);
  }
}

代码示例来源:origin: apache/servicemix-bundles

for (FilterFunctionBuilder filterFunctionBuilder : filterFunctionBuilders) {
  ScoreFunction scoreFunction = filterFunctionBuilder.getScoreFunction().toFunction(context);
  if (filterFunctionBuilder.getFilter().getName().equals(MatchAllQueryBuilder.NAME)) {
    filterFunctions[i++] = scoreFunction;
  } else {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

for (FilterFunctionBuilder filterFunctionBuilder : filterFunctionBuilders) {
  ScoreFunction scoreFunction = filterFunctionBuilder.getScoreFunction().toFunction(context);
  if (filterFunctionBuilder.getFilter().getName().equals(MatchAllQueryBuilder.NAME)) {
    filterFunctions[i++] = scoreFunction;
  } else {

相关文章