GithubHelp home page GithubHelp logo

Undefined method facets about retire HOT 8 CLOSED

karmi avatar karmi commented on September 15, 2024
Undefined method facets

from retire.

Comments (8)

karmi avatar karmi commented on September 15, 2024

Hi, you named your facet commercial_type, not tags, see https://gist.github.com/e2811c9f99b9be2b4f67

See also the docs on ES facets, http://www.elasticsearch.org/guide/reference/api/search/facets/index.html!

from retire.

kbaum avatar kbaum commented on September 15, 2024

Hi. I fixed that... but i noticed that you don't need results anymore. So the example should be:

s.facets['commercial_type']['terms'].each do |f|
   puts "#{f['term'].ljust(10)} #{f['count']}"
end

The above works. I think the documentation needs some updating?

Thanks for your help!

from retire.

karmi avatar karmi commented on September 15, 2024

Well, it's probably just some side effect, it should be accessed via results, see the integration tests...

from retire.

kbaum avatar kbaum commented on September 15, 2024

Strange though.. when i looked at the code, it makes sense that you would not need results. The search method returns Results::Collection.

def search(indices, options={}, &block)
  if block_given?
    Search::Search.new(indices, options, &block).perform
  else
    payload = case options
      when Hash    then options.to_json
      when String  then options
      else raise ArgumentError, "Please pass a Ruby Hash or String with JSON"
    end

    response = Configuration.client.post( "#{Configuration.url}/#{indices}/_search", payload)
    json     = MultiJson.decode(response.body)
    results  = Results::Collection.new(json, options)
  end

Results::Collection has a facets attr_reader

module Tire
  module Results

  class Collection
    include Enumerable
    include Pagination

    attr_reader :time, :total, :options, :results, :facets

from retire.

karmi avatar karmi commented on September 15, 2024

Yeah, but that's precisely why I wonder that you'd not need accessing it via the results method :)

from retire.

kbaum avatar kbaum commented on September 15, 2024

Not sure what you mean... the search method returns Results::Collection and there is a method on their facets.

Results::Collection#facets

Why would we need to call Results::Collection#results#facets?

thx

from retire.

karmi avatar karmi commented on September 15, 2024

Sorry, not enough time right now, you're right.

from retire.

kbaum avatar kbaum commented on September 15, 2024

Cool.. just as long as i am not going crazy. Thanks!

from retire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.