Giter Site home page Giter Site logo

Comments (8)

alindeman avatar alindeman commented on July 22, 2024

Can you instead do something like this?

text :description do
  [desc_lvl1, desc_lvl2]
end

from sunspot.

abkonsta avatar abkonsta commented on July 22, 2024

I don't think so (just tried it to verify). The actual database field is "description", desc_lvl1 and desc_lvl2 are 'fakes' that I am trying to map "description" to, so I can index it in two different ways.

Only workaround so far is to treat them as different fields and carry two (or more) copies of this field in the database.

from sunspot.

alindeman avatar alindeman commented on July 22, 2024

Ahhh, I got my wires crossed. :as is the field name in Solr. For some reason I was thinking it was the method you wanted called to get the data from your model.

You'll want to do something like this:

searchable do
  text(:description_1, :as => :desc_lvl1) { description }
  text(:description_2, :as => :desc_lvl2) { description }
end

or use copyField on the Solr side: http://wiki.apache.org/solr/SchemaXml#Copy_Fields

from sunspot.

abkonsta avatar abkonsta commented on July 22, 2024

Your response did give me a few ideas and here is what worked

    text :desc_sic_lvl1, :as => :desc_sic_lvl1 do
      description
    end
    text :srch_sic_lvl1, :as => :srch_sic_lvl1 do
      search_text
    end
    text :desc_sic_lvl2, :as => :desc_sic_lvl2 do
      description
    end
    text :srch_sic_lvl2, :as => :srch_sic_lvl2 do
      search_text
    end

but what I thought was interesting is that the following syntax does NOT work:

    text :desc_sic_lvl1, :as => :desc_sic_lvl1 { description }
    . . .

from sunspot.

alindeman avatar alindeman commented on July 22, 2024

You'll need parens around text if you want to use { }, yah. Ruby can't really tell the difference between a Hash and a Proc otherwise.

from sunspot.

alindeman avatar alindeman commented on July 22, 2024

Can I close this issue?

from sunspot.

abkonsta avatar abkonsta commented on July 22, 2024

yes with { } it should be

text(:desc_sic_lvl1, :as => :desc_sic_lvl1, :boost => 3.0) { description }
text(:desc_sic_lvl2, :as => :desc_sic_lvl2, :boost => 1.0) { description }

So, not an issue after all, just me being a bit thick!

from sunspot.

alindeman avatar alindeman commented on July 22, 2024

Glad you got it working :)

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.