0
Rails, MongoId 및 Elasticsearch 설정이 있습니다. 나는 MongoDB에서 Elasticsearch에 이르는 성공적인 강을 가지고 있으며, 컬렉션에 들어가는 모든 것을 미러링하고 인덱싱합니다. content
.Rails Elastic Search가 Curl 요청을 수행하는 동안 아무런 결과도 반환하지 않습니다.
은 컬, 바로 Elasticsearch에 나는 성공적으로 텍스트 검색을 수행 할 수 있습니다
{
query: {
match: {
"content": "foo"
}
}
}
[email protected] ~/river $ curl -XGET "localhost:9200/mongo_index/_search?pretty=true" -d @search.json
결과 :
[3] pry(main)> bob = ConfigTextSearch.search query: { match: { content: "foo" } }
=> #<Elasticsearch::Model::Response::Response:0x007f0ea72a75d0
@klass=[PROXY] ConfigTextSearch,
@search=
#<Elasticsearch::Model::Searching::SearchRequest:0x007f0ea72a76c0
@definition=
{:index=>"config_text_searches",
:type=>"config_text_search",
:body=>{:query=>{:match=>{:content=>"foo"}}}},
@klass=[PROXY] ConfigTextSearch,
@options={}>>
[4] pry(main)> bob.results.total
=> 0
[5] pry(main)>
:
{
"took": 35,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 4.6738544,
"hits": [
{
"_index": "mongo_index",
"_type": "config_files",
"_id": "54afe45ef7c61b3000009",
"_score": 4.6738544,
"_source": {
"current": true,
"device_id": "54afe167cf7c61b3000006",
"updated_at": "2015-01-09T15:57:13.368Z",
"retain": false,
"name": "version",
"checksum": "a55393f46e3d730f59de1ff4d3c378",
"created_at": "2015-01-09T13:10:54.324Z",
"skinny": false,
"_id": "54afe453ccec61b3000009",
"content": "Foo was here"
}
},
{
"_index": "mongo_index",
"_type": "config_files",
"_id": "54b00054f7c61b3000011",
"_score": 4.6688538,
"_source": {
"current": false,
"device_id": "54b00054cce1b3000010",
"updated_at": "2015-01-09T16:23:14.543Z",
"retain": false,
"name": "my_awesome_config.conf",
"checksum": "a55393f46e30f59de134ff4d3c378",
"created_at": "2015-01-09T13:10:54.324Z",
"skinny": false,
"_id": "54b00054ccef7c63000011",
"content": "foo was here 111"
}
}
]
}
}
그러나 레일 콘솔
, 내가 더 안타 얻을내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니까?
UPDATE : 제안의 출력,하지만 여전히 성공하지 :
[14] pry(main)> query_string = { query: { match: { content: "foo" } } }.to_json
=> "{\"query\":{\"match\":{\"content\":\"foo\"}}}"
[15] pry(main)> bob = ConfigTextSearch.search query_string
=> #<Elasticsearch::Model::Response::Response:0x007f0ea7505bb0
@klass=[PROXY] ConfigTextSearch,
@search=
#<Elasticsearch::Model::Searching::SearchRequest:0x007f0ea7505d18
@definition=
{:index=>"config_text_searches",
:type=>"config_text_search",
:body=>"{\"query\":{\"match\":{\"content\":\"foo\"}}}"},
@klass=[PROXY] ConfigTextSearch,
@options={}>>
[16] pry(main)> bob.results.total
=> 0
[17] pry(main)>
그냥 확인하시기 바랍니다 편집. – Ajay
죄송합니다, 아직 성공하지 못했습니다 ... 출력으로 업데이트하겠습니다. – dman
@dman, elasticsearch 기능에 보석을 사용하고 있습니까? – Ajay