Giter Site home page Giter Site logo

Comments (3)

dipth avatar dipth commented on July 22, 2024

I'm using sunspot_rails 1.3.0

from sunspot.

JamesChevalier avatar JamesChevalier commented on July 22, 2024

I'm having similar trouble - the problem I'm having is a bit different in that it's only occurring when I pass more than one object through more_like_this, but the error it presents is extremely similar. Here's how my more_like_this call is a bit different from yours:

mlt_results = Sunspot.more_like_this(@article, Article, Video, Event) do
  fields :title
end

Here's the error that I get (again, slightly different from yours):
undefined method 'more_like_this_fields' for #<Sunspot::CompositeSetup:0x10e98d5a0>

I've been poking around trying to find the cause. I'm not certain, but I think the issue has something to do with the composite_setup.rb file.

The lib/sunspot/composite_setup.rb only has a def all_more_like_this_fields block ... it does not have a def more_like_this_fields block (see line 115 of composite_setup.rb).

If you check out line 156 of sunspot/lib/sunspot/setup.rb, you'll see that there's a def more_like_this_fields block. This handles the situation where one object is provided. If more than one object is provided, then sunspot can't handle it.

To get around the issue, I separated my more_like_this calls out, and then concatenated each of the separate results - like this:

mlt_articles = Sunspot.more_like_this(@article, Article) do
  fields :title
  with(:published_at).greater_than(1.months.ago)
end

mlt_videos = Sunspot.more_like_this(@article, Video) do
  fields :title
  with(:published_at).greater_than(1.months.ago)
end

@results = (mlt_articles + mlt_videos).sort! { |a,b| a.published_at <=> b.published_at }

from sunspot.

bragboy avatar bragboy commented on July 22, 2024

This must have been fixed with the latest version of the library. Please feel free to reopen if this still exist

from sunspot.

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.