我已经做了Comment.import,它返回0,这意味着在导入过程中没有错误.
我已经做了 Comment.__elasticsearch__.refresh_index!
这是我正在使用的模型:
require "datamapper_adapter"
class Comment
include DataMapper::Resource
include Elasticsearch::Model
property :id, Serial
property :email, String
property :author, String
property :description, String
property :created_at, DateTime
belongs_to :picture
validates_presence_of :email, :author, :description
settings index: { number_of_shards: 1 } do
mappings dynamic: 'false' do
indexes :id, analyzer: 'english', index_options: 'offsets'
indexes :author, analyzer: 'english', index_options: 'offsets'
indexes :description, analyzer: 'english', index_options: 'offsets'
end
end
def as_indexed_json(options={})
as_json.except("picture_id", "created_at", "email", "_persistence_state", "_repository", "_id")
end
end
Run Code Online (Sandbox Code Playgroud)
而且我对elasticsearch的所有查询都返回一个空数组作为命中.
curl -XPOST 'http://localhost:9200/comments/comment/_search?pretty …Run Code Online (Sandbox Code Playgroud) 我试图使用elasticsearch来匹配嵌套数组中的所有值.例如.我的搜索数组是["1","2","3","4","5","6","7","8","9"]
,我的文档包含一系列数组
"arr":[
["1","2","10"],
["4","5"],
["8","9","11"]
]
Run Code Online (Sandbox Code Playgroud)
我需要匹配嵌套数组中的所有值,但只有一个嵌套数组需要匹配文档才能匹配.所以,在这个例子中仅第二嵌套阵列是匹配,因为"4"和"5"都是本搜索数组中(因此我的文档是一个匹配).我应该使用什么样的查询来实现这一目标?
我通过http poller获得一个json
{
"id":12345
"name":"",
"lastname":"",
"age":12,
"address":{"city":"XXXX" , "street":"ZZZZ" }
}
Run Code Online (Sandbox Code Playgroud)
我想在我的输出中生成两个文档:
人:
{
"id":12345
"name":"",
"lastname":"",
"age":12
}
Run Code Online (Sandbox Code Playgroud)
地址 :
{
"city":"XXXX" ,
"street":"ZZZZ"
}
Run Code Online (Sandbox Code Playgroud)
意思是我在输入中有一个事件
在输入阶段获得一个输入:
input {
http_poller {
urls => {
test1 => "http://localhost:8080"
}
}
Run Code Online (Sandbox Code Playgroud)
在过滤阶段,我想:
在输出阶段,我想:
我们有一个符合OData的API,它将一些全文搜索需求委托给Elasticsearch集群.由于OData表达式可能变得非常复杂,我们决定将它们简单地转换为等效的Lucene查询语法并将其提供给query_string查询.
我们支持一些与文本相关的OData过滤器表达式,例如:
startswith(field,'bla')endswith(field,'bla')substringof('bla',field)name eq 'bla'我们对匹配字段可以是analyzed,not_analyzed或两者(通过多场IE).所搜索的文本可以是一个单一的令牌(例如table),只有其(例如一部分tab),或数个标记(例如table 1.,table 10等).搜索必须不区分大小写.
以下是我们需要支持的行为的一些示例:
startswith(name,'table 1')必须匹配" 表1 "," 表1 00"," 表1 .5"," 表1 12上层"endswith(name,'table 1')必须匹配"房间1,表1 ","子表1 "," 表1 ","杰夫表1 "substringof('table 1',name)必须匹配"Big Table 1 back"," table 1 "," Table 1 ","Small Table1 2"name eq 'table 1'必须匹配" 表1 "," 表1 "," 表1 "所以基本上,我们接受用户输入(即传递给startswith/ 的第二个参数的内容endswith,或者相应的第一个参数substringof …
假设我有下表:
`title`
- id
- name
- tv_series_id
Example:
id=1, name="Episode 2", tv_series_id=4
Run Code Online (Sandbox Code Playgroud)
我可以使用以下 JSON 结构轻松地将其映射到 ElasticSearch 中:
{
"ID": 1,
"Name": "Episode 2",
"TVSeriesID": 4
}
Run Code Online (Sandbox Code Playgroud)
如果我有第二个表,称为外键中引用tv_series的title表,例如:
`tv_series`
- id
- name
Example:
id=4, name='Friends'
Run Code Online (Sandbox Code Playgroud)
那么我将如何在 Elasticsearch 中映射这种关系?是否有一种通用方法可以在 Elasticsearch 中映射具有一个或多个外键关系的两个表?例如,通过执行某个连接语句?
我在 Windows 7 机器上本地安装了 Logstash 和 Elasticsearch。我在 Logstash 中安装了logstash-input-jdbc。
我在 MySql 数据库中有数据,我使用 Logstash 将这些数据发送到 Elasticsearch,以便我可以生成一些报告。
执行此操作的 Logstash 配置文件。
input {
jdbc {
jdbc_driver_library => "C:/logstash/lib/mysql-connector-java-5.1.37-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/test"
jdbc_user => "root"
jdbc_password => ""
statement => "SELECT * FROM transport.audit"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "transport-audit-%{+YYYY.mm.dd}"
}
}
Run Code Online (Sandbox Code Playgroud)
这有效,Logstash 在我运行时将数据发送到 Elasticsearch:
bin\logstash agent -f \logstash\conf\01_input.conf
Run Code Online (Sandbox Code Playgroud)
这是该命令的响应
io/console not supported; tty will not be …Run Code Online (Sandbox Code Playgroud) 我已将ELK配置为脱机收集数据,日志文件如下所示:
Info 2015-08-15 09:33:37,522 User 3 connected
Info 2015-08-15 10:03:57,592 User 99 connected
Info 2015-08-15 11:42:37,522 User 99 disconnected
Info 2015-08-15 11:49:12,108 User 3 disconnected
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是时间线上的平均连接时间.
我无法向消息添加更多信息,特别是我无法在断开连接消息中添加连接时间.
ES 2.0刚刚发布.出于好奇,我测试了我的ES 1.7.3针对ES 2.0的映射文件.我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
],
"type": "mapper_parsing_exception",
"reason": "mapping [mydoctype]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)
基本上,这个错误抱怨我的映射文件包含以下内容:
"mydoctype": {
"_id" : {
"path" : "id"
},
Run Code Online (Sandbox Code Playgroud)
刚刚谷歌并没有找到一种方法将doc _id设置为ES 2.0中索引文档的实际标识符.我怎样才能做到这一点?
感谢任何指针和输入!
我有一个这样的查询
s = Search(using=es, index=indices)
s = s.filter('range',
utctimestamp={'gte': begindateUTC, 'lte': enddateUTC})
.filter("term",tags="foo").
.sort("-utctimestamp")
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何取消过滤器?即不是foo。以上是使用过滤器的“必须”,例如
"filter": {
"bool": {
"must": [
{
"range": {
"utctimestamp": {
"from": 1460407864660,
"to": 1460409664660
}
}
},
{
"fquery": {
"query": {
"query_string": {
"query": "_type:(\"foo\")"
}
},
"_cache": true
}
}
]
Run Code Online (Sandbox Code Playgroud)
我该如何将“foo”位设置为“不得”。
提前致谢
试图让Filebeat与logstash一起使用.目前我收到此错误:
2016/11/14 04:54:27.721478 output.go:109: DBG output worker: publish 2047 events
2016/11/14 04:54:27.756650 sync.go:85: ERR Failed to publish events caused by: lumberjack protocol error
2016/11/14 04:54:27.756676 single.go:91: INFO Error publishing events (retrying): lumberjack protocol error
2016/11/14 04:54:28.782729 sync.go:85: ERR Failed to publish events caused by: lumberjack protocol error
2016/11/14 04:54:28.782756 single.go:91: INFO Error publishing events (retrying): lumberjack protocol error
2016/11/14 04:54:30.786983 sync.go:85: ERR Failed to publish events caused by: lumberjack protocol error
2016/11/14 04:54:30.787017 single.go:91: INFO Error publishing events (retrying): lumberjack …Run Code Online (Sandbox Code Playgroud)