active-fedora 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +30 -0
- data/.gitmodules +3 -0
- data/.rvmrc +33 -0
- data/CONSOLE_GETTING_STARTED.textile +337 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +39 -23
- data/NOKOGIRI_DATASTREAMS.textile +107 -0
- data/README.textile +41 -17
- data/Rakefile +5 -30
- data/active-fedora.gemspec +34 -496
- data/lib/active_fedora.rb +6 -1
- data/lib/active_fedora/base.rb +7 -5
- data/lib/active_fedora/datastream.rb +9 -8
- data/lib/active_fedora/metadata_datastream.rb +10 -3
- data/lib/active_fedora/model.rb +8 -4
- data/lib/active_fedora/nokogiri_datastream.rb +30 -24
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +3 -2
- data/lib/active_fedora/rels_ext_datastream.rb +14 -5
- data/lib/active_fedora/samples.rb +3 -0
- data/lib/active_fedora/samples/hydra-mods_article_datastream.rb +517 -0
- data/lib/active_fedora/samples/hydra-rights_metadata_datastream.rb +206 -0
- data/lib/active_fedora/samples/marpa-dc_datastream.rb +97 -0
- data/lib/active_fedora/samples/special_thing.rb +45 -0
- data/lib/active_fedora/semantic_node.rb +16 -13
- data/lib/active_fedora/version.rb +3 -0
- data/lib/fedora/base.rb +5 -5
- data/lib/fedora/datastream.rb +1 -1
- data/lib/fedora/fedora_object.rb +1 -1
- data/lib/fedora/repository.rb +4 -0
- data/lib/tasks/active_fedora.rake +126 -0
- data/lib/tasks/active_fedora_dev.rake +127 -0
- data/solr/conf/schema.xml +278 -0
- data/solr/conf/solrconfig.xml +840 -0
- data/spec/integration/full_featured_model_spec.rb +2 -2
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/nokogiri_datastream_spec.rb +2 -2
- data/spec/rcov.opts +2 -0
- data/spec/samples/models/hydrangea_article.rb +12 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/nokogiri_datastream_spec.rb +10 -7
- metadata +189 -886
- data/NG_XML_DATASTREAM.textile +0 -25
- data/USING_OM_DATASTREAMS.textile +0 -60
- data/VERSION +0 -1
- data/lib/hydra.rb +0 -2
- data/lib/hydra/sample_mods_datastream.rb +0 -63
- data/tasks/hoe.rake +0 -0
- data/tasks/rspec.rake +0 -29
data/lib/fedora/fedora_object.rb
CHANGED
@@ -153,7 +153,7 @@ class Fedora::FedoraObject < Fedora::BaseObject
|
|
153
153
|
"fedora:info/#{pid}"
|
154
154
|
end
|
155
155
|
|
156
|
-
# @
|
156
|
+
# @return [String] url of the datastream in Fedora, without the repository userinfo
|
157
157
|
def url
|
158
158
|
repo_url = Fedora::Repository.instance.fedora_url
|
159
159
|
return "#{repo_url.scheme}://#{repo_url.host}:#{repo_url.port}#{repo_url.path}/objects/#{pid}"
|
data/lib/fedora/repository.rb
CHANGED
@@ -98,6 +98,10 @@ module Fedora
|
|
98
98
|
convert_xml(connection.get("#{fedora_url.path}/objects?#{params.to_fedora_query}#{includes}"))
|
99
99
|
end
|
100
100
|
|
101
|
+
# Retrieve an object from fedora and load it as an instance of the given model/class
|
102
|
+
#
|
103
|
+
# @param pid of the Fedora object to retrieve and deserialize
|
104
|
+
# @param klazz the Model whose deserialize method the object's FOXML will be passed into
|
101
105
|
def find_model(pid, klazz)
|
102
106
|
obj = self.find_objects("pid=#{pid}").first
|
103
107
|
if obj.nil?
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# require File.expand_path(File.dirname(__FILE__) + '/hydra_jetty.rb')
|
2
|
+
require "active-fedora"
|
3
|
+
require "solrizer-fedora"
|
4
|
+
require "active_support" # This is just to load ActiveSupport::CoreExtensions::String::Inflections
|
5
|
+
namespace :af do
|
6
|
+
|
7
|
+
|
8
|
+
desc "Delete and re-import the fixture identified by pid"
|
9
|
+
task :refresh_fixture => [:delete,:import_fixture]
|
10
|
+
|
11
|
+
desc "Delete the object identified by pid. Example: rake fedora:delete pid=demo:12"
|
12
|
+
task :delete => :init do
|
13
|
+
# If a destination url has been provided, attampt to export from the fedora repository there.
|
14
|
+
if ENV["destination"]
|
15
|
+
Fedora::Repository.register(ENV["destination"])
|
16
|
+
end
|
17
|
+
|
18
|
+
if ENV["pid"].nil?
|
19
|
+
puts "You must specify a valid pid. Example: rake fedora:delete pid=demo:12"
|
20
|
+
else
|
21
|
+
pid = ENV["pid"]
|
22
|
+
puts "Deleting '#{pid}' from #{Fedora::Repository.instance.fedora_url}"
|
23
|
+
begin
|
24
|
+
ActiveFedora::Base.load_instance(pid).delete
|
25
|
+
rescue ActiveFedora::ObjectNotFoundError
|
26
|
+
puts "The object #{pid} has already been deleted (or was never created)."
|
27
|
+
rescue Errno::ECONNREFUSED => e
|
28
|
+
puts "Can't connect to Fedora! Are you sure jetty is running?"
|
29
|
+
rescue Fedora::ServerError => e
|
30
|
+
logger.error("Received a Fedora error while deleting #{pid}")
|
31
|
+
end
|
32
|
+
logger.info "Deleted '#{pid}' from #{Fedora::Repository.instance.fedora_url}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Delete a range of objects in a given namespace. ie 'rake fedora:purge_range[demo, 22, 50]' will delete demo:22 through demo:50"
|
37
|
+
task :purge_range => :init do |t, args|
|
38
|
+
# If Fedora Repository connection is not already initialized, initialize it using ActiveFedora defaults
|
39
|
+
# ActiveFedora.init unless Thread.current[:repo]
|
40
|
+
|
41
|
+
namespace = ENV["namespace"]
|
42
|
+
start_point = ENV["start"].to_i
|
43
|
+
stop_point = ENV["stop"].to_i
|
44
|
+
unless start_point < stop_point
|
45
|
+
raise StandardError "start point must be less that end point."
|
46
|
+
end
|
47
|
+
puts "Deleting #{stop_point - start_point} objects from #{namespace}:#{start_point.to_s} to #{namespace}:#{stop_point.to_s}"
|
48
|
+
i = start_point
|
49
|
+
while i <= stop_point do
|
50
|
+
pid = namespace + ":" + i.to_s
|
51
|
+
begin
|
52
|
+
ActiveFedora::Base.load_instance(pid).delete
|
53
|
+
rescue ActiveFedora::ObjectNotFoundError
|
54
|
+
# The object has already been deleted (or was never created). Do nothing.
|
55
|
+
end
|
56
|
+
puts "Deleted '#{pid}' from #{Fedora::Repository.instance.fedora_url}"
|
57
|
+
i += 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Export the object identified by pid into spec/fixtures. Example:rake fedora:harvest_fixture pid=druid:sb733gr4073 source=http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora"
|
62
|
+
task :harvest_fixture => :init do
|
63
|
+
|
64
|
+
# If a source url has been provided, attampt to export from the fedora repository there.
|
65
|
+
if ENV["source"]
|
66
|
+
Fedora::Repository.register(ENV["source"])
|
67
|
+
end
|
68
|
+
|
69
|
+
if ENV["pid"].nil?
|
70
|
+
puts "You must specify a valid pid. Example: rake fedora:harvest_fixture pid=demo:12"
|
71
|
+
else
|
72
|
+
pid = ENV["pid"]
|
73
|
+
puts "Exporting '#{pid}' from #{Fedora::Repository.instance.fedora_url}"
|
74
|
+
foxml = Fedora::Repository.instance.export(pid)
|
75
|
+
filename = File.join("spec","fixtures","#{pid.gsub(":","_")}.foxml.xml")
|
76
|
+
file = File.new(filename,"w")
|
77
|
+
file.syswrite(foxml)
|
78
|
+
puts "The object has been saved as #{filename}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Import the fixture located at the provided path. Example: rake fedora:import_fixture fixture=spec/fixtures/demo_12.foxml.xml"
|
83
|
+
task :import_fixture => [:init, :environment] do
|
84
|
+
|
85
|
+
# If a destination url has been provided, attampt to export from the fedora repository there.
|
86
|
+
if ENV["destination"]
|
87
|
+
Fedora::Repository.register(ENV["destination"])
|
88
|
+
end
|
89
|
+
|
90
|
+
if !ENV["fixture"].nil?
|
91
|
+
filename = ENV["fixture"]
|
92
|
+
elsif !ENV["pid"].nil?
|
93
|
+
pid = ENV["pid"]
|
94
|
+
filename = File.join("spec","fixtures","#{pid.gsub(":","_")}.foxml.xml")
|
95
|
+
else
|
96
|
+
puts "You must specify a path to the fixture or provide its pid. Example: rake fedora:import_fixture fixture=spec/fixtures/demo_12.foxml.xml"
|
97
|
+
end
|
98
|
+
|
99
|
+
if !filename.nil?
|
100
|
+
puts "Importing '#{filename}' to #{Fedora::Repository.instance.fedora_url}"
|
101
|
+
file = File.new(filename, "r")
|
102
|
+
result = foxml = Fedora::Repository.instance.ingest(file.read)
|
103
|
+
if result
|
104
|
+
puts "The fixture has been ingested as #{result.body}"
|
105
|
+
if !pid.nil?
|
106
|
+
solrizer = Solrizer::Fedora::Solrizer.new
|
107
|
+
solrizer.solrize(pid)
|
108
|
+
end
|
109
|
+
else
|
110
|
+
puts "Failed to ingest the fixture."
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
desc "Init ActiveFedora configuration"
|
118
|
+
task :init do
|
119
|
+
if !ENV["environment"].nil?
|
120
|
+
RAILS_ENV = ENV["environment"]
|
121
|
+
end
|
122
|
+
# If Fedora Repository connection is not already initialized, initialize it using ActiveFedora defaults
|
123
|
+
ActiveFedora.init unless Thread.current[:repo]
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
$: << 'lib'
|
18
|
+
|
19
|
+
desc "Run active-fedora rspec tests"
|
20
|
+
task :spec do
|
21
|
+
Rake::Task["active_fedora:rspec"].invoke
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Hudson build"
|
25
|
+
task :hudson do
|
26
|
+
require 'jettywrapper'
|
27
|
+
project_root = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
28
|
+
|
29
|
+
if (ENV['RAILS_ENV'] == "test")
|
30
|
+
Rake::Task["active_fedora:doc"].invoke
|
31
|
+
Rake::Task["active_fedora:configure_jetty"].invoke
|
32
|
+
jetty_params = {
|
33
|
+
:quiet => false,
|
34
|
+
:jetty_home => File.join(project_root,'jetty'),
|
35
|
+
:jetty_port => 8983,
|
36
|
+
:solr_home => File.expand_path(File.join(project_root,'jetty','solr')),
|
37
|
+
:fedora_home => File.expand_path(File.join(project_root,'jetty','fedora','default')),
|
38
|
+
:startup_wait=>30
|
39
|
+
}
|
40
|
+
error = Jettywrapper.wrap(jetty_params) do
|
41
|
+
Rake::Task["active_fedora:load_fixtures"].invoke
|
42
|
+
Rake::Task["active_fedora:rspec"].invoke
|
43
|
+
end
|
44
|
+
raise "test failures: #{error}" if error
|
45
|
+
else
|
46
|
+
system("rake hudson RAILS_ENV=test")
|
47
|
+
fail unless $?.success?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
namespace :active_fedora do
|
52
|
+
require 'lib/active-fedora'
|
53
|
+
|
54
|
+
# Use yard to build docs
|
55
|
+
begin
|
56
|
+
require 'yard'
|
57
|
+
require 'yard/rake/yardoc_task'
|
58
|
+
project_root = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
59
|
+
doc_destination = File.join(project_root, 'doc')
|
60
|
+
|
61
|
+
YARD::Rake::YardocTask.new(:doc) do |yt|
|
62
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
63
|
+
[ File.join(project_root, 'README.textile'),'-', File.join(project_root,'CONSOLE_GETTING_STARTED.textile'),'-', File.join(project_root,'NOKOGIRI_DATASTREAMS.textile') ]
|
64
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.textile']
|
65
|
+
end
|
66
|
+
rescue LoadError
|
67
|
+
desc "Generate YARD Documentation"
|
68
|
+
task :doc do
|
69
|
+
abort "Please install the YARD gem to generate rdoc."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
Spec::Rake::SpecTask.new(:rspec) do |t|
|
75
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
76
|
+
t.rcov = true
|
77
|
+
t.rcov_opts << ['--exclude', 'gems']
|
78
|
+
t.rcov_opts << ['--exclude', 'spec']
|
79
|
+
end
|
80
|
+
|
81
|
+
task :refresh_fixtures do
|
82
|
+
Rake::Task["active_fedora:clean_jetty"].invoke
|
83
|
+
Rake::Task["active_fedora:load_fixtures"].invoke
|
84
|
+
end
|
85
|
+
|
86
|
+
task :clean_jetty do
|
87
|
+
Dir.chdir("./jetty")
|
88
|
+
system("git clean -f -d")
|
89
|
+
system("git checkout .")
|
90
|
+
Dir.chdir("..")
|
91
|
+
end
|
92
|
+
|
93
|
+
task :load_fixtures => :environment do
|
94
|
+
require 'solrizer'
|
95
|
+
require 'solrizer-fedora'
|
96
|
+
require 'spec/samples/models/hydrangea_article'
|
97
|
+
ENV["FEDORA_HOME"]=File.expand_path(File.join(File.dirname(__FILE__),'..','..','jetty','fedora','default'))
|
98
|
+
retval = `$FEDORA_HOME/client/bin/fedora-ingest-demos.sh localhost 8983 fedoraAdmin fedoraAdmin http`
|
99
|
+
puts "loaded demo objects #{retval}"
|
100
|
+
ActiveFedora.init unless Thread.current[:repo]
|
101
|
+
|
102
|
+
ENV["pid"] = "hydrangea:fixture_mods_article1"
|
103
|
+
Rake::Task["af:refresh_fixture"].invoke
|
104
|
+
ENV["pid"] = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Copies the default SOLR config for the bundled Testing Server"
|
108
|
+
task :configure_jetty do
|
109
|
+
Rake::Task["active_fedora:clean_jetty"].invoke
|
110
|
+
FileList['solr/conf/*'].each do |f|
|
111
|
+
cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
|
112
|
+
cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
# Provides an :environment task for use while working within a working copy of active-fedora
|
119
|
+
# You should never load this rake file into any other application
|
120
|
+
desc 'Set up ActiveFedora environment. !! Only for use while working within a working copy of active-fedora'
|
121
|
+
task :environment do
|
122
|
+
puts "Initializing ActiveFedora Rake environment. This should only be called when working within a workign copy of the active-fedora code."
|
123
|
+
require 'spec/samples/models/hydrangea_article'
|
124
|
+
require 'active_fedora/samples'
|
125
|
+
# $:.unshift(File.dirname(__FILE__) + '/../lib')
|
126
|
+
# Dir[File.join(File.dirname(__FILE__)+'/../lib/')+'**/*.rb'].each{|x| require x}
|
127
|
+
end
|
@@ -0,0 +1,278 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!--
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
5
|
+
this work for additional information regarding copyright ownership.
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
8
|
+
the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
-->
|
18
|
+
|
19
|
+
<!--
|
20
|
+
This is the Solr schema file. This file should be named "schema.xml" and
|
21
|
+
should be in the conf directory under the solr home
|
22
|
+
(i.e. ./solr/conf/schema.xml by default)
|
23
|
+
or located where the classloader for the Solr webapp can find it.
|
24
|
+
|
25
|
+
This example schema is the recommended starting point for users.
|
26
|
+
It should be kept correct and concise, usable out-of-the-box.
|
27
|
+
|
28
|
+
For more information, on how to customize this file, please see
|
29
|
+
http://wiki.apache.org/solr/SchemaXml
|
30
|
+
-->
|
31
|
+
|
32
|
+
<schema name="salt" version="1.1">
|
33
|
+
<!-- attribute "name" is the name of this schema and is only used for display purposes.
|
34
|
+
Applications should change this to reflect the nature of the search collection.
|
35
|
+
version="1.1" is Solr's version number for the schema syntax and semantics. It should
|
36
|
+
not normally be changed by applications.
|
37
|
+
1.0: multiValued attribute did not exist, all fields are multiValued by nature
|
38
|
+
1.1: multiValued attribute introduced, false by default -->
|
39
|
+
|
40
|
+
<types>
|
41
|
+
<!-- field type definitions. The "name" attribute is
|
42
|
+
just a label to be used by field definitions. The "class"
|
43
|
+
attribute and any other attributes determine the real
|
44
|
+
behavior of the fieldType.
|
45
|
+
Class names starting with "solr" refer to java classes in the
|
46
|
+
org.apache.solr.analysis package.
|
47
|
+
-->
|
48
|
+
|
49
|
+
<!-- The StrField type is not analyzed, but indexed/stored verbatim.
|
50
|
+
- StrField and TextField support an optional compressThreshold which
|
51
|
+
limits compression (if enabled in the derived fields) to values which
|
52
|
+
exceed a certain size (in characters).
|
53
|
+
-->
|
54
|
+
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
|
55
|
+
|
56
|
+
<!-- boolean type: "true" or "false" -->
|
57
|
+
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
|
58
|
+
|
59
|
+
<!-- The optional sortMissingLast and sortMissingFirst attributes are
|
60
|
+
currently supported on types that are sorted internally as strings.
|
61
|
+
- If sortMissingLast="true", then a sort on this field will cause documents
|
62
|
+
without the field to come after documents with the field,
|
63
|
+
regardless of the requested sort order (asc or desc).
|
64
|
+
- If sortMissingFirst="true", then a sort on this field will cause documents
|
65
|
+
without the field to come before documents with the field,
|
66
|
+
regardless of the requested sort order.
|
67
|
+
- If sortMissingLast="false" and sortMissingFirst="false" (the default),
|
68
|
+
then default lucene sorting will be used which places docs without the
|
69
|
+
field first in an ascending sort and last in a descending sort.
|
70
|
+
-->
|
71
|
+
|
72
|
+
|
73
|
+
<!-- numeric field types that store and index the text
|
74
|
+
value verbatim (and hence don't support range queries, since the
|
75
|
+
lexicographic ordering isn't equal to the numeric ordering) -->
|
76
|
+
<fieldType name="integer" class="solr.IntField" omitNorms="true"/>
|
77
|
+
<fieldType name="long" class="solr.LongField" omitNorms="true"/>
|
78
|
+
<fieldType name="float" class="solr.FloatField" omitNorms="true"/>
|
79
|
+
<fieldType name="double" class="solr.DoubleField" omitNorms="true"/>
|
80
|
+
|
81
|
+
|
82
|
+
<!-- Numeric field types that manipulate the value into
|
83
|
+
a string value that isn't human-readable in its internal form,
|
84
|
+
but with a lexicographic ordering the same as the numeric ordering,
|
85
|
+
so that range queries work correctly. -->
|
86
|
+
<fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
|
87
|
+
<fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
|
88
|
+
<fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
|
89
|
+
<fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>
|
90
|
+
|
91
|
+
|
92
|
+
<!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
|
93
|
+
is a more restricted form of the canonical representation of dateTime
|
94
|
+
http://www.w3.org/TR/xmlschema-2/#dateTime
|
95
|
+
The trailing "Z" designates UTC time and is mandatory.
|
96
|
+
Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
|
97
|
+
All other components are mandatory.
|
98
|
+
|
99
|
+
Expressions can also be used to denote calculations that should be
|
100
|
+
performed relative to "NOW" to determine the value, ie...
|
101
|
+
|
102
|
+
NOW/HOUR
|
103
|
+
... Round to the start of the current hour
|
104
|
+
NOW-1DAY
|
105
|
+
... Exactly 1 day prior to now
|
106
|
+
NOW/DAY+6MONTHS+3DAYS
|
107
|
+
... 6 months and 3 days in the future from the start of
|
108
|
+
the current day
|
109
|
+
|
110
|
+
Consult the DateField javadocs for more information.
|
111
|
+
-->
|
112
|
+
<fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>
|
113
|
+
|
114
|
+
|
115
|
+
<!-- The "RandomSortField" is not used to store or search any
|
116
|
+
data. You can declare fields of this type it in your schema
|
117
|
+
to generate psuedo-random orderings of your docs for sorting
|
118
|
+
purposes. The ordering is generated based on the field name
|
119
|
+
and the version of the index, As long as the index version
|
120
|
+
remains unchanged, and the same field name is reused,
|
121
|
+
the ordering of the docs will be consistent.
|
122
|
+
If you want differend psuedo-random orderings of documents,
|
123
|
+
for the same version of the index, use a dynamicField and
|
124
|
+
change the name
|
125
|
+
-->
|
126
|
+
<fieldType name="random" class="solr.RandomSortField" indexed="true" />
|
127
|
+
|
128
|
+
<!-- solr.TextField allows the specification of custom text analyzers
|
129
|
+
specified as a tokenizer and a list of token filters. Different
|
130
|
+
analyzers may be specified for indexing and querying.
|
131
|
+
|
132
|
+
The optional positionIncrementGap puts space between multiple fields of
|
133
|
+
this type on the same document, with the purpose of preventing false phrase
|
134
|
+
matching across fields.
|
135
|
+
|
136
|
+
For more info on customizing your analyzer chain, please see
|
137
|
+
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters
|
138
|
+
-->
|
139
|
+
|
140
|
+
<!-- One can also specify an existing Analyzer class that has a
|
141
|
+
default constructor via the class attribute on the analyzer element
|
142
|
+
<fieldType name="text_greek" class="solr.TextField">
|
143
|
+
<analyzer class="org.apache.lucene.analysis.el.GreekAnalyzer"/>
|
144
|
+
</fieldType>
|
145
|
+
-->
|
146
|
+
|
147
|
+
<!-- A text field that only splits on whitespace for exact matching of words -->
|
148
|
+
<fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
|
149
|
+
<analyzer>
|
150
|
+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
|
151
|
+
</analyzer>
|
152
|
+
</fieldType>
|
153
|
+
|
154
|
+
<!-- A text field that uses WordDelimiterFilter to enable splitting and matching of
|
155
|
+
words on case-change, alpha numeric boundaries, and non-alphanumeric chars,
|
156
|
+
so that a query of "wifi" or "wi fi" could match a document containing "Wi-Fi".
|
157
|
+
Synonyms and stopwords are customized by external files, and stemming is enabled.
|
158
|
+
Duplicate tokens at the same position (which may result from Stemmed Synonyms or
|
159
|
+
WordDelim parts) are removed.
|
160
|
+
-->
|
161
|
+
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
|
162
|
+
<analyzer type="index">
|
163
|
+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
|
164
|
+
<!-- in this example, we will only use synonyms at query time
|
165
|
+
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
|
166
|
+
-->
|
167
|
+
<!-- Case insensitive stop word removal.
|
168
|
+
enablePositionIncrements=true ensures that a 'gap' is left to
|
169
|
+
allow for accurate phrase queries.
|
170
|
+
-->
|
171
|
+
<filter class="solr.StopFilterFactory"
|
172
|
+
ignoreCase="true"
|
173
|
+
words="stopwords.txt"
|
174
|
+
enablePositionIncrements="true"
|
175
|
+
/>
|
176
|
+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
|
177
|
+
<filter class="solr.LowerCaseFilterFactory"/>
|
178
|
+
<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
|
179
|
+
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
|
180
|
+
</analyzer>
|
181
|
+
<analyzer type="query">
|
182
|
+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
|
183
|
+
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
|
184
|
+
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
|
185
|
+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
|
186
|
+
<filter class="solr.LowerCaseFilterFactory"/>
|
187
|
+
<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
|
188
|
+
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
|
189
|
+
</analyzer>
|
190
|
+
</fieldType>
|
191
|
+
|
192
|
+
|
193
|
+
<!-- Less flexible matching, but less false matches. Probably not ideal for product names,
|
194
|
+
but may be good for SKUs. Can insert dashes in the wrong place and still match. -->
|
195
|
+
<fieldType name="textTight" class="solr.TextField" positionIncrementGap="100" >
|
196
|
+
<analyzer>
|
197
|
+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
|
198
|
+
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
|
199
|
+
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
|
200
|
+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
|
201
|
+
<filter class="solr.LowerCaseFilterFactory"/>
|
202
|
+
<filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
|
203
|
+
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
|
204
|
+
</analyzer>
|
205
|
+
</fieldType>
|
206
|
+
|
207
|
+
<!-- This is an example of using the KeywordTokenizer along
|
208
|
+
With various TokenFilterFactories to produce a sortable field
|
209
|
+
that does not include some properties of the source text
|
210
|
+
-->
|
211
|
+
<fieldType name="alphaOnlySort" class="solr.TextField" sortMissingLast="true" omitNorms="true">
|
212
|
+
<analyzer>
|
213
|
+
<!-- KeywordTokenizer does no actual tokenizing, so the entire
|
214
|
+
input string is preserved as a single token
|
215
|
+
-->
|
216
|
+
<tokenizer class="solr.KeywordTokenizerFactory"/>
|
217
|
+
<!-- The LowerCase TokenFilter does what you expect, which can be
|
218
|
+
when you want your sorting to be case insensitive
|
219
|
+
-->
|
220
|
+
<filter class="solr.LowerCaseFilterFactory" />
|
221
|
+
<!-- The TrimFilter removes any leading or trailing whitespace -->
|
222
|
+
<filter class="solr.TrimFilterFactory" />
|
223
|
+
<!-- The PatternReplaceFilter gives you the flexibility to use
|
224
|
+
Java Regular expression to replace any sequence of characters
|
225
|
+
matching a pattern with an arbitrary replacement string,
|
226
|
+
which may include back refrences to portions of the orriginal
|
227
|
+
string matched by the pattern.
|
228
|
+
|
229
|
+
See the Java Regular Expression documentation for more
|
230
|
+
infomation on pattern and replacement string syntax.
|
231
|
+
|
232
|
+
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
|
233
|
+
-->
|
234
|
+
<filter class="solr.PatternReplaceFilterFactory"
|
235
|
+
pattern="([^a-z])" replacement="" replace="all"
|
236
|
+
/>
|
237
|
+
</analyzer>
|
238
|
+
</fieldType>
|
239
|
+
|
240
|
+
<!-- since fields of this type are by default not stored or indexed, any data added to
|
241
|
+
them will be ignored outright
|
242
|
+
-->
|
243
|
+
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
|
244
|
+
|
245
|
+
</types>
|
246
|
+
|
247
|
+
<fields>
|
248
|
+
|
249
|
+
<field name="id" type="string" indexed="true" stored="true" required="true" />
|
250
|
+
<field name="text" type="text" indexed="true" stored="true" multiValued="true"/>
|
251
|
+
<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
|
252
|
+
|
253
|
+
<!-- format is used for facet, display, and choosing which partial to use for the show view, so it must be stored and indexed -->
|
254
|
+
<field name="format" type="string" indexed="true" stored="true"/>
|
255
|
+
|
256
|
+
<dynamicField name="*_i" type="sint" indexed="true" stored="true"/>
|
257
|
+
<dynamicField name="*_s" type="string" indexed="true" stored="true" multiValued="true"/>
|
258
|
+
<dynamicField name="*_l" type="slong" indexed="true" stored="true"/>
|
259
|
+
<dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="true"/>
|
260
|
+
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
|
261
|
+
<dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/>
|
262
|
+
<dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/>
|
263
|
+
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
|
264
|
+
|
265
|
+
<dynamicField name="random*" type="random" />
|
266
|
+
|
267
|
+
<dynamicField name="*_sort" type="string" indexed="true" stored="false" multiValued="true" />
|
268
|
+
<dynamicField name="*_facet" type="string" indexed="true" stored="true" multiValued="true" />
|
269
|
+
<dynamicField name="*_display" type="string" indexed="false" stored="true" multiValued="true" />
|
270
|
+
|
271
|
+
</fields>
|
272
|
+
|
273
|
+
<uniqueKey>id</uniqueKey>
|
274
|
+
<defaultSearchField>text</defaultSearchField>
|
275
|
+
<solrQueryParser defaultOperator="AND" />
|
276
|
+
<copyField source="*_facet" dest="text" />
|
277
|
+
|
278
|
+
</schema>
|