Created
September 19, 2013 19:14
-
-
Save mulderp/6628444 to your computer and use it in GitHub Desktop.
Stretcher test new SearchResults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server = Stretcher::Server.new('http://localhost:9200', :log_level => :debug) | |
server.index(:moviesdb1).create(mappings: {movie: {properties: {title: {type: 'string'}, genres: {type: 'string', index_name: 'genre1'}}}}) | |
# [Stretcher][DEBUG]: curl -XPUT http://localhost:9200/moviesdb1 -d '{"mappings":{"movie":{"properties":{"title":{"type":"string"},"genres":{"type":"string","index_name":"genre1"}}}}}' '-H Accept: application/json' '-H Content-Type: application/json' '-H User-Agent: Stretcher Ruby Gem 1.20.0.beta1' | |
# => #<Hashie::Mash acknowledged=true ok=true> | |
server.index(:moviesdb1).type(:movie).put(1, { title: 'The Artist', genres: ['Drama', 'Comedy']}) | |
server.index(:moviesdb1).type(:movie).put(2, { title: 'Taxi Driver', genres: ['Drama', 'Action']}) | |
puts server.index(:moviesdb1).type(:movie).get(1) | |
# => #<Hashie::Mash genres=["Drama", "Comedy"] title="The Artist"> | |
rs = server.index(:moviesdb1).search(size: 12, query: {match_all: {}}) | |
# [Stretcher][DEBUG]: curl -XGET http://localhost:9200/moviesdb1/_search -d '{"size":12,"query":{"match_all":{}}}' '-H Accept: application/json' '-H Content-Type: application/json' '-H User-Agent: Stretcher Ruby Gem 1.20.0.beta1' | |
# | |
# => #<Stretcher::SearchResults:0x007fc74ae1cc38 @raw_plain=#<Hashie::Mash _shards=#<Hashie::Mash failed=0 successful=5 total=5> hits=#<Hashie::Mash hits=[#<Hashie::Mash _id="1" _index="moviesdb1" _score=1.0 _source=#<Hashie::Mash genres=["Drama", "Comedy"] title="The Artist"> _type="movie">, #<Hashie::Mash _id="2" _index="moviesdb1" _score=1.0 _source=#<Hashie::Mash genres=["Drama", "Action"] title="Taxi Driver"> _type="movie">] max_score=1.0 total=2> timed_out=false took=1>> | |
# | |
rs.class | |
rs.total | |
# => 2 | |
rs.documents | |
# NoMethodError: undefined method `documents' for #<Stretcher::SearchResults:0x007fc74ae1cc38> | |
# from (irb):18 | |
# from /Users/pmu/.rbenv/versions/2.0.0-p0/bin/irb:12:in `<main>' | |
# irb(main):019:0> rs.facets | |
# => nil | |
# irb(main):020:0> rs.hits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I've the same issue. Did you solve it?
Cheers