datastax_rails 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +62 -0
  3. data/Rakefile +34 -0
  4. data/config/schema.xml +266 -0
  5. data/config/schema.xml.erb +70 -0
  6. data/config/solrconfig.xml +1564 -0
  7. data/config/stopwords.txt +58 -0
  8. data/lib/datastax_rails/associations/association.rb +224 -0
  9. data/lib/datastax_rails/associations/association_scope.rb +25 -0
  10. data/lib/datastax_rails/associations/belongs_to_association.rb +64 -0
  11. data/lib/datastax_rails/associations/builder/association.rb +56 -0
  12. data/lib/datastax_rails/associations/builder/belongs_to.rb +30 -0
  13. data/lib/datastax_rails/associations/builder/collection_association.rb +48 -0
  14. data/lib/datastax_rails/associations/builder/has_and_belongs_to_many.rb +36 -0
  15. data/lib/datastax_rails/associations/builder/has_many.rb +54 -0
  16. data/lib/datastax_rails/associations/builder/has_one.rb +52 -0
  17. data/lib/datastax_rails/associations/builder/singular_association.rb +56 -0
  18. data/lib/datastax_rails/associations/collection_association.rb +274 -0
  19. data/lib/datastax_rails/associations/collection_proxy.rb +118 -0
  20. data/lib/datastax_rails/associations/has_and_belongs_to_many_association.rb +44 -0
  21. data/lib/datastax_rails/associations/has_many_association.rb +58 -0
  22. data/lib/datastax_rails/associations/has_one_association.rb +68 -0
  23. data/lib/datastax_rails/associations/singular_association.rb +58 -0
  24. data/lib/datastax_rails/associations.rb +86 -0
  25. data/lib/datastax_rails/attribute_methods/definition.rb +20 -0
  26. data/lib/datastax_rails/attribute_methods/dirty.rb +43 -0
  27. data/lib/datastax_rails/attribute_methods/typecasting.rb +50 -0
  28. data/lib/datastax_rails/attribute_methods.rb +104 -0
  29. data/lib/datastax_rails/base.rb +587 -0
  30. data/lib/datastax_rails/batches.rb +35 -0
  31. data/lib/datastax_rails/callbacks.rb +37 -0
  32. data/lib/datastax_rails/collection.rb +9 -0
  33. data/lib/datastax_rails/connection.rb +21 -0
  34. data/lib/datastax_rails/consistency.rb +33 -0
  35. data/lib/datastax_rails/cql/base.rb +15 -0
  36. data/lib/datastax_rails/cql/column_family.rb +38 -0
  37. data/lib/datastax_rails/cql/consistency.rb +13 -0
  38. data/lib/datastax_rails/cql/create_column_family.rb +63 -0
  39. data/lib/datastax_rails/cql/create_keyspace.rb +30 -0
  40. data/lib/datastax_rails/cql/delete.rb +41 -0
  41. data/lib/datastax_rails/cql/drop_column_family.rb +13 -0
  42. data/lib/datastax_rails/cql/drop_keyspace.rb +13 -0
  43. data/lib/datastax_rails/cql/insert.rb +53 -0
  44. data/lib/datastax_rails/cql/select.rb +51 -0
  45. data/lib/datastax_rails/cql/truncate.rb +13 -0
  46. data/lib/datastax_rails/cql/update.rb +68 -0
  47. data/lib/datastax_rails/cql/use_keyspace.rb +13 -0
  48. data/lib/datastax_rails/cql.rb +25 -0
  49. data/lib/datastax_rails/cursor.rb +90 -0
  50. data/lib/datastax_rails/errors.rb +16 -0
  51. data/lib/datastax_rails/identity/abstract_key_factory.rb +26 -0
  52. data/lib/datastax_rails/identity/custom_key_factory.rb +36 -0
  53. data/lib/datastax_rails/identity/hashed_natural_key_factory.rb +10 -0
  54. data/lib/datastax_rails/identity/natural_key_factory.rb +37 -0
  55. data/lib/datastax_rails/identity/uuid_key_factory.rb +23 -0
  56. data/lib/datastax_rails/identity.rb +53 -0
  57. data/lib/datastax_rails/log_subscriber.rb +37 -0
  58. data/lib/datastax_rails/migrations/migration.rb +15 -0
  59. data/lib/datastax_rails/migrations.rb +36 -0
  60. data/lib/datastax_rails/mocking.rb +15 -0
  61. data/lib/datastax_rails/persistence.rb +133 -0
  62. data/lib/datastax_rails/railtie.rb +20 -0
  63. data/lib/datastax_rails/reflection.rb +472 -0
  64. data/lib/datastax_rails/relation/finder_methods.rb +184 -0
  65. data/lib/datastax_rails/relation/modification_methods.rb +80 -0
  66. data/lib/datastax_rails/relation/search_methods.rb +349 -0
  67. data/lib/datastax_rails/relation/spawn_methods.rb +107 -0
  68. data/lib/datastax_rails/relation.rb +393 -0
  69. data/lib/datastax_rails/schema/migration.rb +106 -0
  70. data/lib/datastax_rails/schema/migration_proxy.rb +25 -0
  71. data/lib/datastax_rails/schema/migrator.rb +212 -0
  72. data/lib/datastax_rails/schema.rb +37 -0
  73. data/lib/datastax_rails/scoping.rb +394 -0
  74. data/lib/datastax_rails/serialization.rb +6 -0
  75. data/lib/datastax_rails/tasks/column_family.rb +162 -0
  76. data/lib/datastax_rails/tasks/ds.rake +63 -0
  77. data/lib/datastax_rails/tasks/keyspace.rb +57 -0
  78. data/lib/datastax_rails/timestamps.rb +19 -0
  79. data/lib/datastax_rails/type.rb +16 -0
  80. data/lib/datastax_rails/types/array_type.rb +77 -0
  81. data/lib/datastax_rails/types/base_type.rb +26 -0
  82. data/lib/datastax_rails/types/binary_type.rb +15 -0
  83. data/lib/datastax_rails/types/boolean_type.rb +22 -0
  84. data/lib/datastax_rails/types/date_type.rb +17 -0
  85. data/lib/datastax_rails/types/float_type.rb +18 -0
  86. data/lib/datastax_rails/types/integer_type.rb +18 -0
  87. data/lib/datastax_rails/types/string_type.rb +16 -0
  88. data/lib/datastax_rails/types/text_type.rb +16 -0
  89. data/lib/datastax_rails/types/time_type.rb +17 -0
  90. data/lib/datastax_rails/types.rb +9 -0
  91. data/lib/datastax_rails/validations/uniqueness.rb +119 -0
  92. data/lib/datastax_rails/validations.rb +48 -0
  93. data/lib/datastax_rails/version.rb +3 -0
  94. data/lib/datastax_rails.rb +87 -0
  95. data/lib/solr_no_escape.rb +28 -0
  96. data/spec/datastax_rails/associations/belongs_to_association_spec.rb +7 -0
  97. data/spec/datastax_rails/associations/has_many_association_spec.rb +37 -0
  98. data/spec/datastax_rails/associations_spec.rb +22 -0
  99. data/spec/datastax_rails/attribute_methods_spec.rb +23 -0
  100. data/spec/datastax_rails/base_spec.rb +15 -0
  101. data/spec/datastax_rails/cql/select_spec.rb +12 -0
  102. data/spec/datastax_rails/cql/update_spec.rb +0 -0
  103. data/spec/datastax_rails/relation/finder_methods_spec.rb +54 -0
  104. data/spec/datastax_rails/relation/modification_methods_spec.rb +41 -0
  105. data/spec/datastax_rails/relation/search_methods_spec.rb +117 -0
  106. data/spec/datastax_rails/relation/spawn_methods_spec.rb +28 -0
  107. data/spec/datastax_rails/relation_spec.rb +130 -0
  108. data/spec/datastax_rails/validations/uniqueness_spec.rb +41 -0
  109. data/spec/datastax_rails_spec.rb +5 -0
  110. data/spec/dummy/Rakefile +8 -0
  111. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  112. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  113. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  114. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  115. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  116. data/spec/dummy/config/application.rb +47 -0
  117. data/spec/dummy/config/boot.rb +10 -0
  118. data/spec/dummy/config/database.yml +25 -0
  119. data/spec/dummy/config/datastax.yml +18 -0
  120. data/spec/dummy/config/environment.rb +5 -0
  121. data/spec/dummy/config/environments/development.rb +30 -0
  122. data/spec/dummy/config/environments/production.rb +60 -0
  123. data/spec/dummy/config/environments/test.rb +39 -0
  124. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  125. data/spec/dummy/config/initializers/inflections.rb +10 -0
  126. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  127. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  128. data/spec/dummy/config/initializers/session_store.rb +8 -0
  129. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  130. data/spec/dummy/config/locales/en.yml +5 -0
  131. data/spec/dummy/config/routes.rb +58 -0
  132. data/spec/dummy/config/sunspot.yml +17 -0
  133. data/spec/dummy/config.ru +4 -0
  134. data/spec/dummy/ks/migrate/20111117224534_models.rb +20 -0
  135. data/spec/dummy/ks/schema.json +180 -0
  136. data/spec/dummy/log/development.log +298 -0
  137. data/spec/dummy/log/production.log +0 -0
  138. data/spec/dummy/log/test.log +20307 -0
  139. data/spec/dummy/public/404.html +26 -0
  140. data/spec/dummy/public/422.html +26 -0
  141. data/spec/dummy/public/500.html +26 -0
  142. data/spec/dummy/public/favicon.ico +0 -0
  143. data/spec/dummy/script/rails +6 -0
  144. data/spec/spec.opts +5 -0
  145. data/spec/spec_helper.rb +29 -0
  146. data/spec/support/datastax_test_hook.rb +14 -0
  147. data/spec/support/models.rb +72 -0
  148. metadata +353 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2012 [Jason M. Kusar]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,62 @@
1
+ = datastax_rails
2
+ ==============
3
+
4
+ A Ruby-on-Rails interface to Datastax Enterprise (specifically DSE Search nodes). Replaces the majority of ActiveRecord functionality.
5
+
6
+ This gem is based heavily on the excellent CassandraObject gem (https://github.com/data-axle/cassandra_object) as well as some work I initially
7
+ did in the form of SolandraObject (https://github.com/jasonmk/solandra_object). We made the decision to move away from Solandra and to
8
+ Datastax Enterprise, thus datastax_rails was born.
9
+
10
+ Significant changes from SolandraObject:
11
+
12
+ * Cassandra communication is now entirely CQL-based
13
+ * Solr communication is now handled directly via RSolr
14
+ * Bifurcation of data is no longer necessary as DSE writes data to SOLR automatically
15
+
16
+ === Usage Note
17
+
18
+ Before using this gem, you should probably take a strong look at the type of problem you are trying to solve. Cassandra is primarily
19
+ designed as a solution to Big Data problems. This gem is not. You will notice that it still carries a lot of relational logic with it.
20
+ We are using DSE to solve a replication problem more so than a Big Data problem. That's not to say that this gem won't work for Big Data problems,
21
+ it just might not be ideal. You've been warned...
22
+
23
+ === Getting started
24
+
25
+ First add it to your Gemfile:
26
+
27
+ gem 'datastax_rails'
28
+
29
+ Configure the config/datastax.yml file:
30
+
31
+ development:
32
+ servers: ["localhost:9160"]
33
+ keyspace: "<my_app>_development"
34
+ strategy_class: "org.apache.cassandra.locator.NetworkTopologyStrategy"
35
+ strategy_options: {"DC1": "1"}
36
+ solr:
37
+ url: http://localhost:8983/solr
38
+
39
+ The above is configured to use NetworkTopologyStrategy. If you go with this, you'll need to configure Datastax to use the
40
+ NetworkTopologySnitch and set up the cassandra-topology.properties file. See the Datastax documentation for more information.
41
+ For a more simple, single datacenter setup, something like this should probably work:
42
+
43
+ development:
44
+ servers: ["localhost:9160"]
45
+ keyspace: "<my_app>_development"
46
+ strategy_class: "org.apache.cassandra.locator.SimpleStrategy"
47
+ strategy_options: {"replication_factor": "1"}
48
+ solr:
49
+ url: http://localhost:8983/solr
50
+
51
+ Create your keyspace:
52
+
53
+ rake ds:create
54
+ rake ds:create RAILS_ENV=test
55
+
56
+ Once you've created some models, the following will upload the solr schemas and create the column families:
57
+
58
+ rake ds:schema
59
+ rake ds:schema RAILS_ENV=test
60
+
61
+ It is safe to run ds:schema over and over. In fact, it is necessary to re-run it any time you change the
62
+ attributes on any model. DSR will only upload schema files if they have changed.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'DatastaxRails'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:spec) do |spec|
28
+ #spec.rcov = true
29
+ #spec.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/,cassandra_object\/}
30
+ spec.rspec_opts = File.read(File.expand_path("../spec/spec.opts", __FILE__)).split("\n")
31
+ end
32
+ task :default => :spec
33
+
34
+ Bundler::GemHelper.install_tasks
data/config/schema.xml ADDED
@@ -0,0 +1,266 @@
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
+ This is the Solr schema file. This file should be named "schema.xml" and
20
+ should be in the conf directory under the solr home
21
+ (i.e. ./solr/conf/schema.xml by default)
22
+ or located where the classloader for the Solr webapp can find it.
23
+
24
+ This example schema is the recommended starting point for users.
25
+ It should be kept correct and concise, usable out-of-the-box.
26
+
27
+ For more information, on how to customize this file, please see
28
+ http://wiki.apache.org/solr/SchemaXml
29
+
30
+ PERFORMANCE NOTE: this schema includes many optional features and should not
31
+ be used for benchmarking. To improve performance one could
32
+ - set stored="false" for all fields possible (esp large fields) when you
33
+ only need to search on the field but don't need to return the original
34
+ value.
35
+ - set indexed="false" if you don't need to search on the field, but only
36
+ return the field as a result of searching on other indexed fields.
37
+ - remove all unneeded copyField statements
38
+ - for best index size and searching performance, set "index" to false
39
+ for all general text fields, use copyField to copy them to the
40
+ catchall "text" field, and use that for searching.
41
+ - For maximum indexing performance, use the StreamingUpdateSolrServer
42
+ java client.
43
+ - Remember to run the JVM in server mode, and use a higher logging level
44
+ that avoids logging every request
45
+ -->
46
+ <schema name="sunspot" version="1.0">
47
+ <types>
48
+ <!-- field type definitions. The "name" attribute is
49
+ just a label to be used by field definitions. The "class"
50
+ attribute and any other attributes determine the real
51
+ behavior of the fieldType.
52
+ Class names starting with "solr" refer to java classes in the
53
+ org.apache.solr.analysis package.
54
+ -->
55
+ <!-- *** This fieldType is used by Sunspot! *** -->
56
+ <fieldType name="string" class="solr.StrField" omitNorms="true"/>
57
+ <fieldType name="string_ci" class="solr.TextField" omitNorms="true">
58
+ <analyzer type="index">
59
+ <tokenizer class="solr.KeywordTokenizerFactory"/>
60
+ <filter class="solr.LowerCaseFilterFactory"/>
61
+ </analyzer>
62
+ <analyzer type="query">
63
+ <tokenizer class="solr.KeywordTokenizerFactory"/>
64
+ <filter class="solr.LowerCaseFilterFactory"/>
65
+ </analyzer>
66
+ </fieldType>
67
+ <!-- *** This fieldType is used by Sunspot! *** -->
68
+ <fieldType name="tdouble" class="solr.TrieDoubleField" omitNorms="true"/>
69
+ <!-- *** This fieldType is used by Sunspot! *** -->
70
+ <fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
71
+ <!-- *** This fieldType is used by Sunspot! *** -->
72
+ <fieldType name="text" class="solr.TextField" omitNorms="false">
73
+ <analyzer>
74
+ <tokenizer class="solr.StandardTokenizerFactory"/>
75
+ <filter class="solr.StandardFilterFactory"/>
76
+ <filter class="solr.LowerCaseFilterFactory"/>
77
+ </analyzer>
78
+ </fieldType>
79
+ <!-- *** This fieldType is used by Sunspot! *** -->
80
+ <fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
81
+ <!-- *** This fieldType is used by Sunspot! *** -->
82
+ <fieldType name="date" class="solr.DateField" omitNorms="true"/>
83
+ <!-- *** This fieldType is used by Sunspot! *** -->
84
+ <fieldType name="sdouble" class="solr.SortableDoubleField" omitNorms="true"/>
85
+ <!-- *** This fieldType is used by Sunspot! *** -->
86
+ <fieldType name="sfloat" class="solr.SortableFloatField" omitNorms="true"/>
87
+ <!-- *** This fieldType is used by Sunspot! *** -->
88
+ <fieldType name="sint" class="solr.SortableIntField" omitNorms="true"/>
89
+ <!-- *** This fieldType is used by Sunspot! *** -->
90
+ <fieldType name="slong" class="solr.SortableLongField" omitNorms="true"/>
91
+ <!-- *** This fieldType is used by Sunspot! *** -->
92
+ <fieldType name="tint" class="solr.TrieIntField" omitNorms="true"/>
93
+ <!-- *** This fieldType is used by Sunspot! *** -->
94
+ <fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true"/>
95
+ <!-- *** This fieldType is used by Sunspot! *** -->
96
+ <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true"/>
97
+ </types>
98
+ <fields>
99
+ <!-- Valid attributes for fields:
100
+ name: mandatory - the name for the field
101
+ type: mandatory - the name of a previously defined type from the
102
+ <types> section
103
+ indexed: true if this field should be indexed (searchable or sortable)
104
+ stored: true if this field should be retrievable
105
+ compressed: [false] if this field should be stored using gzip compression
106
+ (this will only apply if the field type is compressable; among
107
+ the standard field types, only TextField and StrField are)
108
+ multiValued: true if this field may contain multiple values per document
109
+ omitNorms: (expert) set to true to omit the norms associated with
110
+ this field (this disables length normalization and index-time
111
+ boosting for the field, and saves some memory). Only full-text
112
+ fields or fields that need an index-time boost need norms.
113
+ termVectors: [false] set to true to store the term vector for a
114
+ given field.
115
+ When using MoreLikeThis, fields used for similarity should be
116
+ stored for best performance.
117
+ termPositions: Store position information with the term vector.
118
+ This will increase storage costs.
119
+ termOffsets: Store offset information with the term vector. This
120
+ will increase storage costs.
121
+ default: a value that should be used if no value is specified
122
+ when adding a document.
123
+ -->
124
+ <!-- *** This field is used by Sunspot! *** -->
125
+ <field name="id" stored="true" type="string" multiValued="false" indexed="true"/>
126
+ <!-- *** This field is used by Sunspot! *** -->
127
+ <field name="type" stored="false" type="string" multiValued="true" indexed="true"/>
128
+ <!-- *** This field is used by Sunspot! *** -->
129
+ <field name="class_name" stored="false" type="string" multiValued="false" indexed="true"/>
130
+ <!-- *** This field is used by Sunspot! *** -->
131
+ <field name="text" stored="false" type="text" multiValued="true" indexed="true"/>
132
+ <!-- *** This field is used by Sunspot! *** -->
133
+ <field name="lat" stored="true" type="tdouble" multiValued="false" indexed="true"/>
134
+ <!-- *** This field is used by Sunspot! *** -->
135
+ <field name="lng" stored="true" type="tdouble" multiValued="false" indexed="true"/>
136
+ <!-- *** This dynamicField is used by Sunspot! *** -->
137
+ <dynamicField name="random_*" stored="false" type="rand" multiValued="false" indexed="true"/>
138
+ <!-- *** This dynamicField is used by Sunspot! *** -->
139
+ <dynamicField name="_local*" stored="false" type="tdouble" multiValued="false" indexed="true"/>
140
+ <!-- *** This dynamicField is used by Sunspot! *** -->
141
+ <dynamicField name="*_text" stored="false" type="text" multiValued="true" indexed="true"/>
142
+ <!-- *** This dynamicField is used by Sunspot! *** -->
143
+ <dynamicField name="*_texts" stored="true" type="text" multiValued="true" indexed="true"/>
144
+ <!-- *** This dynamicField is used by Sunspot! *** -->
145
+ <dynamicField name="*_b" stored="false" type="boolean" multiValued="false" indexed="true"/>
146
+ <!-- *** This dynamicField is used by Sunspot! *** -->
147
+ <dynamicField name="*_bm" stored="false" type="boolean" multiValued="true" indexed="true"/>
148
+ <!-- *** This dynamicField is used by Sunspot! *** -->
149
+ <dynamicField name="*_bs" stored="true" type="boolean" multiValued="false" indexed="true"/>
150
+ <!-- *** This dynamicField is used by Sunspot! *** -->
151
+ <dynamicField name="*_bms" stored="true" type="boolean" multiValued="true" indexed="true"/>
152
+ <!-- *** This dynamicField is used by Sunspot! *** -->
153
+ <dynamicField name="*_d" stored="false" type="date" multiValued="false" indexed="true"/>
154
+ <!-- *** This dynamicField is used by Sunspot! *** -->
155
+ <dynamicField name="*_dm" stored="false" type="date" multiValued="true" indexed="true"/>
156
+ <!-- *** This dynamicField is used by Sunspot! *** -->
157
+ <dynamicField name="*_ds" stored="true" type="date" multiValued="false" indexed="true"/>
158
+ <!-- *** This dynamicField is used by Sunspot! *** -->
159
+ <dynamicField name="*_dms" stored="true" type="date" multiValued="true" indexed="true"/>
160
+ <!-- *** This dynamicField is used by Sunspot! *** -->
161
+ <dynamicField name="*_e" stored="false" type="sdouble" multiValued="false" indexed="true"/>
162
+ <!-- *** This dynamicField is used by Sunspot! *** -->
163
+ <dynamicField name="*_em" stored="false" type="sdouble" multiValued="true" indexed="true"/>
164
+ <!-- *** This dynamicField is used by Sunspot! *** -->
165
+ <dynamicField name="*_es" stored="true" type="sdouble" multiValued="false" indexed="true"/>
166
+ <!-- *** This dynamicField is used by Sunspot! *** -->
167
+ <dynamicField name="*_ems" stored="true" type="sdouble" multiValued="true" indexed="true"/>
168
+ <!-- *** This dynamicField is used by Sunspot! *** -->
169
+ <dynamicField name="*_f" stored="false" type="sfloat" multiValued="false" indexed="true"/>
170
+ <!-- *** This dynamicField is used by Sunspot! *** -->
171
+ <dynamicField name="*_fm" stored="false" type="sfloat" multiValued="true" indexed="true"/>
172
+ <!-- *** This dynamicField is used by Sunspot! *** -->
173
+ <dynamicField name="*_fs" stored="true" type="sfloat" multiValued="false" indexed="true"/>
174
+ <!-- *** This dynamicField is used by Sunspot! *** -->
175
+ <dynamicField name="*_fms" stored="true" type="sfloat" multiValued="true" indexed="true"/>
176
+ <!-- *** This dynamicField is used by Sunspot! *** -->
177
+ <dynamicField name="*_i" stored="false" type="sint" multiValued="false" indexed="true"/>
178
+ <!-- *** This dynamicField is used by Sunspot! *** -->
179
+ <dynamicField name="*_im" stored="false" type="sint" multiValued="true" indexed="true"/>
180
+ <!-- *** This dynamicField is used by Sunspot! *** -->
181
+ <dynamicField name="*_is" stored="true" type="sint" multiValued="false" indexed="true"/>
182
+ <!-- *** This dynamicField is used by Sunspot! *** -->
183
+ <dynamicField name="*_ims" stored="true" type="sint" multiValued="true" indexed="true"/>
184
+ <!-- *** This dynamicField is used by Sunspot! *** -->
185
+ <dynamicField name="*_l" stored="false" type="slong" multiValued="false" indexed="true"/>
186
+ <!-- *** This dynamicField is used by Sunspot! *** -->
187
+ <dynamicField name="*_lm" stored="false" type="slong" multiValued="true" indexed="true"/>
188
+ <!-- *** This dynamicField is used by Sunspot! *** -->
189
+ <dynamicField name="*_ls" stored="true" type="slong" multiValued="false" indexed="true"/>
190
+ <!-- *** This dynamicField is used by Sunspot! *** -->
191
+ <dynamicField name="*_lms" stored="true" type="slong" multiValued="true" indexed="true"/>
192
+ <!-- *** This dynamicField is used by Sunspot! *** -->
193
+ <dynamicField name="*_sc" stored="false" type="string" multiValued="false" indexed="true"/>
194
+ <!-- *** This dynamicField is used by Sunspot! *** -->
195
+ <dynamicField name="*_scm" stored="false" type="string" multiValued="true" indexed="true"/>
196
+ <!-- *** This dynamicField is used by Sunspot! *** -->
197
+ <dynamicField name="*_scs" stored="true" type="string" multiValued="false" indexed="true"/>
198
+ <!-- *** This dynamicField is used by Sunspot! *** -->
199
+ <dynamicField name="*_scms" stored="true" type="string" multiValued="true" indexed="true"/>
200
+ <!-- *** This dynamicField is used by Sunspot! *** -->
201
+ <dynamicField name="*_s" stored="false" type="string_ci" multiValued="false" indexed="true"/>
202
+ <!-- *** This dynamicField is used by Sunspot! *** -->
203
+ <dynamicField name="*_sm" stored="false" type="string_ci" multiValued="true" indexed="true"/>
204
+ <!-- *** This dynamicField is used by Sunspot! *** -->
205
+ <dynamicField name="*_ss" stored="true" type="string_ci" multiValued="false" indexed="true"/>
206
+ <!-- *** This dynamicField is used by Sunspot! *** -->
207
+ <dynamicField name="*_sms" stored="true" type="string_ci" multiValued="true" indexed="true"/>
208
+ <!-- *** This dynamicField is used by Sunspot! *** -->
209
+ <dynamicField name="*_it" stored="false" type="tint" multiValued="false" indexed="true"/>
210
+ <!-- *** This dynamicField is used by Sunspot! *** -->
211
+ <dynamicField name="*_itm" stored="false" type="tint" multiValued="true" indexed="true"/>
212
+ <!-- *** This dynamicField is used by Sunspot! *** -->
213
+ <dynamicField name="*_its" stored="true" type="tint" multiValued="false" indexed="true"/>
214
+ <!-- *** This dynamicField is used by Sunspot! *** -->
215
+ <dynamicField name="*_itms" stored="true" type="tint" multiValued="true" indexed="true"/>
216
+ <!-- *** This dynamicField is used by Sunspot! *** -->
217
+ <dynamicField name="*_ft" stored="false" type="tfloat" multiValued="false" indexed="true"/>
218
+ <!-- *** This dynamicField is used by Sunspot! *** -->
219
+ <dynamicField name="*_ftm" stored="false" type="tfloat" multiValued="true" indexed="true"/>
220
+ <!-- *** This dynamicField is used by Sunspot! *** -->
221
+ <dynamicField name="*_fts" stored="true" type="tfloat" multiValued="false" indexed="true"/>
222
+ <!-- *** This dynamicField is used by Sunspot! *** -->
223
+ <dynamicField name="*_ftms" stored="true" type="tfloat" multiValued="true" indexed="true"/>
224
+ <!-- *** This dynamicField is used by Sunspot! *** -->
225
+ <dynamicField name="*_dt" stored="false" type="tdate" multiValued="false" indexed="true"/>
226
+ <!-- *** This dynamicField is used by Sunspot! *** -->
227
+ <dynamicField name="*_dtm" stored="false" type="tdate" multiValued="true" indexed="true"/>
228
+ <!-- *** This dynamicField is used by Sunspot! *** -->
229
+ <dynamicField name="*_dts" stored="true" type="tdate" multiValued="false" indexed="true"/>
230
+ <!-- *** This dynamicField is used by Sunspot! *** -->
231
+ <dynamicField name="*_dtms" stored="true" type="tdate" multiValued="true" indexed="true"/>
232
+ <!-- *** This dynamicField is used by Sunspot! *** -->
233
+ <dynamicField name="*_textv" stored="false" termVectors="true" type="text" multiValued="true" indexed="true"/>
234
+ <!-- *** This dynamicField is used by Sunspot! *** -->
235
+ <dynamicField name="*_textsv" stored="true" termVectors="true" type="text" multiValued="true" indexed="true"/>
236
+ <!-- *** This dynamicField is used by Sunspot! *** -->
237
+ <dynamicField name="*_et" stored="false" termVectors="true" type="tdouble" multiValued="false" indexed="true"/>
238
+ <!-- *** This dynamicField is used by Sunspot! *** -->
239
+ <dynamicField name="*_etm" stored="false" termVectors="true" type="tdouble" multiValued="true" indexed="true"/>
240
+ <!-- *** This dynamicField is used by Sunspot! *** -->
241
+ <dynamicField name="*_ets" stored="true" termVectors="true" type="tdouble" multiValued="false" indexed="true"/>
242
+ <!-- *** This dynamicField is used by Sunspot! *** -->
243
+ <dynamicField name="*_etms" stored="true" termVectors="true" type="tdouble" multiValued="true" indexed="true"/>
244
+ </fields>
245
+ <!-- Field to use to determine and enforce document uniqueness.
246
+ Unless this field is marked with required="false", it will be a required field
247
+ -->
248
+ <uniqueKey>id</uniqueKey>
249
+ <!-- field for the QueryParser to use when an explicit fieldname is absent -->
250
+ <defaultSearchField>text</defaultSearchField>
251
+ <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
252
+ <solrQueryParser defaultOperator="AND"/>
253
+ <!-- copyField commands copy one field to another at the time a document
254
+ is added to the index. It's used either to index the same field differently,
255
+ or to add multiple fields to the same field for easier/faster searching. -->
256
+ <copyField source="*_s" dest="text"/>
257
+ <copyField source="*_sm" dest="text"/>
258
+ <copyField source="*_ss" dest="text"/>
259
+ <copyField source="*_sms" dest="text"/>
260
+ <copyField source="*_sc" dest="text"/>
261
+ <copyField source="*_scm" dest="text"/>
262
+ <copyField source="*_scs" dest="text"/>
263
+ <copyField source="*_scms" dest="text"/>
264
+ <copyField source="*_text" dest="text"/>
265
+ <copyField source="*_texts" dest="text"/>
266
+ </schema>
@@ -0,0 +1,70 @@
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
+ <schema name="datastax_rails" version="1.1">
19
+ <types>
20
+ <fieldType name="string_cs" class="solr.StrField" omitNorms="true"/>
21
+ <fieldType name="string" class="solr.TextField" omitNorms="true">
22
+ <analyzer type="index">
23
+ <tokenizer class="solr.KeywordTokenizerFactory"/>
24
+ <filter class="solr.LowerCaseFilterFactory"/>
25
+ </analyzer>
26
+ <analyzer type="query">
27
+ <tokenizer class="solr.KeywordTokenizerFactory"/>
28
+ <filter class="solr.LowerCaseFilterFactory"/>
29
+ </analyzer>
30
+ </fieldType>
31
+ <fieldType name="text" class="solr.TextField" omitNorms="false" positionIncrementGap="100">
32
+ <analyzer>
33
+ <tokenizer class="solr.StandardTokenizerFactory"/>
34
+ <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
35
+ <filter class="solr.StandardFilterFactory"/>
36
+ <filter class="solr.LowerCaseFilterFactory"/>
37
+ </analyzer>
38
+ </fieldType>
39
+ <fieldType name="array" class="solr.TextField" positionIncrementGap="100">
40
+ <analyzer>
41
+ <tokenizer class="solr.PatternTokenizerFactory" pattern="\$\$\$\$"/>
42
+ <filter class="solr.LowerCaseFilterFactory"/>
43
+ </analyzer>
44
+ </fieldType>
45
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
46
+ <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
47
+ <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
48
+ <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
49
+ <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
50
+ <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
51
+
52
+ </types>
53
+ <fields>
54
+ <field name="id" type="string" indexed="true" stored="true"/>
55
+ <% @fields.each do |field| %>
56
+ <field name="<%= field[:name] %>" type="<%= field[:type] %>" indexed="<%= field[:indexed] %>" stored="<%= field[:stored] %>" multiValued="<%= field[:multi_valued] %>"/>
57
+ <% end %>
58
+ <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
59
+ </fields>
60
+
61
+ <defaultSearchField>text</defaultSearchField>
62
+ <solrQueryParser defaultOperator="AND"/>
63
+ <uniqueKey>id</uniqueKey>
64
+ <% @fulltext_fields.each do |field| %>
65
+ <copyField source="<%= field %>" dest="text"/>
66
+ <% end %>
67
+ <% @copy_fields.each do |field| %>
68
+ <copyField source="<%= field[:source] %>" dest="<%= field[:dest]%>"/>
69
+ <% end %>
70
+ </schema>