Elastic的Workplace Search如何使用Gmail或Google Drive等数据源

Workplace Search 提供了大量的数据源的集成,我们只需要适当的配置就可以让Workplace Search自动同步数据源上的内容,让我们可以快速查询数据源上我们感兴趣的数据。

但目前官方提供的一些数据源,比如像GitHub、Gmail、Google Drive等,都需要翻墙才能够获取内容
在这里插入图片描述
以Gmail举例,当我们按照教程,完成OAuth访问配置,获得Client ID和Client Secret

在这里插入图片描述
我们需要将Gmail配置为数据源,并且connect,以获取数据:

在这里插入图片描述
我们会发现页面上会提示Server Internal ERROR的500错误。

后台有如下打印:

[2020-10-14T08:59:37.113+00:00][29186218][2510][app-server][ERROR]: [cdeb1208-fac4-498c-9881-38f43daf85ae] org/jruby/ext/socket/RubyTCPSocket.java:144:in `initialize': execution expired (Faraday::ConnectionFailed)
	from org/jruby/RubyIO.java:1158:in `open'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:941:in `block in connect'
	from org/jruby/ext/timeout/Timeout.java:99:in `timeout'
	from org/jruby/ext/timeout/Timeout.java:75:in `timeout'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:939:in `connect'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:924:in `do_start'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:913:in `start'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:1465:in `request'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/adapter/net_http.rb:87:in `perform_request'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/adapter/net_http.rb:43:in `block in call'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/adapter/net_http.rb:92:in `with_net_http_connection'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/adapter/net_http.rb:38:in `call'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/request/url_encoded.rb:15:in `call'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/rack_builder.rb:143:in `build_response'
	from /Users/lex.li/es_lab/enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/connection.rb:387:in `run_request'

究其原因是connector无法访问当google的网址(你懂的)。

这时,唯一的求解方式是通过代理来解决网络的问题。

本以为会是很麻烦的事情,结果很美妙

我看了ruby的源码enterprise-search-7.9.2/lib/war/gems/gems/faraday-0.15.2/lib/faraday/connection.rb,发现这个类会直接读取系统的http_proxy作为代理的配置,因此,简单的配置一下:

export http_proxy=http://127.0.0.1:1087
ENT_SEARCH_DEFAULT_PASSWORD=changeme bin/enterprise-search

解决!完美!
在这里插入图片描述

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页