/**
   * for ES to initialize the user dictionary.
   *
   * @param configFile
   */
  public void init(Path configFile) {
    String abspath = configFile.toAbsolutePath().toString();
    System.out.println("initialize user dictionary:" + abspath);
    synchronized (WordDictionary.class) {
      if (loadedPath.contains(abspath)) return;

      DirectoryStream<Path> stream;
      try {
        stream =
            Files.newDirectoryStream(
                configFile, String.format(Locale.getDefault(), "*%s", USER_DICT_SUFFIX));
        for (Path path : stream) {
          System.err.println(
              String.format(Locale.getDefault(), "loading dict %s", path.toString()));
          singleton.loadUserDict(path);
        }
        loadedPath.add(abspath);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        // e.printStackTrace();
        System.err.println(
            String.format(
                Locale.getDefault(), "%s: load user dict failure!", configFile.toString()));
      }
    }
  }
 @Inject
 public JiebaTokenFilterFactory(
     IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) {
   super(indexSettings, name, settings);
   type = settings.get("seg_mode", "index");
   Environment env = new Environment(indexSettings.getSettings());
   WordDictionary.getInstance().init(env.pluginsFile().resolve("jieba/dic"));
 }