예제 #1
0
    @Override
    public Y build(BuilderContext context) {
      ContentPath.Type origPathType = context.path().pathType();
      context.path().pathType(pathType);
      context.path().add(name);

      Map<String, Mapper> mappers = new HashMap<String, Mapper>();
      for (Mapper.Builder builder : mappersBuilders) {
        Mapper mapper = builder.build(context);
        mappers.put(mapper.name(), mapper);
      }
      context.path().pathType(origPathType);
      context.path().remove();

      ObjectMapper objectMapper =
          createMapper(
              name,
              context.path().fullPathAsText(name),
              enabled,
              nested,
              dynamic,
              pathType,
              mappers);
      objectMapper.includeInAllIfNotSet(includeInAll);

      return (Y) objectMapper;
    }
예제 #2
0
  public static OntologyHelper getHelper(OntologySettings settings, ThreadPool threadPool)
      throws OntologyHelperException {
    String helperKey = buildHelperKey(settings);
    OntologyHelper helper = helpers.get(helperKey);

    if (helper == null) {
      helper = new ElasticOntologyHelperFactory(settings).buildOntologyHelper();
      OntologyCheckRunnable checker = new OntologyCheckRunnable(helperKey);
      threadPool.scheduleWithFixedDelay(checker, TimeValue.timeValueMillis(DELETE_CHECK_DELAY_MS));
      helpers.put(helperKey, helper);
      helper.updateLastCallTime();
    }

    return helper;
  }
예제 #3
0
    private Map<String, StringFieldMapper.Builder> parseProperties(
        Map<String, Object> propertiesNode, ParserContext parserContext) {
      Map<String, StringFieldMapper.Builder> propertyMap = new HashMap<>();
      for (Iterator<Map.Entry<String, Object>> iterator = propertiesNode.entrySet().iterator();
          iterator.hasNext(); ) {
        Entry<String, Object> entry = iterator.next();
        String name = entry.getKey();

        @SuppressWarnings("unchecked")
        Mapper.Builder builder =
            new StringFieldMapper.TypeParser()
                .parse(entry.getKey(), (Map<String, Object>) entry.getValue(), parserContext);
        propertyMap.put(name, (StringFieldMapper.Builder) builder);
      }
      return propertyMap;
    }
 void addField(String fieldName, Terms terms) {
   fields.put(fieldName, terms);
 }