Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.type :boolean for NtriplesRdfDatastream #321

Closed
acurley opened this issue Jan 15, 2014 · 2 comments
Closed

index.type :boolean for NtriplesRdfDatastream #321

acurley opened this issue Jan 15, 2014 · 2 comments

Comments

@acurley
Copy link
Contributor

acurley commented Jan 15, 2014

Is it possible to index an attribute in an NtriplesRDFDatastream as a :boolean? I see from the specs that :date, :text and :integer are possible (and they work against the master branch of ActiveFedora) but :boolean seems unsupported.

module RDF
  class MyRDF < Vocabulary("http://example.com/terms/")
    property :has_boolean
    property :number
  end
end

class MyDatastream < ActiveFedora::NtriplesRDFDatastream
  map_predicates do |map|
    map.has_boolean(in: RDF::MyRDF) do |index|
      index.type :boolean
      index.as :stored_searchable
    end
    map.number(in: RDF::MyRDF) do |index|
      index.type :integer
      index.as :stored_searchable
    end
  end
end

class MyObject < ActiveFedora::Base
  has_metadata :name=>'rdf', :type=>MyDatastream
  has_attributes :has_boolean, :number, datastream: 'rdf', multiple: false
end

Given the above the following are true:

MyObject.defined_attributes[:has_boolean].type == :boolean
MyObject.defined_attributes[:number].type == :integer
MyObject.defined_attributes[:has_boolean].primary_solr_name == "rdf__has_boolean_bsi"
MyObject.defined_attributes[:number].primary_solr_name == "rdf__number_isim"

So far so good! But when it comes to .to_solr, things don't work for the :has_boolean column.

m = MyObject.create(has_boolean: true, number: 2)
pp m.to_solr => 
....
 "rdf__has_boolean_tesim"=>["true"],
 "rdf__number_isim"=>["2"],
...

I cannot figure out how or why the field changes from _bsi to _tesim. Any ideas?

@jcoyne
Copy link
Member

jcoyne commented Jan 15, 2014

It may not be possible now, but you could submit that as a pull request. Otherwise, I suggest overriding #to_solr on your datastream to manually add that field to the solr document.

@no-reply
Copy link
Contributor

This is patched in AF 7.0 RC3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants