sunspot_rails 2.0.0.pre.120924 → 2.0.0.pre.120925
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 +6 -10
- data/{sunspot_rails/.rspec → .rspec} +0 -0
- data/{sunspot_rails/History.txt → History.txt} +0 -0
- data/{sunspot/LICENSE → LICENSE} +0 -0
- data/{sunspot_rails/MIT-LICENSE → MIT-LICENSE} +0 -0
- data/{sunspot_rails/README.rdoc → README.rdoc} +0 -0
- data/Rakefile +12 -32
- data/{sunspot_rails/TODO → TODO} +0 -0
- data/{sunspot_rails/dev_tasks → dev_tasks}/rdoc.rake +0 -0
- data/{sunspot_rails/dev_tasks → dev_tasks}/release.rake +0 -0
- data/{sunspot_rails/dev_tasks → dev_tasks}/spec.rake +0 -0
- data/{sunspot/tasks → dev_tasks}/todo.rake +0 -0
- data/{sunspot_rails/gemfiles → gemfiles}/rails-2.3.14 +0 -0
- data/{sunspot_rails/gemfiles → gemfiles}/rails-3.0.15 +0 -0
- data/{sunspot_rails/gemfiles → gemfiles}/rails-3.1.6 +0 -0
- data/{sunspot_rails/gemfiles → gemfiles}/rails-3.2.6 +0 -0
- data/{sunspot_rails/generators → generators}/sunspot/sunspot_generator.rb +0 -0
- data/{sunspot_rails/generators → generators}/sunspot/templates/sunspot.yml +0 -0
- data/{sunspot_rails/install.rb → install.rb} +0 -0
- data/{sunspot_rails/lib → lib}/generators/sunspot_rails.rb +0 -0
- data/{sunspot_rails/lib → lib}/generators/sunspot_rails/install/install_generator.rb +0 -0
- data/{sunspot_rails/lib → lib}/generators/sunspot_rails/install/templates/config/sunspot.yml +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/adapters.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/configuration.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/init.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/log_subscriber.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/railtie.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/railties/controller_runtime.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/request_lifecycle.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/searchable.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/server.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/solr_instrumentation.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/solr_logging.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/spec_helper.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/stub_session_proxy.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot/rails/tasks.rb +0 -0
- data/{sunspot_rails/lib → lib}/sunspot_rails.rb +0 -0
- data/{sunspot_rails/spec → spec}/configuration_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/model_lifecycle_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/model_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/controllers/application_controller.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/controllers/posts_controller.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/author.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/blog.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/location.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/photo_post.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/post.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/post_with_auto.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/app/models/post_with_default_scope.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/config/boot.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/config/preinitializer.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/config/routes.rb +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/config/sunspot.yml +0 -0
- data/{sunspot_rails/spec → spec}/rails_template/db/schema.rb +0 -0
- data/{sunspot_rails/spec → spec}/request_lifecycle_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/schema.rb +0 -0
- data/{sunspot_rails/spec → spec}/searchable_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/server_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/session_spec.rb +0 -0
- data/{sunspot_rails/spec → spec}/shared_examples/indexed_after_save.rb +0 -0
- data/{sunspot_rails/spec → spec}/shared_examples/not_indexed_after_save.rb +0 -0
- data/{sunspot_rails/spec → spec}/spec_helper.rb +0 -0
- data/{sunspot_rails/spec → spec}/stub_session_proxy_spec.rb +0 -0
- data/{sunspot_rails/sunspot_rails.gemspec → sunspot_rails.gemspec} +0 -0
- metadata +102 -305
- data/.travis.yml +0 -35
- data/README.md +0 -863
- data/ci/travis.sh +0 -67
- data/sunspot/.gitignore +0 -13
- data/sunspot/Gemfile +0 -5
- data/sunspot/History.txt +0 -258
- data/sunspot/Rakefile +0 -13
- data/sunspot/TODO +0 -13
- data/sunspot/lib/light_config.rb +0 -40
- data/sunspot/lib/sunspot.rb +0 -579
- data/sunspot/lib/sunspot/adapters.rb +0 -349
- data/sunspot/lib/sunspot/batcher.rb +0 -62
- data/sunspot/lib/sunspot/class_set.rb +0 -23
- data/sunspot/lib/sunspot/composite_setup.rb +0 -202
- data/sunspot/lib/sunspot/configuration.rb +0 -53
- data/sunspot/lib/sunspot/data_extractor.rb +0 -50
- data/sunspot/lib/sunspot/dsl.rb +0 -5
- data/sunspot/lib/sunspot/dsl/adjustable.rb +0 -47
- data/sunspot/lib/sunspot/dsl/field_group.rb +0 -57
- data/sunspot/lib/sunspot/dsl/field_query.rb +0 -345
- data/sunspot/lib/sunspot/dsl/fields.rb +0 -103
- data/sunspot/lib/sunspot/dsl/fulltext.rb +0 -243
- data/sunspot/lib/sunspot/dsl/function.rb +0 -27
- data/sunspot/lib/sunspot/dsl/functional.rb +0 -44
- data/sunspot/lib/sunspot/dsl/more_like_this_query.rb +0 -56
- data/sunspot/lib/sunspot/dsl/paginatable.rb +0 -32
- data/sunspot/lib/sunspot/dsl/query_facet.rb +0 -36
- data/sunspot/lib/sunspot/dsl/restriction.rb +0 -25
- data/sunspot/lib/sunspot/dsl/restriction_with_near.rb +0 -160
- data/sunspot/lib/sunspot/dsl/scope.rb +0 -214
- data/sunspot/lib/sunspot/dsl/search.rb +0 -30
- data/sunspot/lib/sunspot/dsl/standard_query.rb +0 -122
- data/sunspot/lib/sunspot/field.rb +0 -193
- data/sunspot/lib/sunspot/field_factory.rb +0 -129
- data/sunspot/lib/sunspot/indexer.rb +0 -136
- data/sunspot/lib/sunspot/query.rb +0 -11
- data/sunspot/lib/sunspot/query/abstract_field_facet.rb +0 -55
- data/sunspot/lib/sunspot/query/bbox.rb +0 -15
- data/sunspot/lib/sunspot/query/boost_query.rb +0 -24
- data/sunspot/lib/sunspot/query/common_query.rb +0 -96
- data/sunspot/lib/sunspot/query/composite_fulltext.rb +0 -36
- data/sunspot/lib/sunspot/query/connective.rb +0 -206
- data/sunspot/lib/sunspot/query/date_field_facet.rb +0 -14
- data/sunspot/lib/sunspot/query/dismax.rb +0 -132
- data/sunspot/lib/sunspot/query/field_facet.rb +0 -41
- data/sunspot/lib/sunspot/query/field_group.rb +0 -37
- data/sunspot/lib/sunspot/query/filter.rb +0 -38
- data/sunspot/lib/sunspot/query/function_query.rb +0 -52
- data/sunspot/lib/sunspot/query/geo.rb +0 -53
- data/sunspot/lib/sunspot/query/geofilt.rb +0 -16
- data/sunspot/lib/sunspot/query/highlighting.rb +0 -62
- data/sunspot/lib/sunspot/query/more_like_this.rb +0 -61
- data/sunspot/lib/sunspot/query/more_like_this_query.rb +0 -12
- data/sunspot/lib/sunspot/query/pagination.rb +0 -42
- data/sunspot/lib/sunspot/query/query_facet.rb +0 -53
- data/sunspot/lib/sunspot/query/range_facet.rb +0 -15
- data/sunspot/lib/sunspot/query/restriction.rb +0 -308
- data/sunspot/lib/sunspot/query/scope.rb +0 -9
- data/sunspot/lib/sunspot/query/sort.rb +0 -109
- data/sunspot/lib/sunspot/query/sort_composite.rb +0 -34
- data/sunspot/lib/sunspot/query/standard_query.rb +0 -16
- data/sunspot/lib/sunspot/query/text_field_boost.rb +0 -17
- data/sunspot/lib/sunspot/schema.rb +0 -151
- data/sunspot/lib/sunspot/search.rb +0 -9
- data/sunspot/lib/sunspot/search/abstract_search.rb +0 -286
- data/sunspot/lib/sunspot/search/date_facet.rb +0 -35
- data/sunspot/lib/sunspot/search/facet_row.rb +0 -27
- data/sunspot/lib/sunspot/search/field_facet.rb +0 -88
- data/sunspot/lib/sunspot/search/field_group.rb +0 -70
- data/sunspot/lib/sunspot/search/group.rb +0 -54
- data/sunspot/lib/sunspot/search/highlight.rb +0 -38
- data/sunspot/lib/sunspot/search/hit.rb +0 -150
- data/sunspot/lib/sunspot/search/hit_enumerable.rb +0 -68
- data/sunspot/lib/sunspot/search/more_like_this_search.rb +0 -31
- data/sunspot/lib/sunspot/search/paginated_collection.rb +0 -57
- data/sunspot/lib/sunspot/search/query_facet.rb +0 -67
- data/sunspot/lib/sunspot/search/range_facet.rb +0 -37
- data/sunspot/lib/sunspot/search/standard_search.rb +0 -21
- data/sunspot/lib/sunspot/session.rb +0 -262
- data/sunspot/lib/sunspot/session_proxy.rb +0 -95
- data/sunspot/lib/sunspot/session_proxy/abstract_session_proxy.rb +0 -29
- data/sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb +0 -66
- data/sunspot/lib/sunspot/session_proxy/id_sharding_session_proxy.rb +0 -89
- data/sunspot/lib/sunspot/session_proxy/master_slave_session_proxy.rb +0 -43
- data/sunspot/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb +0 -67
- data/sunspot/lib/sunspot/session_proxy/sharding_session_proxy.rb +0 -222
- data/sunspot/lib/sunspot/session_proxy/silent_fail_session_proxy.rb +0 -42
- data/sunspot/lib/sunspot/session_proxy/thread_local_session_proxy.rb +0 -37
- data/sunspot/lib/sunspot/setup.rb +0 -350
- data/sunspot/lib/sunspot/text_field_setup.rb +0 -29
- data/sunspot/lib/sunspot/type.rb +0 -393
- data/sunspot/lib/sunspot/util.rb +0 -252
- data/sunspot/lib/sunspot/version.rb +0 -3
- data/sunspot/script/console +0 -10
- data/sunspot/spec/api/adapters_spec.rb +0 -68
- data/sunspot/spec/api/batcher_spec.rb +0 -112
- data/sunspot/spec/api/binding_spec.rb +0 -50
- data/sunspot/spec/api/class_set_spec.rb +0 -24
- data/sunspot/spec/api/hit_enumerable_spec.rb +0 -47
- data/sunspot/spec/api/indexer/attributes_spec.rb +0 -149
- data/sunspot/spec/api/indexer/batch_spec.rb +0 -72
- data/sunspot/spec/api/indexer/dynamic_fields_spec.rb +0 -42
- data/sunspot/spec/api/indexer/fixed_fields_spec.rb +0 -57
- data/sunspot/spec/api/indexer/fulltext_spec.rb +0 -43
- data/sunspot/spec/api/indexer/removal_spec.rb +0 -53
- data/sunspot/spec/api/indexer/spec_helper.rb +0 -1
- data/sunspot/spec/api/indexer_spec.rb +0 -14
- data/sunspot/spec/api/query/advanced_manipulation_examples.rb +0 -35
- data/sunspot/spec/api/query/connectives_examples.rb +0 -201
- data/sunspot/spec/api/query/dsl_spec.rb +0 -18
- data/sunspot/spec/api/query/dynamic_fields_examples.rb +0 -165
- data/sunspot/spec/api/query/faceting_examples.rb +0 -497
- data/sunspot/spec/api/query/fulltext_examples.rb +0 -313
- data/sunspot/spec/api/query/function_spec.rb +0 -79
- data/sunspot/spec/api/query/geo_examples.rb +0 -68
- data/sunspot/spec/api/query/group_spec.rb +0 -32
- data/sunspot/spec/api/query/highlighting_examples.rb +0 -245
- data/sunspot/spec/api/query/more_like_this_spec.rb +0 -140
- data/sunspot/spec/api/query/ordering_pagination_examples.rb +0 -116
- data/sunspot/spec/api/query/scope_examples.rb +0 -275
- data/sunspot/spec/api/query/spatial_examples.rb +0 -27
- data/sunspot/spec/api/query/spec_helper.rb +0 -1
- data/sunspot/spec/api/query/standard_spec.rb +0 -29
- data/sunspot/spec/api/query/text_field_scoping_examples.rb +0 -30
- data/sunspot/spec/api/query/types_spec.rb +0 -20
- data/sunspot/spec/api/search/dynamic_fields_spec.rb +0 -33
- data/sunspot/spec/api/search/faceting_spec.rb +0 -360
- data/sunspot/spec/api/search/highlighting_spec.rb +0 -69
- data/sunspot/spec/api/search/hits_spec.rb +0 -147
- data/sunspot/spec/api/search/paginated_collection_spec.rb +0 -36
- data/sunspot/spec/api/search/results_spec.rb +0 -72
- data/sunspot/spec/api/search/search_spec.rb +0 -23
- data/sunspot/spec/api/search/spec_helper.rb +0 -1
- data/sunspot/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +0 -85
- data/sunspot/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +0 -30
- data/sunspot/spec/api/session_proxy/master_slave_session_proxy_spec.rb +0 -41
- data/sunspot/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +0 -78
- data/sunspot/spec/api/session_proxy/sharding_session_proxy_spec.rb +0 -77
- data/sunspot/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +0 -24
- data/sunspot/spec/api/session_proxy/spec_helper.rb +0 -9
- data/sunspot/spec/api/session_proxy/thread_local_session_proxy_spec.rb +0 -39
- data/sunspot/spec/api/session_spec.rb +0 -232
- data/sunspot/spec/api/spec_helper.rb +0 -3
- data/sunspot/spec/api/sunspot_spec.rb +0 -29
- data/sunspot/spec/ext.rb +0 -11
- data/sunspot/spec/helpers/indexer_helper.rb +0 -17
- data/sunspot/spec/helpers/integration_helper.rb +0 -8
- data/sunspot/spec/helpers/mock_session_helper.rb +0 -13
- data/sunspot/spec/helpers/query_helper.rb +0 -26
- data/sunspot/spec/helpers/search_helper.rb +0 -68
- data/sunspot/spec/integration/dynamic_fields_spec.rb +0 -57
- data/sunspot/spec/integration/faceting_spec.rb +0 -330
- data/sunspot/spec/integration/field_grouping_spec.rb +0 -100
- data/sunspot/spec/integration/geospatial_spec.rb +0 -96
- data/sunspot/spec/integration/highlighting_spec.rb +0 -44
- data/sunspot/spec/integration/indexing_spec.rb +0 -55
- data/sunspot/spec/integration/keyword_search_spec.rb +0 -317
- data/sunspot/spec/integration/local_search_spec.rb +0 -64
- data/sunspot/spec/integration/more_like_this_spec.rb +0 -43
- data/sunspot/spec/integration/scoped_search_spec.rb +0 -386
- data/sunspot/spec/integration/stored_fields_spec.rb +0 -12
- data/sunspot/spec/integration/test_pagination.rb +0 -43
- data/sunspot/spec/integration/unicode_spec.rb +0 -15
- data/sunspot/spec/mocks/adapters.rb +0 -33
- data/sunspot/spec/mocks/blog.rb +0 -3
- data/sunspot/spec/mocks/comment.rb +0 -21
- data/sunspot/spec/mocks/connection.rb +0 -126
- data/sunspot/spec/mocks/mock_adapter.rb +0 -30
- data/sunspot/spec/mocks/mock_class_sharding_session_proxy.rb +0 -24
- data/sunspot/spec/mocks/mock_record.rb +0 -52
- data/sunspot/spec/mocks/mock_sharding_session_proxy.rb +0 -15
- data/sunspot/spec/mocks/photo.rb +0 -11
- data/sunspot/spec/mocks/post.rb +0 -86
- data/sunspot/spec/mocks/super_class.rb +0 -2
- data/sunspot/spec/mocks/user.rb +0 -13
- data/sunspot/spec/spec_helper.rb +0 -40
- data/sunspot/sunspot.gemspec +0 -37
- data/sunspot/tasks/rdoc.rake +0 -27
- data/sunspot/tasks/schema.rake +0 -19
- data/sunspot_rails/.gitignore +0 -7
- data/sunspot_rails/LICENSE +0 -18
- data/sunspot_rails/Rakefile +0 -17
- data/sunspot_rails/dev_tasks/todo.rake +0 -4
- data/sunspot_solr/Gemfile +0 -3
- data/sunspot_solr/README.rdoc +0 -24
- data/sunspot_solr/bin/sunspot-installer +0 -20
- data/sunspot_solr/bin/sunspot-solr +0 -80
- data/sunspot_solr/lib/sunspot/solr/installer.rb +0 -25
- data/sunspot_solr/lib/sunspot/solr/installer/config_installer.rb +0 -46
- data/sunspot_solr/lib/sunspot/solr/installer/task_helper.rb +0 -13
- data/sunspot_solr/lib/sunspot/solr/java.rb +0 -10
- data/sunspot_solr/lib/sunspot/solr/railtie.rb +0 -15
- data/sunspot_solr/lib/sunspot/solr/server.rb +0 -223
- data/sunspot_solr/lib/sunspot/solr/tasks.rb +0 -49
- data/sunspot_solr/lib/sunspot_solr.rb +0 -5
- data/sunspot_solr/solr/README.txt +0 -42
- data/sunspot_solr/solr/etc/jetty.xml +0 -219
- data/sunspot_solr/solr/etc/webdefault.xml +0 -379
- data/sunspot_solr/solr/lib/jetty-6.1.26-patched-JETTY-1340.jar +0 -0
- data/sunspot_solr/solr/lib/jetty-util-6.1.26-patched-JETTY-1340.jar +0 -0
- data/sunspot_solr/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/sunspot_solr/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/sunspot_solr/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/sunspot_solr/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/sunspot_solr/solr/lib/servlet-api-2.5-20081211.jar +0 -0
- data/sunspot_solr/solr/solr/.gitignore +0 -1
- data/sunspot_solr/solr/solr/README.txt +0 -54
- data/sunspot_solr/solr/solr/conf/admin-extra.html +0 -31
- data/sunspot_solr/solr/solr/conf/elevate.xml +0 -36
- data/sunspot_solr/solr/solr/conf/mapping-ISOLatin1Accent.txt +0 -246
- data/sunspot_solr/solr/solr/conf/protwords.txt +0 -21
- data/sunspot_solr/solr/solr/conf/schema.xml +0 -250
- data/sunspot_solr/solr/solr/conf/scripts.conf +0 -24
- data/sunspot_solr/solr/solr/conf/solrconfig.xml +0 -934
- data/sunspot_solr/solr/solr/conf/spellings.txt +0 -2
- data/sunspot_solr/solr/solr/conf/stopwords.txt +0 -58
- data/sunspot_solr/solr/solr/conf/synonyms.txt +0 -31
- data/sunspot_solr/solr/solr/conf/xslt/example.xsl +0 -132
- data/sunspot_solr/solr/solr/conf/xslt/example_atom.xsl +0 -67
- data/sunspot_solr/solr/solr/conf/xslt/example_rss.xsl +0 -66
- data/sunspot_solr/solr/solr/conf/xslt/luke.xsl +0 -337
- data/sunspot_solr/solr/start.jar +0 -0
- data/sunspot_solr/solr/webapps/solr.war +0 -0
- data/sunspot_solr/spec/server_spec.rb +0 -98
- data/sunspot_solr/spec/spec_helper.rb +0 -18
- data/sunspot_solr/sunspot_solr.gemspec +0 -37
- data/tools/gem_tasks.rb +0 -69
data/ci/travis.sh
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
set +e
|
4
|
-
|
5
|
-
solr_responding() {
|
6
|
-
port=$1
|
7
|
-
curl -o /dev/null "http://localhost:$port/solr/admin/ping" > /dev/null 2>&1
|
8
|
-
}
|
9
|
-
|
10
|
-
wait_until_solr_responds() {
|
11
|
-
port=$1
|
12
|
-
while ! solr_responding $1; do
|
13
|
-
/bin/echo -n "."
|
14
|
-
sleep 1
|
15
|
-
done
|
16
|
-
}
|
17
|
-
|
18
|
-
case $GEM in
|
19
|
-
"sunspot")
|
20
|
-
|
21
|
-
cd sunspot
|
22
|
-
/bin/echo -n "Starting Solr on port 8983 for Sunspot specs..."
|
23
|
-
bundle install --quiet --path vendor/bundle
|
24
|
-
if [ -f sunspot-solr.pid ]; then bundle exec sunspot-solr stop || true; fi
|
25
|
-
|
26
|
-
bundle exec sunspot-solr start -p 8983 -d /tmp/solr
|
27
|
-
wait_until_solr_responds 8983
|
28
|
-
/bin/echo "done."
|
29
|
-
|
30
|
-
# Invoke the sunspot specs
|
31
|
-
bundle exec rake spec
|
32
|
-
rv=$?
|
33
|
-
|
34
|
-
/bin/echo -n "Stopping Solr... "
|
35
|
-
bundle exec sunspot-solr stop
|
36
|
-
/bin/echo "done."
|
37
|
-
|
38
|
-
exit $rv
|
39
|
-
;;
|
40
|
-
|
41
|
-
"sunspot_rails")
|
42
|
-
|
43
|
-
cd sunspot
|
44
|
-
/bin/echo -n "Starting Solr on port 8983 for Sunspot specs..."
|
45
|
-
bundle install --quiet --path vendor/bundle
|
46
|
-
if [ -f sunspot-solr.pid ]; then bundle exec sunspot-solr stop || true; fi
|
47
|
-
|
48
|
-
bundle exec sunspot-solr start -p 8983 -d /tmp/solr
|
49
|
-
wait_until_solr_responds 8983
|
50
|
-
/bin/echo "done."
|
51
|
-
|
52
|
-
# Install gems for test Rails application
|
53
|
-
cd ../sunspot_rails
|
54
|
-
rake spec RAILS=$RAILS
|
55
|
-
rv=$?
|
56
|
-
|
57
|
-
# Cleanup Solr
|
58
|
-
/bin/echo -n "Stopping Solr... "
|
59
|
-
cd ../sunspot
|
60
|
-
bundle exec sunspot-solr stop
|
61
|
-
/bin/echo "done."
|
62
|
-
|
63
|
-
exit $rv
|
64
|
-
;;
|
65
|
-
|
66
|
-
*)
|
67
|
-
esac
|
data/sunspot/.gitignore
DELETED
data/sunspot/Gemfile
DELETED
data/sunspot/History.txt
DELETED
@@ -1,258 +0,0 @@
|
|
1
|
-
== 2.0.0
|
2
|
-
* Adds support for field grouping (Andy Lindeman)
|
3
|
-
* Adds support for native geospatial searches and ordering (Eric Tang, Bruno Miranda, Andy Lindeman)
|
4
|
-
* Bundled Solr installation (`sunspot_solr`) is version 3.5.0 (Chris Parker)
|
5
|
-
* Adds #query_time method to retrieve the Solr query time in
|
6
|
-
milliseconds (Jason Weathered)
|
7
|
-
* Fixes syntax of highlighting when used with nested dismax queries (Marco Crepaldi)
|
8
|
-
* Adds ability to nest `Sunspot.batch` calls (Thorbjørn Hermansen)
|
9
|
-
* Adds `open_timeout` and `read_timeout` configuration options (Rob Di
|
10
|
-
Marco)
|
11
|
-
* Adds `offset` options to facets (Federico Gonzalez)
|
12
|
-
* Adds `Retry5xxSessionProxy` to retry requests when an internal server error
|
13
|
-
occurs (Nick Zadrozny)
|
14
|
-
* Adds support for range queries (Jan Ulrich)
|
15
|
-
* Allows custom field names specified with :as to be symbols (David Oliver)
|
16
|
-
* Add field exclusion when faceting (Cuong Hoang)
|
17
|
-
|
18
|
-
== 1.3.0 2011-11-26
|
19
|
-
* Requests to Solr use HTTP POST verb by default to avoid issues when the query string grows too large for GET (Johan Van Ryseghem)
|
20
|
-
* `sunspot.yml` supports ERB (Andrew Cholakian)
|
21
|
-
* An error is raised when attempting to run the packaged Solr if Java is not available (Lucas Parry)
|
22
|
-
* Pagination operates correctly without dependency on `will_paginate` (Larry Sprock, Dave Krupinski)
|
23
|
-
* Stored boolean fields with `false` value are returned correctly (yipdw)
|
24
|
-
* `highlight` accepts `:formatter` and `:fragmenter` parameters (Jeremy McNevin)
|
25
|
-
* Default `headerBufferSize` is increased for packaged Solr make sure the limit is not reached during large queries (gjb83)
|
26
|
-
* Packaged Solr respects the `data_path` configuration setting from `sunspot.yml` (djmaze)
|
27
|
-
* Packaged Solr correctly uses the `pid_dir` configuration option from `sunspot.yml` (Russen Guggemos)
|
28
|
-
* Specs run correctly in 1.9.2 (Larry Sprock)
|
29
|
-
* Documentation improvements (Thibaut Barrère, gjb83, Breno Santos Salgado)
|
30
|
-
* Adds :offset option to paginate method (Benjamin Fleischer)
|
31
|
-
* Requires rsolr 1.0.6, which fixes issues with Unicode characters
|
32
|
-
returned by Solr
|
33
|
-
|
34
|
-
== 1.2.1 2010-12-28
|
35
|
-
* Decreased default reindexing batch size from 500 to 50
|
36
|
-
|
37
|
-
== 1.2.0 2010-12-28
|
38
|
-
* Replace solr-spatial-light with client-side geohash-based spatial search
|
39
|
-
* Override Solr field naming conventions using :as option
|
40
|
-
* Delegate #id method directly to calling context inside DSL
|
41
|
-
* Create a SilentFailSessionProxy that rescues exceptions on write operations.
|
42
|
-
* Inclusion by identity
|
43
|
-
* Solr optimize command
|
44
|
-
* Ignore negative :limit option for query facets
|
45
|
-
* Eliminated value sorting for range scopes
|
46
|
-
* Correctly cast stored boolean values if they are booleans
|
47
|
-
* Correctly cast and return stored values for multi-valued fields
|
48
|
-
|
49
|
-
== 1.1.0 2010-04-01
|
50
|
-
* MoreLikeThis support
|
51
|
-
* Allow multiple fulltext queries in one search
|
52
|
-
* Function queries
|
53
|
-
* Update solr-spatial-light to 0.0.6 build
|
54
|
-
* Support for :prefix when faceting.
|
55
|
-
* Allow specification of solr jar
|
56
|
-
* Updated reindex task to allow setting of batch size and list of models to index
|
57
|
-
* Use a '*:*' query for deleting the entire index
|
58
|
-
* Ability to specify custom request handler for queries
|
59
|
-
* Gracefully handle nonexistent search result
|
60
|
-
|
61
|
-
== 1.0.4 2010-03-19
|
62
|
-
* Update solr-spatial-light to 0.0.5
|
63
|
-
* Fix NullPointerException in repeated geo search
|
64
|
-
* Fix missing distances in repeated geo search
|
65
|
-
* Don't query the data store more than once when results are missing
|
66
|
-
|
67
|
-
== 1.0.2 2010-03-11
|
68
|
-
* Restore Hit#distance for result geo distance
|
69
|
-
* Remove :distance special sort
|
70
|
-
* Quote reserved keywords in boolean queries
|
71
|
-
* Add Search#facets accessor to retrieve all facets
|
72
|
-
|
73
|
-
== 1.0.1 2010-03-05
|
74
|
-
* Copy all needed config files when sunspot-installer run with force option
|
75
|
-
|
76
|
-
== 1.0.0 2010-03-03
|
77
|
-
* Multiselect Field Faceting
|
78
|
-
* Named field facets
|
79
|
-
* Upgrade to Solr 1.4
|
80
|
-
* Deletion by query
|
81
|
-
* Allow :latitude and :longitude as coordinate method names
|
82
|
-
* Assumed inconsistency
|
83
|
-
* Support for TrieField numeric/time types
|
84
|
-
* Built-in Session Proxies: Thread-local, master/slave, sharding
|
85
|
-
* Give DSL blocks access to calling context
|
86
|
-
* Create sunspot-installer executable, which modifies an existing
|
87
|
-
schema/solrconfig to work with Sunspot
|
88
|
-
* Support for Long and Double types
|
89
|
-
* new_search method accepts DSL block
|
90
|
-
* Sunspot::Server now a real class that manages embedded Sunspot instance
|
91
|
-
* Add Search#each_hit_with_result method
|
92
|
-
* Able to access stored dynamic fields
|
93
|
-
* Access dynamic facets using the #facet method
|
94
|
-
* Remove accidental existence of dynamic_text fields
|
95
|
-
* Upgrade to RSolr 0.12.1
|
96
|
-
* Switch from LocalSolr to solr-spatial-light
|
97
|
-
* Turn off request logging in Jetty for default Solr install
|
98
|
-
* Full support for class-reloading of Sunspot-setup classes
|
99
|
-
* Support time ranges outside of 32-bit range
|
100
|
-
* Remove sunspot-configure-solr executable
|
101
|
-
* new_search method accepts DSL block
|
102
|
-
|
103
|
-
== 0.10.8 2009-11-24
|
104
|
-
* Strictly enforce RSolr 0.9.6 gem dependency (newer ones broken)
|
105
|
-
|
106
|
-
== 0.10.7 2009-11-16
|
107
|
-
* Ignore boost_fields that don't apply
|
108
|
-
* Ability to specify text_fields inside connectives
|
109
|
-
* Fix bug with newlines in strings incorrectly being considered multi-value
|
110
|
-
* Compatibility with RSolr 0.10.1
|
111
|
-
* Remove commented-out code entirely
|
112
|
-
|
113
|
-
== 0.10.6 2009-11-05
|
114
|
-
* Support more dismax parameters
|
115
|
-
* Support multiple boost queries
|
116
|
-
* Allow "extra" facet rows
|
117
|
-
* Allow exclusion of fulltext fields
|
118
|
-
* Allow specification of per-field highlighting params
|
119
|
-
* Specify coordinates using block extraction
|
120
|
-
* Return empty array if no highlights available
|
121
|
-
* Get stored text fields from hits
|
122
|
-
* Update docs to reflect a requirement of at least one search type
|
123
|
-
* added --max-memory and --min-memory parameters to sunspot-solr
|
124
|
-
* LocalLucene and LocalSolr compatible with Java 1.5
|
125
|
-
|
126
|
-
== 0.10.5 2009-10-22
|
127
|
-
* Fix highlighting for multiple-model search
|
128
|
-
|
129
|
-
== 0.10.4 2009-10-20
|
130
|
-
* Add adjust_params method, allowing experts to manually edit Solr params
|
131
|
-
* Track adds and deletes separately in session, and expose delete_dirty? method
|
132
|
-
* Allow clients to inject a singleton session proxy
|
133
|
-
|
134
|
-
== 0.10.3 2009-10-15
|
135
|
-
* Contiguous, not continuous
|
136
|
-
* Fail fast if less-than-1 radius passed for local search
|
137
|
-
|
138
|
-
== 0.10.2 2009-10-09
|
139
|
-
* Add Sunspot.config.xml_builder option, which is passed to RSolr
|
140
|
-
|
141
|
-
== 0.10.1 2009-10-08
|
142
|
-
* Fix directory bugs in sunspot-solr executable
|
143
|
-
|
144
|
-
== 0.10.0 2009-10-08
|
145
|
-
* Support for geographical search using LocalSolr
|
146
|
-
* Support for keyword highlighting, with custom deferred formatting
|
147
|
-
* New fulltext DSL for specifying advanced dismax options
|
148
|
-
* Support boost queries
|
149
|
-
* Support for search-time field boost
|
150
|
-
* Support for phrase fields
|
151
|
-
* Support for prefix queries
|
152
|
-
* Set default search-time field boost in setup
|
153
|
-
* Restrict field facet to a set of desired values
|
154
|
-
* Query facets support all facet options
|
155
|
-
* Allow scoping by text fields
|
156
|
-
* Support executing searches repeatedly
|
157
|
-
* Allow setting of Solr URL for integration tests in environment variable
|
158
|
-
* Add support for master/slave configurations
|
159
|
-
* Added logging options to sunspot-solr executable
|
160
|
-
* Added default solr config file location to Sunspot::Configuration
|
161
|
-
* Informative, non-firehose Search#inspect
|
162
|
-
* No longer require arguments to #paginate
|
163
|
-
* Silently ignore keyword calls with nil/blank/whitespace keywords
|
164
|
-
* Don't require that all searched types have a referenced field
|
165
|
-
* Correct backwards ranges
|
166
|
-
* Raise descriptive error if no types passed to search
|
167
|
-
* Handle empty query facets, query facet rows, and connectives
|
168
|
-
* Quote values in range restrictions if they contain spaces
|
169
|
-
* Fix bug in Sunspot::Util.full_const_get
|
170
|
-
* Remove support for :other option in time faceting
|
171
|
-
* Remove order_by_random() method
|
172
|
-
* Removed options and Query from public API
|
173
|
-
* Use built-in optparse instead of optiflag in bin/sunspot-solr
|
174
|
-
* Remove dependency on haml and use erb since it is only used to generate one file
|
175
|
-
|
176
|
-
== 0.9.0 2009-07-21
|
177
|
-
* Use Dismax parser for keyword search
|
178
|
-
* Field and document boosting
|
179
|
-
* Specify which fields to search in keyword search
|
180
|
-
* Allow indexing of multiple values in text fields
|
181
|
-
* Access keyword relevance score in Hit objects
|
182
|
-
* Allow stored fields, retrieve stored values from Hit objects
|
183
|
-
* Support more values in shorthand restrictions
|
184
|
-
* Disjunctions and conjunctions
|
185
|
-
* Random ordering
|
186
|
-
* Control all options for field facets
|
187
|
-
* Time range facets
|
188
|
-
* Get referenced objects from facets on foreign keys
|
189
|
-
* Facet by class
|
190
|
-
* Batch indexing
|
191
|
-
* New Date field type
|
192
|
-
* Direct access to data accessors
|
193
|
-
* Executable to configure production Solr instances
|
194
|
-
* Replace solr-ruby with RSolr
|
195
|
-
* Remove accidental ActiveSupport dependency
|
196
|
-
|
197
|
-
== 0.8.9 2009-06-23
|
198
|
-
* Fix OrderedHash bug in older versions of ActiveSupport
|
199
|
-
|
200
|
-
== 0.8.8 2009-06-15
|
201
|
-
* Escape type names to support namespaced classes
|
202
|
-
* Fix bug with anonymous modules in Ruby 1.9
|
203
|
-
|
204
|
-
== 0.8.7 2009-06-10
|
205
|
-
* Add --pid-dir option for sunspot-solr executable
|
206
|
-
|
207
|
-
== 0.8.5 2009-06-09
|
208
|
-
* Added dependencies for sunspot-solr executable to gem dependencies
|
209
|
-
* Search for adapters using class ancestors rather than superclasses
|
210
|
-
|
211
|
-
== 0.8.3 2009-06-03
|
212
|
-
* Index objects passed as a collection in a single HTTP request
|
213
|
-
|
214
|
-
== 0.8.2 2009-05-27
|
215
|
-
* Allow specification of Solr home when using sunspot-solr
|
216
|
-
|
217
|
-
== 0.8.1 2009-05-26
|
218
|
-
* Add Search#execute! to public API
|
219
|
-
|
220
|
-
== 0.8.0 2009-05-22
|
221
|
-
* Access query API directly; instantiate search without running it
|
222
|
-
* Dynamic fields
|
223
|
-
* Search blocks can be evaluated in calling context
|
224
|
-
|
225
|
-
== 0.7.3 2009-05-06
|
226
|
-
* Better exception handling when class doesn't have adapter/setup
|
227
|
-
|
228
|
-
== 0.7.2 2009-04-29
|
229
|
-
* Dirty sessions
|
230
|
-
|
231
|
-
== 0.7.1 2009-04-29
|
232
|
-
* Removed extlib dependency from gemspec
|
233
|
-
|
234
|
-
== 0.7.0 2009-04-28
|
235
|
-
* Less magic in the DSL
|
236
|
-
* Restrict by empty values
|
237
|
-
* Negative scoping using without() method
|
238
|
-
* Exclusion by object identity using without(instance)
|
239
|
-
* Support for faceting
|
240
|
-
* Explicit commits
|
241
|
-
* Boolean field type
|
242
|
-
* Attribute field flexibility
|
243
|
-
* Virtual field blocks can be evaluated in calling context
|
244
|
-
* Order available by multiple fields
|
245
|
-
* New adapter API
|
246
|
-
* Got rid of builder API
|
247
|
-
* Full documentation
|
248
|
-
|
249
|
-
== 0.0.2 2009-02-14
|
250
|
-
* Run sunspot's built-in Solr instance using
|
251
|
-
sunspot-solr executable
|
252
|
-
* Search hash interpretation delegated to
|
253
|
-
Builder object
|
254
|
-
|
255
|
-
== 0.0.1 2008-12-11
|
256
|
-
* Initial release
|
257
|
-
* Define indexing for any class using DSL
|
258
|
-
* Search indexed classes using DSL
|
data/sunspot/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
|
5
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
6
|
-
|
7
|
-
desc "Run all examples"
|
8
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
-
t.rspec_opts = '--format documentation'
|
10
|
-
t.ruby_opts = "-W1"
|
11
|
-
end
|
12
|
-
|
13
|
-
task :default => :spec
|
data/sunspot/TODO
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
=== Sunspot 1.1.x ===
|
2
|
-
* commitWithin (needs support from RSolr, currently available in master)
|
3
|
-
* commit options (non-blocking, etc.)
|
4
|
-
|
5
|
-
=== Someday ===
|
6
|
-
* Shorthand arguments to Sunspot#search
|
7
|
-
* Rudimentary fulltext prefixing support
|
8
|
-
|
9
|
-
=== Solr 1.5 ===
|
10
|
-
* Field Collapsing (SOLR-236)
|
11
|
-
* Support for official spatial support (SOLR-773)
|
12
|
-
* Support sorting by function
|
13
|
-
* Support string constants in functions
|
data/sunspot/lib/light_config.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module LightConfig
|
2
|
-
class Configuration
|
3
|
-
def initialize(&block)
|
4
|
-
@properties = {}
|
5
|
-
::LightConfig::Builder.new(self).instance_eval(&block)
|
6
|
-
singleton = (class <<self; self; end)
|
7
|
-
@properties.keys.each do |property|
|
8
|
-
singleton.module_eval do
|
9
|
-
define_method property do
|
10
|
-
@properties[property]
|
11
|
-
end
|
12
|
-
|
13
|
-
define_method "#{property}=" do |value|
|
14
|
-
@properties[property] = value
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Builder
|
22
|
-
def initialize(configuration)
|
23
|
-
@configuration = configuration
|
24
|
-
end
|
25
|
-
|
26
|
-
def method_missing(method, *args, &block)
|
27
|
-
raise ArgumentError("wrong number of arguments(#{args.length} for 1)") unless args.length < 2
|
28
|
-
value = if block then ::LightConfig::Configuration.new(&block)
|
29
|
-
else args.first
|
30
|
-
end
|
31
|
-
@configuration.instance_variable_get(:@properties)[method] = value
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class <<self
|
36
|
-
def build(&block)
|
37
|
-
LightConfig::Configuration.new(&block)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/sunspot/lib/sunspot.rb
DELETED
@@ -1,579 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'time'
|
3
|
-
require 'date'
|
4
|
-
require 'enumerator'
|
5
|
-
require 'cgi'
|
6
|
-
begin
|
7
|
-
require 'rsolr'
|
8
|
-
rescue LoadError
|
9
|
-
require 'rubygems'
|
10
|
-
require 'rsolr'
|
11
|
-
end
|
12
|
-
|
13
|
-
require File.join(File.dirname(__FILE__), 'light_config')
|
14
|
-
|
15
|
-
%w(util adapters configuration setup composite_setup text_field_setup field
|
16
|
-
field_factory data_extractor indexer query search session session_proxy
|
17
|
-
type dsl class_set).each do |filename|
|
18
|
-
require File.join(File.dirname(__FILE__), 'sunspot', filename)
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# The Sunspot module provides class-method entry points to most of the
|
23
|
-
# functionality provided by the Sunspot library. Internally, the Sunspot
|
24
|
-
# singleton class contains a (non-thread-safe!) instance of Sunspot::Session,
|
25
|
-
# to which it delegates most of the class methods it exposes. In the method
|
26
|
-
# documentation below, this instance is referred to as the "singleton session".
|
27
|
-
#
|
28
|
-
# Though the singleton session provides a convenient entry point to Sunspot,
|
29
|
-
# it is by no means required to use the Sunspot class methods. Multiple sessions
|
30
|
-
# may be instantiated and used (if you need to connect to multiple Solr
|
31
|
-
# instances, for example.)
|
32
|
-
#
|
33
|
-
# Note that the configuration of classes for index/search (the +setup+
|
34
|
-
# method) is _not_ session-specific, but rather global.
|
35
|
-
#
|
36
|
-
module Sunspot
|
37
|
-
UnrecognizedFieldError = Class.new(StandardError)
|
38
|
-
UnrecognizedRestrictionError = Class.new(StandardError)
|
39
|
-
NoAdapterError = Class.new(StandardError)
|
40
|
-
NoSetupError = Class.new(StandardError)
|
41
|
-
IllegalSearchError = Class.new(StandardError)
|
42
|
-
NotImplementedError = Class.new(StandardError)
|
43
|
-
|
44
|
-
autoload :Installer, File.join(File.dirname(__FILE__), 'sunspot', 'installer')
|
45
|
-
|
46
|
-
# Array to track classes that have been set up for searching.
|
47
|
-
# Used by, e.g., Sunspot::Rails for reindexing all searchable classes.
|
48
|
-
@searchable = ClassSet.new
|
49
|
-
|
50
|
-
class <<self
|
51
|
-
#
|
52
|
-
# Clients can inject a session proxy, allowing them to implement custom
|
53
|
-
# session-management logic while retaining the Sunspot singleton API as
|
54
|
-
# an available interface. The object assigned to this attribute must
|
55
|
-
# respond to all of the public methods of the Sunspot::Session class.
|
56
|
-
#
|
57
|
-
attr_writer :session
|
58
|
-
|
59
|
-
#
|
60
|
-
# Access the list of classes set up to be searched.
|
61
|
-
#
|
62
|
-
attr_reader :searchable
|
63
|
-
|
64
|
-
# Configures indexing and search for a given class.
|
65
|
-
#
|
66
|
-
# ==== Parameters
|
67
|
-
#
|
68
|
-
# clazz<Class>:: class to configure
|
69
|
-
#
|
70
|
-
# ==== Example
|
71
|
-
#
|
72
|
-
# Sunspot.setup(Post) do
|
73
|
-
# text :title, :body
|
74
|
-
# string :author_name
|
75
|
-
# integer :blog_id
|
76
|
-
# integer :category_ids
|
77
|
-
# float :average_rating, :using => :ratings_average
|
78
|
-
# time :published_at
|
79
|
-
# string :sort_title do
|
80
|
-
# title.downcase.sub(/^(an?|the)\W+/, ''/) if title = self.title
|
81
|
-
# end
|
82
|
-
# end
|
83
|
-
#
|
84
|
-
# ====== Attribute Fields vs. Virtual Fields
|
85
|
-
#
|
86
|
-
# Attribute fields call a method on the indexed object and index the
|
87
|
-
# return value. All of the fields defined above except for the last one are
|
88
|
-
# attribute fields. By default, the field name will also be the attribute
|
89
|
-
# used; this can be overriden with the +:using+ option, as in
|
90
|
-
# +:average_rating+ above. In that case, the attribute +:ratings_average+
|
91
|
-
# will be indexed with the field name +:average_rating+.
|
92
|
-
#
|
93
|
-
# +:sort_title+ is a virtual field, which evaluates the block inside the
|
94
|
-
# context of the instance being indexed, and indexes the value returned
|
95
|
-
# by the block. If the block you pass takes an argument, it will be passed
|
96
|
-
# the instance rather than being evaluated inside of it; so, the following
|
97
|
-
# example is equivalent to the one above (assuming #title is public):
|
98
|
-
#
|
99
|
-
# Sunspot.setup(Post) do
|
100
|
-
# string :sort_title do |post|
|
101
|
-
# post.title.downcase.sub(/^(an?|the)\W+/, ''/) if title = self.title
|
102
|
-
# end
|
103
|
-
# end
|
104
|
-
#
|
105
|
-
# ===== Field Types
|
106
|
-
#
|
107
|
-
# The available types are:
|
108
|
-
#
|
109
|
-
# * +text+
|
110
|
-
# * +string+
|
111
|
-
# * +integer+
|
112
|
-
# * +float+
|
113
|
-
# * +time+
|
114
|
-
# * +boolean+
|
115
|
-
#
|
116
|
-
# Note that the +text+ type behaves quite differently from the others -
|
117
|
-
# this is the type that is indexed as fulltext, and is searched using the
|
118
|
-
# +keywords+ method inside the search DSL. Text fields cannot have
|
119
|
-
# restrictions set on them, nor can they be used in order statements or
|
120
|
-
# for facets. All other types are indexed literally, and thus can be used
|
121
|
-
# for all of those operations. They will not, however, be searched in
|
122
|
-
# fulltext. In this way, Sunspot provides a complete barrier between
|
123
|
-
# fulltext fields and value fields.
|
124
|
-
#
|
125
|
-
# It is fine to specify a field both as a text field and a string field;
|
126
|
-
# internally, the fields will have different names so there is no danger
|
127
|
-
# of conflict.
|
128
|
-
#
|
129
|
-
# ===== Dynamic Fields
|
130
|
-
#
|
131
|
-
# For use cases which have highly dynamic data models (for instance, an
|
132
|
-
# open set of key-value pairs attached to a model), it may be useful to
|
133
|
-
# defer definition of fields until indexing time. Sunspot exposes dynamic
|
134
|
-
# fields, which define a data accessor (either attribute or virtual, see
|
135
|
-
# above), which accepts a hash of field names to values. Note that the field
|
136
|
-
# names in the hash are internally scoped to the base name of the dynamic
|
137
|
-
# field, so any time they are referred to, they are referred to using both
|
138
|
-
# the base name and the dynamic (runtime-specified) name.
|
139
|
-
#
|
140
|
-
# Dynamic fields are speficied in the setup block using the type name
|
141
|
-
# prefixed by +dynamic_+. For example:
|
142
|
-
#
|
143
|
-
# Sunspot.setup(Post) do
|
144
|
-
# dynamic_string :custom_values do
|
145
|
-
# key_value_pairs.inject({}) do |hash, key_value_pair|
|
146
|
-
# hash[key_value_pair.key.to_sym] = key_value_pair.value
|
147
|
-
# end
|
148
|
-
# end
|
149
|
-
# end
|
150
|
-
#
|
151
|
-
# If you later wanted to facet all of the values for the key "cuisine",
|
152
|
-
# you could issue:
|
153
|
-
#
|
154
|
-
# Sunspot.search(Post) do
|
155
|
-
# dynamic :custom_values do
|
156
|
-
# facet :cuisine
|
157
|
-
# end
|
158
|
-
# end
|
159
|
-
#
|
160
|
-
# In the documentation, +:custom_values+ is referred to as the "base name" -
|
161
|
-
# that is, the one specified statically - and +:cuisine+ is referred to as
|
162
|
-
# the dynamic name, which is the part that is specified at indexing time.
|
163
|
-
#
|
164
|
-
def setup(clazz, &block)
|
165
|
-
Sunspot.searchable << clazz
|
166
|
-
Setup.setup(clazz, &block)
|
167
|
-
end
|
168
|
-
|
169
|
-
# Indexes objects on the singleton session.
|
170
|
-
#
|
171
|
-
# ==== Parameters
|
172
|
-
#
|
173
|
-
# objects...<Object>:: objects to index (may pass an array or varargs)
|
174
|
-
#
|
175
|
-
# ==== Example
|
176
|
-
#
|
177
|
-
# post1, post2 = new Array(2) { Post.create }
|
178
|
-
# Sunspot.index(post1, post2)
|
179
|
-
#
|
180
|
-
# Note that indexed objects won't be reflected in search until a commit is
|
181
|
-
# sent - see Sunspot.index! and Sunspot.commit
|
182
|
-
#
|
183
|
-
def index(*objects)
|
184
|
-
session.index(*objects)
|
185
|
-
end
|
186
|
-
|
187
|
-
# Indexes objects on the singleton session and commits immediately.
|
188
|
-
#
|
189
|
-
# See: Sunspot.index and Sunspot.commit
|
190
|
-
#
|
191
|
-
# ==== Parameters
|
192
|
-
#
|
193
|
-
# objects...<Object>:: objects to index (may pass an array or varargs)
|
194
|
-
#
|
195
|
-
def index!(*objects)
|
196
|
-
session.index!(*objects)
|
197
|
-
end
|
198
|
-
|
199
|
-
# Commits the singleton session
|
200
|
-
#
|
201
|
-
# When documents are added to or removed from Solr, the changes are
|
202
|
-
# initially stored in memory, and are not reflected in Solr's existing
|
203
|
-
# searcher instance. When a commit message is sent, the changes are written
|
204
|
-
# to disk, and a new searcher is spawned. Commits are thus fairly
|
205
|
-
# expensive, so if your application needs to index several documents as part
|
206
|
-
# of a single operation, it is advisable to index them all and then call
|
207
|
-
# commit at the end of the operation.
|
208
|
-
#
|
209
|
-
# Note that Solr can also be configured to automatically perform a commit
|
210
|
-
# after either a specified interval after the last change, or after a
|
211
|
-
# specified number of documents are added. See
|
212
|
-
# http://wiki.apache.org/solr/SolrConfigXml
|
213
|
-
#
|
214
|
-
def commit
|
215
|
-
session.commit
|
216
|
-
end
|
217
|
-
|
218
|
-
# Optimizes the index on the singletion session.
|
219
|
-
#
|
220
|
-
# Frequently adding and deleting documents to Solr, leaves the index in a
|
221
|
-
# fragmented state. The optimize command merges all index segments into
|
222
|
-
# a single segment and removes any deleted documents, making it faster to
|
223
|
-
# search. Since optimize rebuilds the index from scratch, it takes some
|
224
|
-
# time and requires double the space on the hard disk while it's rebuilding.
|
225
|
-
# Note that optimize also commits.
|
226
|
-
def optimize
|
227
|
-
session.optimize
|
228
|
-
end
|
229
|
-
|
230
|
-
#
|
231
|
-
# Create a new Search instance, but do not execute it immediately. Generally
|
232
|
-
# you will want to use the #search method to build and execute searches in
|
233
|
-
# one step, but if you are building searches piecemeal you may call
|
234
|
-
# #new_search and then call #build one or more times to add components to
|
235
|
-
# the query.
|
236
|
-
#
|
237
|
-
# ==== Example
|
238
|
-
#
|
239
|
-
# search = Sunspot.new_search do
|
240
|
-
# with(:blog_id, 1)
|
241
|
-
# end
|
242
|
-
# search.build do
|
243
|
-
# keywords('some keywords')
|
244
|
-
# end
|
245
|
-
# search.build do
|
246
|
-
# order_by(:published_at, :desc)
|
247
|
-
# end
|
248
|
-
# search.execute
|
249
|
-
#
|
250
|
-
# # This is equivalent to:
|
251
|
-
# Sunspot.search do
|
252
|
-
# with(:blog_id, 1)
|
253
|
-
# keywords('some keywords')
|
254
|
-
# order_by(:published_at, :desc)
|
255
|
-
# end
|
256
|
-
#
|
257
|
-
# ==== Parameters
|
258
|
-
#
|
259
|
-
# types<Class>...::
|
260
|
-
# One or more types to search for. If no types are passed, all
|
261
|
-
# configured types will be searched for.
|
262
|
-
#
|
263
|
-
# ==== Returns
|
264
|
-
#
|
265
|
-
# Sunspot::Search::
|
266
|
-
# Search object, not yet executed. Query parameters can be added manually;
|
267
|
-
# then #execute should be called.
|
268
|
-
#
|
269
|
-
def new_search(*types, &block)
|
270
|
-
session.new_search(*types, &block)
|
271
|
-
end
|
272
|
-
|
273
|
-
|
274
|
-
# Search for objects in the index.
|
275
|
-
#
|
276
|
-
# ==== Parameters
|
277
|
-
#
|
278
|
-
# types<Class>...::
|
279
|
-
# One or more types to search for. If no types are passed, all
|
280
|
-
# configured types will be searched.
|
281
|
-
#
|
282
|
-
# ==== Returns
|
283
|
-
#
|
284
|
-
# Sunspot::Search:: Object containing results, facets, count, etc.
|
285
|
-
#
|
286
|
-
# The fields available for restriction, ordering, etc. are those that meet
|
287
|
-
# the following criteria:
|
288
|
-
#
|
289
|
-
# * They are not of type +text+.
|
290
|
-
# * They are defined for at least one of the classes being searched
|
291
|
-
# * They have the same data type for all of the classes being searched.
|
292
|
-
# * They have the same multiple flag for all of the classes being searched.
|
293
|
-
# * They have the same stored flag for all of the classes being searched.
|
294
|
-
#
|
295
|
-
# The restrictions available are the constants defined in the
|
296
|
-
# Sunspot::Restriction class. The standard restrictions are:
|
297
|
-
#
|
298
|
-
# with(:field_name).equal_to(value)
|
299
|
-
# with(:field_name, value) # shorthand for above
|
300
|
-
# with(:field_name).less_than(value)
|
301
|
-
# with(:field_name).greater_than(value)
|
302
|
-
# with(:field_name).between(value1..value2)
|
303
|
-
# with(:field_name).any_of([value1, value2, value3])
|
304
|
-
# with(:field_name).all_of([value1, value2, value3])
|
305
|
-
# without(some_instance) # exclude that particular instance
|
306
|
-
#
|
307
|
-
# +without+ can be substituted for +with+, causing the restriction to be
|
308
|
-
# negated. In the last example above, only +without+ works, as it does not
|
309
|
-
# make sense to search only for an instance you already have.
|
310
|
-
#
|
311
|
-
# Equality restrictions can take +nil+ as a value, which restricts the
|
312
|
-
# results to documents that have no value for the given field. Passing +nil+
|
313
|
-
# as a value to other restriction types is illegal. Thus:
|
314
|
-
#
|
315
|
-
# with(:field_name, nil) # ok
|
316
|
-
# with(:field_name).equal_to(nil) # ok
|
317
|
-
# with(:field_name).less_than(nil) # bad
|
318
|
-
#
|
319
|
-
# ==== Example
|
320
|
-
#
|
321
|
-
# Sunspot.search(Post) do
|
322
|
-
# keywords 'great pizza'
|
323
|
-
# with(:published_at).less_than Time.now
|
324
|
-
# with :blog_id, 1
|
325
|
-
# without current_post
|
326
|
-
# facet :category_ids
|
327
|
-
# order_by :published_at, :desc
|
328
|
-
# paginate 2, 15
|
329
|
-
# end
|
330
|
-
#
|
331
|
-
# If the block passed to #search takes an argument, that argument will
|
332
|
-
# present the DSL, and the block will be evaluated in the calling context.
|
333
|
-
# This will come in handy for building searches using instance data or
|
334
|
-
# methods, e.g.:
|
335
|
-
#
|
336
|
-
# Sunspot.search(Post) do |query|
|
337
|
-
# query.with(:blog_id, @current_blog.id)
|
338
|
-
# end
|
339
|
-
#
|
340
|
-
# See Sunspot::DSL::Search, Sunspot::DSL::Scope, Sunspot::DSL::FieldQuery
|
341
|
-
# and Sunspot::DSL::StandardQuery for the full API presented inside the
|
342
|
-
# block.
|
343
|
-
#
|
344
|
-
def search(*types, &block)
|
345
|
-
session.search(*types, &block)
|
346
|
-
end
|
347
|
-
|
348
|
-
def new_more_like_this(object, *types, &block)
|
349
|
-
session.new_more_like_this(object, *types, &block)
|
350
|
-
end
|
351
|
-
|
352
|
-
#
|
353
|
-
# Initiate a MoreLikeThis search. MoreLikeThis is a special type of search
|
354
|
-
# that finds similar documents using fulltext comparison. The fields to be
|
355
|
-
# compared are `text` fields set up with the `:more_like_this` option set to
|
356
|
-
# `true`. By default, more like this returns objects of the same type as the
|
357
|
-
# object used for comparison, but a list of types can optionally be passed
|
358
|
-
# to this method to return similar documents of other types. This will only
|
359
|
-
# work for types that have common fields.
|
360
|
-
#
|
361
|
-
# The DSL for MoreLikeThis search exposes several methods for setting
|
362
|
-
# options specific to this type of search. See the
|
363
|
-
# Sunspot::DSL::MoreLikeThis class and the MoreLikeThis documentation on
|
364
|
-
# the Solr wiki: http://wiki.apache.org/solr/MoreLikeThis
|
365
|
-
#
|
366
|
-
# MoreLikeThis searches have all of the same scoping, ordering, and faceting
|
367
|
-
# functionality as standard searches; the only thing you can't do in a MLT
|
368
|
-
# search is fulltext matching (since the MLT itself is a fulltext query).
|
369
|
-
#
|
370
|
-
# ==== Example
|
371
|
-
#
|
372
|
-
# post = Post.first
|
373
|
-
# Sunspot.more_like_this(post, Post, Page) do
|
374
|
-
# fields :title, :body
|
375
|
-
# with(:updated_at).greater_than(1.month.ago)
|
376
|
-
# facet(:category_ids)
|
377
|
-
# end
|
378
|
-
#
|
379
|
-
#
|
380
|
-
def more_like_this(object, *types, &block)
|
381
|
-
session.more_like_this(object, *types, &block)
|
382
|
-
end
|
383
|
-
|
384
|
-
# Remove objects from the index. Any time an object is destroyed, it must
|
385
|
-
# be removed from the index; otherwise, the index will contain broken
|
386
|
-
# references to objects that do not exist, which will cause errors when
|
387
|
-
# those objects are matched in search results.
|
388
|
-
#
|
389
|
-
# If a block is passed, it is evaluated as a search scope; in this way,
|
390
|
-
# documents can be removed by an arbitrary query. In this case, the
|
391
|
-
# arguments to the method should be the classes to run the query on.
|
392
|
-
#
|
393
|
-
# ==== Parameters
|
394
|
-
#
|
395
|
-
# objects...<Object>::
|
396
|
-
# Objects to remove from the index (may pass an array or varargs)
|
397
|
-
#
|
398
|
-
# ==== Example (remove a document)
|
399
|
-
#
|
400
|
-
# post.destroy
|
401
|
-
# Sunspot.remove(post)
|
402
|
-
#
|
403
|
-
# ==== Example (remove by query)
|
404
|
-
#
|
405
|
-
# Sunspot.remove(Post) do
|
406
|
-
# with(:created_at).less_than(Time.now - 14.days)
|
407
|
-
# end
|
408
|
-
#
|
409
|
-
def remove(*objects, &block)
|
410
|
-
session.remove(*objects, &block)
|
411
|
-
end
|
412
|
-
|
413
|
-
#
|
414
|
-
# Remove objects from the index and immediately commit. See Sunspot.remove
|
415
|
-
#
|
416
|
-
# ==== Parameters
|
417
|
-
#
|
418
|
-
# objects...<Object>:: Objects to remove from the index
|
419
|
-
#
|
420
|
-
def remove!(*objects)
|
421
|
-
session.remove!(*objects)
|
422
|
-
end
|
423
|
-
|
424
|
-
#
|
425
|
-
# Remove an object from the index using its class name and primary key.
|
426
|
-
# Useful if you know this information and want to remove an object without
|
427
|
-
# instantiating it from persistent storage
|
428
|
-
#
|
429
|
-
# ==== Parameters
|
430
|
-
#
|
431
|
-
# clazz<Class>:: Class of the object, or class name as a string or symbol
|
432
|
-
# id::
|
433
|
-
# Primary key of the object. This should be the same id that would be
|
434
|
-
# returned by the class's instance adapter.
|
435
|
-
#
|
436
|
-
def remove_by_id(clazz, id)
|
437
|
-
session.remove_by_id(clazz, id)
|
438
|
-
end
|
439
|
-
|
440
|
-
#
|
441
|
-
# Remove an object by class name and primary key, and immediately commit.
|
442
|
-
# See #remove_by_id and #commit
|
443
|
-
#
|
444
|
-
def remove_by_id!(clazz, id)
|
445
|
-
session.remove_by_id!(clazz, id)
|
446
|
-
end
|
447
|
-
|
448
|
-
# Remove all objects of the given classes from the index. There isn't much
|
449
|
-
# use for this in general operations but it can be useful for maintenance,
|
450
|
-
# testing, etc. If no arguments are passed, remove everything from the
|
451
|
-
# index.
|
452
|
-
#
|
453
|
-
# ==== Parameters
|
454
|
-
#
|
455
|
-
# classes...<Class>::
|
456
|
-
# classes for which to remove all instances from the index (may pass an
|
457
|
-
# array or varargs)
|
458
|
-
#
|
459
|
-
# ==== Example
|
460
|
-
#
|
461
|
-
# Sunspot.remove_all(Post, Blog)
|
462
|
-
#
|
463
|
-
def remove_all(*classes)
|
464
|
-
session.remove_all(*classes)
|
465
|
-
end
|
466
|
-
|
467
|
-
#
|
468
|
-
# Remove all objects of the given classes from the index and immediately
|
469
|
-
# commit. See Sunspot.remove_all
|
470
|
-
#
|
471
|
-
# ==== Parameters
|
472
|
-
#
|
473
|
-
# classes...<Class>::
|
474
|
-
# classes for which to remove all instances from the index
|
475
|
-
def remove_all!(*classes)
|
476
|
-
session.remove_all!(*classes)
|
477
|
-
end
|
478
|
-
|
479
|
-
#
|
480
|
-
# Process all adds in a batch. Any Sunspot adds initiated inside the block
|
481
|
-
# will be sent in bulk when the block finishes. Useful if your application
|
482
|
-
# initiates index adds from various places in code as part of a single
|
483
|
-
# operation; doing a batch add will give better performance.
|
484
|
-
#
|
485
|
-
# ==== Example
|
486
|
-
#
|
487
|
-
# Sunspot.batch do
|
488
|
-
# post = Post.new
|
489
|
-
# Sunspot.add(post)
|
490
|
-
# comment = Comment.new
|
491
|
-
# Sunspot.add(comment)
|
492
|
-
# end
|
493
|
-
#
|
494
|
-
# Sunspot will send both the post and the comment in a single request.
|
495
|
-
#
|
496
|
-
def batch(&block)
|
497
|
-
session.batch(&block)
|
498
|
-
end
|
499
|
-
|
500
|
-
#
|
501
|
-
# True if documents have been added, updated, or removed since the last
|
502
|
-
# commit.
|
503
|
-
#
|
504
|
-
# ==== Returns
|
505
|
-
#
|
506
|
-
# Boolean:: Whether there have been any updates since the last commit
|
507
|
-
#
|
508
|
-
def dirty?
|
509
|
-
session.dirty?
|
510
|
-
end
|
511
|
-
|
512
|
-
#
|
513
|
-
# Sends a commit if the session is dirty (see #dirty?).
|
514
|
-
#
|
515
|
-
def commit_if_dirty
|
516
|
-
session.commit_if_dirty
|
517
|
-
end
|
518
|
-
|
519
|
-
#
|
520
|
-
# True if documents have been removed since the last commit.
|
521
|
-
#
|
522
|
-
# ==== Returns
|
523
|
-
#
|
524
|
-
# Boolean:: Whether there have been any deletes since the last commit
|
525
|
-
#
|
526
|
-
def delete_dirty?
|
527
|
-
session.delete_dirty?
|
528
|
-
end
|
529
|
-
|
530
|
-
#
|
531
|
-
# Sends a commit if the session has deletes since the last commit (see #delete_dirty?).
|
532
|
-
#
|
533
|
-
def commit_if_delete_dirty
|
534
|
-
session.commit_if_delete_dirty
|
535
|
-
end
|
536
|
-
|
537
|
-
# Returns the configuration associated with the singleton session. See
|
538
|
-
# Sunspot::Configuration for details.
|
539
|
-
#
|
540
|
-
# ==== Returns
|
541
|
-
#
|
542
|
-
# LightConfig::Configuration:: configuration for singleton session
|
543
|
-
#
|
544
|
-
def config
|
545
|
-
session.config
|
546
|
-
end
|
547
|
-
|
548
|
-
#
|
549
|
-
# Resets the singleton session. This is useful for clearing out all
|
550
|
-
# static data between tests, but probably nowhere else.
|
551
|
-
#
|
552
|
-
# ==== Parameters
|
553
|
-
#
|
554
|
-
# keep_config<Boolean>::
|
555
|
-
# Whether to retain the configuration used by the current singleton
|
556
|
-
# session. Default false.
|
557
|
-
#
|
558
|
-
def reset!(keep_config = false)
|
559
|
-
config =
|
560
|
-
if keep_config
|
561
|
-
session.config
|
562
|
-
else
|
563
|
-
Configuration.build
|
564
|
-
end
|
565
|
-
@session = Session.new(config)
|
566
|
-
end
|
567
|
-
|
568
|
-
#
|
569
|
-
# Get the singleton session, creating it if none yet exists.
|
570
|
-
#
|
571
|
-
# ==== Returns
|
572
|
-
#
|
573
|
-
# Sunspot::Session:: the singleton session
|
574
|
-
#
|
575
|
-
def session #:nodoc:
|
576
|
-
@session ||= Session.new
|
577
|
-
end
|
578
|
-
end
|
579
|
-
end
|