nxa-sunspot 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +153 -0
- data/LICENSE +18 -0
- data/README.rdoc +191 -0
- data/Rakefile +9 -0
- data/TODO +14 -0
- data/VERSION.yml +4 -0
- data/bin/sunspot-configure-solr +40 -0
- data/bin/sunspot-solr +95 -0
- data/lib/light_config.rb +40 -0
- data/lib/sunspot.rb +488 -0
- data/lib/sunspot/adapters.rb +265 -0
- data/lib/sunspot/composite_setup.rb +188 -0
- data/lib/sunspot/configuration.rb +56 -0
- data/lib/sunspot/data_extractor.rb +50 -0
- data/lib/sunspot/dsl.rb +4 -0
- data/lib/sunspot/dsl/field_query.rb +150 -0
- data/lib/sunspot/dsl/fields.rb +100 -0
- data/lib/sunspot/dsl/fulltext.rb +228 -0
- data/lib/sunspot/dsl/query.rb +162 -0
- data/lib/sunspot/dsl/query_facet.rb +36 -0
- data/lib/sunspot/dsl/restriction.rb +25 -0
- data/lib/sunspot/dsl/scope.rb +225 -0
- data/lib/sunspot/dsl/search.rb +30 -0
- data/lib/sunspot/field.rb +181 -0
- data/lib/sunspot/field_factory.rb +144 -0
- data/lib/sunspot/indexer.rb +133 -0
- data/lib/sunspot/query.rb +9 -0
- data/lib/sunspot/query/abstract_field_facet.rb +43 -0
- data/lib/sunspot/query/boost_query.rb +20 -0
- data/lib/sunspot/query/connective.rb +189 -0
- data/lib/sunspot/query/date_field_facet.rb +14 -0
- data/lib/sunspot/query/dismax.rb +88 -0
- data/lib/sunspot/query/field_facet.rb +9 -0
- data/lib/sunspot/query/highlighting.rb +55 -0
- data/lib/sunspot/query/local.rb +27 -0
- data/lib/sunspot/query/pagination.rb +38 -0
- data/lib/sunspot/query/query.rb +86 -0
- data/lib/sunspot/query/query_facet.rb +16 -0
- data/lib/sunspot/query/restriction.rb +254 -0
- data/lib/sunspot/query/scope.rb +9 -0
- data/lib/sunspot/query/sort.rb +105 -0
- data/lib/sunspot/query/sort_composite.rb +33 -0
- data/lib/sunspot/query/text_field_boost.rb +15 -0
- data/lib/sunspot/schema.rb +147 -0
- data/lib/sunspot/search.rb +216 -0
- data/lib/sunspot/search/date_facet.rb +35 -0
- data/lib/sunspot/search/facet_row.rb +27 -0
- data/lib/sunspot/search/field_facet.rb +44 -0
- data/lib/sunspot/search/highlight.rb +38 -0
- data/lib/sunspot/search/hit.rb +117 -0
- data/lib/sunspot/search/query_facet.rb +62 -0
- data/lib/sunspot/session.rb +236 -0
- data/lib/sunspot/setup.rb +323 -0
- data/lib/sunspot/text_field_setup.rb +29 -0
- data/lib/sunspot/type.rb +204 -0
- data/lib/sunspot/util.rb +210 -0
- data/solr/etc/jetty.xml +212 -0
- data/solr/etc/webdefault.xml +379 -0
- data/solr/lib/jetty-6.1.3.jar +0 -0
- data/solr/lib/jetty-util-6.1.3.jar +0 -0
- data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr/solr/conf/elevate.xml +36 -0
- data/solr/solr/conf/protwords.txt +21 -0
- data/solr/solr/conf/schema.xml +64 -0
- data/solr/solr/conf/solrconfig.xml +725 -0
- data/solr/solr/conf/stopwords.txt +57 -0
- data/solr/solr/conf/synonyms.txt +31 -0
- data/solr/solr/lib/geoapi-nogenerics-2.1-M2.jar +0 -0
- data/solr/solr/lib/gt2-referencing-2.3.1.jar +0 -0
- data/solr/solr/lib/jsr108-0.01.jar +0 -0
- data/solr/solr/lib/locallucene.jar +0 -0
- data/solr/solr/lib/localsolr.jar +0 -0
- data/solr/start.jar +0 -0
- data/solr/webapps/solr.war +0 -0
- data/spec/api/adapters_spec.rb +33 -0
- data/spec/api/indexer/attributes_spec.rb +110 -0
- data/spec/api/indexer/batch_spec.rb +46 -0
- data/spec/api/indexer/dynamic_fields_spec.rb +33 -0
- data/spec/api/indexer/fixed_fields_spec.rb +57 -0
- data/spec/api/indexer/fulltext_spec.rb +43 -0
- data/spec/api/indexer/removal_spec.rb +46 -0
- data/spec/api/indexer/spec_helper.rb +1 -0
- data/spec/api/indexer_spec.rb +4 -0
- data/spec/api/query/adjust_params_spec.rb +37 -0
- data/spec/api/query/connectives_spec.rb +176 -0
- data/spec/api/query/dsl_spec.rb +12 -0
- data/spec/api/query/dynamic_fields_spec.rb +149 -0
- data/spec/api/query/faceting_spec.rb +296 -0
- data/spec/api/query/fulltext_spec.rb +281 -0
- data/spec/api/query/highlighting_spec.rb +225 -0
- data/spec/api/query/local_spec.rb +62 -0
- data/spec/api/query/ordering_pagination_spec.rb +95 -0
- data/spec/api/query/scope_spec.rb +266 -0
- data/spec/api/query/spec_helper.rb +1 -0
- data/spec/api/query/text_field_scoping_spec.rb +30 -0
- data/spec/api/query/types_spec.rb +20 -0
- data/spec/api/search/dynamic_fields_spec.rb +27 -0
- data/spec/api/search/faceting_spec.rb +242 -0
- data/spec/api/search/highlighting_spec.rb +65 -0
- data/spec/api/search/hits_spec.rb +67 -0
- data/spec/api/search/results_spec.rb +52 -0
- data/spec/api/search/search_spec.rb +23 -0
- data/spec/api/search/spec_helper.rb +1 -0
- data/spec/api/session_spec.rb +198 -0
- data/spec/api/spec_helper.rb +1 -0
- data/spec/api/sunspot_spec.rb +18 -0
- data/spec/helpers/indexer_helper.rb +29 -0
- data/spec/helpers/query_helper.rb +13 -0
- data/spec/helpers/search_helper.rb +78 -0
- data/spec/integration/dynamic_fields_spec.rb +55 -0
- data/spec/integration/faceting_spec.rb +188 -0
- data/spec/integration/highlighting_spec.rb +22 -0
- data/spec/integration/indexing_spec.rb +7 -0
- data/spec/integration/keyword_search_spec.rb +245 -0
- data/spec/integration/local_search_spec.rb +56 -0
- data/spec/integration/scoped_search_spec.rb +303 -0
- data/spec/integration/spec_helper.rb +7 -0
- data/spec/integration/stored_fields_spec.rb +10 -0
- data/spec/integration/test_pagination.rb +32 -0
- data/spec/mocks/adapters.rb +32 -0
- data/spec/mocks/blog.rb +3 -0
- data/spec/mocks/comment.rb +19 -0
- data/spec/mocks/connection.rb +106 -0
- data/spec/mocks/mock_adapter.rb +30 -0
- data/spec/mocks/mock_record.rb +48 -0
- data/spec/mocks/photo.rb +11 -0
- data/spec/mocks/post.rb +75 -0
- data/spec/mocks/super_class.rb +2 -0
- data/spec/mocks/user.rb +8 -0
- data/spec/spec_helper.rb +68 -0
- data/tasks/gemspec.rake +42 -0
- data/tasks/rcov.rake +28 -0
- data/tasks/rdoc.rake +22 -0
- data/tasks/schema.rake +19 -0
- data/tasks/spec.rake +24 -0
- data/tasks/todo.rake +4 -0
- data/templates/schema.xml.erb +36 -0
- metadata +319 -0
data/History.txt
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
== 0.10.7 2009-11-16
|
2
|
+
* Ignore boost_fields that don't apply
|
3
|
+
* Ability to specify text_fields inside connectives
|
4
|
+
* Fix bug with newlines in strings incorrectly being considered multi-value
|
5
|
+
* Compatibility with RSolr 0.10.1
|
6
|
+
* Remove commented-out code entirely
|
7
|
+
|
8
|
+
== 0.10.6 2009-11-05
|
9
|
+
* Support more dismax parameters
|
10
|
+
* Support multiple boost queries
|
11
|
+
* Allow "extra" facet rows
|
12
|
+
* Allow exclusion of fulltext fields
|
13
|
+
* Allow specification of per-field highlighting params
|
14
|
+
* Specify coordinates using block extraction
|
15
|
+
* Return empty array if no highlights available
|
16
|
+
* Get stored text fields from hits
|
17
|
+
* Update docs to reflect a requirement of at least one search type
|
18
|
+
* added --max-memory and --min-memory parameters to sunspot-solr
|
19
|
+
* LocalLucene and LocalSolr compatible with Java 1.5
|
20
|
+
|
21
|
+
== 0.10.5 2009-10-22
|
22
|
+
* Fix highlighting for multiple-model search
|
23
|
+
|
24
|
+
== 0.10.4 2009-10-20
|
25
|
+
* Add adjust_params method, allowing experts to manually edit Solr params
|
26
|
+
* Track adds and deletes separately in session, and expose delete_dirty? method
|
27
|
+
* Allow clients to inject a singleton session proxy
|
28
|
+
|
29
|
+
== 0.10.3 2009-10-15
|
30
|
+
* Contiguous, not continuous
|
31
|
+
* Fail fast if less-than-1 radius passed for local search
|
32
|
+
|
33
|
+
== 0.10.2 2009-10-09
|
34
|
+
* Add Sunspot.config.xml_builder option, which is passed to RSolr
|
35
|
+
|
36
|
+
== 0.10.1 2009-10-08
|
37
|
+
* Fix directory bugs in sunspot-solr executable
|
38
|
+
|
39
|
+
== 0.10.0 2009-10-08
|
40
|
+
* Support for geographical search using LocalSolr
|
41
|
+
* Support for keyword highlighting, with custom deferred formatting
|
42
|
+
* New fulltext DSL for specifying advanced dismax options
|
43
|
+
* Support boost queries
|
44
|
+
* Support for search-time field boost
|
45
|
+
* Support for phrase fields
|
46
|
+
* Support for prefix queries
|
47
|
+
* Set default search-time field boost in setup
|
48
|
+
* Restrict field facet to a set of desired values
|
49
|
+
* Query facets support all facet options
|
50
|
+
* Allow scoping by text fields
|
51
|
+
* Support executing searches repeatedly
|
52
|
+
* Allow setting of Solr URL for integration tests in environment variable
|
53
|
+
* Add support for master/slave configurations
|
54
|
+
* Added logging options to sunspot-solr executable
|
55
|
+
* Added default solr config file location to Sunspot::Configuration
|
56
|
+
* Informative, non-firehose Search#inspect
|
57
|
+
* No longer require arguments to #paginate
|
58
|
+
* Silently ignore keyword calls with nil/blank/whitespace keywords
|
59
|
+
* Don't require that all searched types have a referenced field
|
60
|
+
* Correct backwards ranges
|
61
|
+
* Raise descriptive error if no types passed to search
|
62
|
+
* Handle empty query facets, query facet rows, and connectives
|
63
|
+
* Quote values in range restrictions if they contain spaces
|
64
|
+
* Fix bug in Sunspot::Util.full_const_get
|
65
|
+
* Remove support for :other option in time faceting
|
66
|
+
* Remove order_by_random() method
|
67
|
+
* Removed options and Query from public API
|
68
|
+
* Use built-in optparse instead of optiflag in bin/sunspot-solr
|
69
|
+
* Remove dependency on haml and use erb since it is only used to generate one file
|
70
|
+
|
71
|
+
== 0.9.0 2009-07-21
|
72
|
+
* Use Dismax parser for keyword search
|
73
|
+
* Field and document boosting
|
74
|
+
* Specify which fields to search in keyword search
|
75
|
+
* Allow indexing of multiple values in text fields
|
76
|
+
* Access keyword relevance score in Hit objects
|
77
|
+
* Allow stored fields, retrieve stored values from Hit objects
|
78
|
+
* Support more values in shorthand restrictions
|
79
|
+
* Disjunctions and conjunctions
|
80
|
+
* Random ordering
|
81
|
+
* Control all options for field facets
|
82
|
+
* Time range facets
|
83
|
+
* Get referenced objects from facets on foreign keys
|
84
|
+
* Facet by class
|
85
|
+
* Batch indexing
|
86
|
+
* New Date field type
|
87
|
+
* Direct access to data accessors
|
88
|
+
* Executable to configure production Solr instances
|
89
|
+
* Replace solr-ruby with RSolr
|
90
|
+
* Remove accidental ActiveSupport dependency
|
91
|
+
|
92
|
+
== 0.8.9 2009-06-23
|
93
|
+
* Fix OrderedHash bug in older versions of ActiveSupport
|
94
|
+
|
95
|
+
== 0.8.8 2009-06-15
|
96
|
+
* Escape type names to support namespaced classes
|
97
|
+
* Fix bug with anonymous modules in Ruby 1.9
|
98
|
+
|
99
|
+
== 0.8.7 2009-06-10
|
100
|
+
* Add --pid-dir option for sunspot-solr executable
|
101
|
+
|
102
|
+
== 0.8.5 2009-06-09
|
103
|
+
* Added dependencies for sunspot-solr executable to gem dependencies
|
104
|
+
* Search for adapters using class ancestors rather than superclasses
|
105
|
+
|
106
|
+
== 0.8.3 2009-06-03
|
107
|
+
* Index objects passed as a collection in a single HTTP request
|
108
|
+
|
109
|
+
== 0.8.2 2009-05-27
|
110
|
+
* Allow specification of Solr home when using sunspot-solr
|
111
|
+
|
112
|
+
== 0.8.1 2009-05-26
|
113
|
+
* Add Search#execute! to public API
|
114
|
+
|
115
|
+
== 0.8.0 2009-05-22
|
116
|
+
* Access query API directly; instantiate search without running it
|
117
|
+
* Dynamic fields
|
118
|
+
* Search blocks can be evaluated in calling context
|
119
|
+
|
120
|
+
== 0.7.3 2009-05-06
|
121
|
+
* Better exception handling when class doesn't have adapter/setup
|
122
|
+
|
123
|
+
== 0.7.2 2009-04-29
|
124
|
+
* Dirty sessions
|
125
|
+
|
126
|
+
== 0.7.1 2009-04-29
|
127
|
+
* Removed extlib dependency from gemspec
|
128
|
+
|
129
|
+
== 0.7.0 2009-04-28
|
130
|
+
* Less magic in the DSL
|
131
|
+
* Restrict by empty values
|
132
|
+
* Negative scoping using without() method
|
133
|
+
* Exclusion by object identity using without(instance)
|
134
|
+
* Support for faceting
|
135
|
+
* Explicit commits
|
136
|
+
* Boolean field type
|
137
|
+
* Attribute field flexibility
|
138
|
+
* Virtual field blocks can be evaluated in calling context
|
139
|
+
* Order available by multiple fields
|
140
|
+
* New adapter API
|
141
|
+
* Got rid of builder API
|
142
|
+
* Full documentation
|
143
|
+
|
144
|
+
== 0.0.2 2009-02-14
|
145
|
+
* Run sunspot's built-in Solr instance using
|
146
|
+
sunspot-solr executable
|
147
|
+
* Search hash interpretation delegated to
|
148
|
+
Builder object
|
149
|
+
|
150
|
+
== 0.0.1 2008-12-11
|
151
|
+
* Initial release
|
152
|
+
* Define indexing for any class using DSL
|
153
|
+
* Search indexed classes using DSL
|
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
2
|
+
a copy of this software and associated documentation files (the
|
3
|
+
'Software'), to deal in the Software without restriction, including
|
4
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
5
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
6
|
+
permit persons to whom the Software is furnished to do so, subject to
|
7
|
+
the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be
|
10
|
+
included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
13
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
15
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
16
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
17
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
18
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
= Sunspot
|
2
|
+
|
3
|
+
http://outoftime.github.com/sunspot
|
4
|
+
|
5
|
+
Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine.
|
6
|
+
Sunspot is built on top of the RSolr gem, which provides a low-level interface for Solr
|
7
|
+
interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful
|
8
|
+
features for indexing objects and searching for them.
|
9
|
+
|
10
|
+
Sunspot is designed to be easily plugged in to any ORM, or even non-database-backed
|
11
|
+
objects such as the filesystem.
|
12
|
+
|
13
|
+
This README is intended as a quick primer on what Sunspot is capable of; for
|
14
|
+
detailed treatment of Sunspot's full feature range, check out the wiki:
|
15
|
+
http://wiki.github.com/outoftime/sunspot
|
16
|
+
|
17
|
+
|
18
|
+
=== Features:
|
19
|
+
|
20
|
+
* Define indexing strategy for each searchable class using intuitive block-based API
|
21
|
+
* Clean separation between keyword-searchable fields and fields for scoping/ordering
|
22
|
+
* Define fields based on existing attributes or "virtual fields" for custom indexing
|
23
|
+
* Indexes each object's entire superclass hierarchy, for easy searching for all objects inheriting from a parent class
|
24
|
+
* Intuitive DSL for scoping searches, with all the usual boolean operators available
|
25
|
+
* Intuitive interface for requesting facets on indexed fields
|
26
|
+
* Extensible adapter architecture for easy integration of other ORMs or non-model classes
|
27
|
+
* Refine search using field facets, date range facets, or ultra-powerful query facets
|
28
|
+
* Full compatibility with will_paginate
|
29
|
+
* Ordering
|
30
|
+
|
31
|
+
== Installation
|
32
|
+
|
33
|
+
gem install sunspot
|
34
|
+
|
35
|
+
In order to start the packaged Solr installation, run:
|
36
|
+
|
37
|
+
sunspot-solr start -- [-d /path/to/data/directory] [-p port] [-s path/to/solr/home] [--pid-dir=path/to/pid/dir]
|
38
|
+
|
39
|
+
If you don't specify a data directory, your Solr index will be stored in your operating system's temporary directory.
|
40
|
+
|
41
|
+
If you specify a solr home, the directory must contain a <code>conf</code>
|
42
|
+
directory, which should contain at least <code>schema.xml</code> and
|
43
|
+
<code>solrconfig.xml</code>. Be sure to copy the <code>schema.xml</code> out of
|
44
|
+
the Sunspot gem's <code>solr/solr/conf</code> directory. Sunspot relies on the
|
45
|
+
field name patterns defined in the packaged <code>schema.xml</code>, so those
|
46
|
+
cannot be modified.
|
47
|
+
|
48
|
+
You can also run your own instance of Solr wherever you'd like; just copy the solr/config/schema.xml file out of the gem's solr into your installation.
|
49
|
+
You can change the URL at which Sunspot accesses Solr with:
|
50
|
+
|
51
|
+
Sunspot.config.solr.url = 'http://solr.my.host:9818/solr'
|
52
|
+
|
53
|
+
== Rails Integration
|
54
|
+
|
55
|
+
The {Sunspot::Rails}[http://github.com/outoftime/sunspot_rails] plugin makes
|
56
|
+
integrating Sunspot into Rails drop-in easy.
|
57
|
+
|
58
|
+
== Using Sunspot
|
59
|
+
|
60
|
+
=== Define an index:
|
61
|
+
|
62
|
+
class Post
|
63
|
+
#...
|
64
|
+
end
|
65
|
+
|
66
|
+
Sunspot.setup(Post) do
|
67
|
+
text :title, :body
|
68
|
+
string :author_name
|
69
|
+
integer :blog_id
|
70
|
+
integer :category_ids
|
71
|
+
float :average_rating, :using => :ratings_average
|
72
|
+
time :published_at
|
73
|
+
string :sort_title do
|
74
|
+
title.downcase.sub(/^(an?|the)\W+/, ''/) if title = self.title
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
See Sunspot.setup for more information.
|
79
|
+
|
80
|
+
Note that in order for a class to be searchable, it must have an adapter
|
81
|
+
registered for itself or one of its subclasses. Adapters allow Sunspot to load
|
82
|
+
objects out of persistent storage, and to determine their primary key for
|
83
|
+
indexing. {Sunspot::Rails}[http://github.com/outoftime/sunspot_rails] comes with
|
84
|
+
an adapter for ActiveRecord objects, but for other types of models you will need
|
85
|
+
to define your own. See Sunspot::Adapters for more information.
|
86
|
+
|
87
|
+
=== Search for objects:
|
88
|
+
|
89
|
+
search = Sunspot.search Post do
|
90
|
+
keywords 'great pizza'
|
91
|
+
with :author_name, 'Mark Twain'
|
92
|
+
with(:blog_id).any_of [2, 14]
|
93
|
+
with(:category_ids).all_of [4, 10]
|
94
|
+
with(:published_at).less_than Time.now
|
95
|
+
any_of do
|
96
|
+
with(:expired_at).greater_than(Time.now)
|
97
|
+
with(:expired_at, nil)
|
98
|
+
end
|
99
|
+
without :title, 'Bad Title'
|
100
|
+
without bad_instance # specifically exclude this instance from results
|
101
|
+
|
102
|
+
paginate :page => 3, :per_page => 15
|
103
|
+
order_by :average_rating, :desc
|
104
|
+
|
105
|
+
facet :blog_id
|
106
|
+
end
|
107
|
+
|
108
|
+
See Sunspot.search for more information.
|
109
|
+
|
110
|
+
=== Get data from search:
|
111
|
+
|
112
|
+
search.results
|
113
|
+
search.total
|
114
|
+
search.page
|
115
|
+
search.per_page
|
116
|
+
search.facet(:blog_id)
|
117
|
+
|
118
|
+
== About the API documentation
|
119
|
+
|
120
|
+
All of the methods documented in the RDoc are considered part of Sunspot's
|
121
|
+
public API. Methods that are not part of the public API are documented in the
|
122
|
+
code, but excluded from the RDoc. If you find yourself needing to access methods
|
123
|
+
that are not part of the public API in order to do what you need, please contact
|
124
|
+
me so I can rectify the situation!
|
125
|
+
|
126
|
+
== Dependencies
|
127
|
+
|
128
|
+
1. RSolr 0.10.1
|
129
|
+
2. Daemons 1.x
|
130
|
+
4. Java 1.5+
|
131
|
+
|
132
|
+
Sunspot has been tested with MRI 1.8.6 and 1.8.7, REE 1.8.6, YARV 1.9.1, and
|
133
|
+
JRuby 1.2.0
|
134
|
+
|
135
|
+
== Bugs
|
136
|
+
|
137
|
+
Please submit bug reports to
|
138
|
+
http://outoftime.lighthouseapp.com/projects/20339-sunspot
|
139
|
+
|
140
|
+
== Contribution Guidelines
|
141
|
+
|
142
|
+
Contributions are very welcome - both new features, enhancements, and bug fixes.
|
143
|
+
Bug reports with a failing regression test are also lovely. In order to keep the
|
144
|
+
contribution process as organized and smooth as possible, please follow these
|
145
|
+
guidelines:
|
146
|
+
|
147
|
+
* Contributions should be submitted via Sunspot's Lighthouse account, with an
|
148
|
+
attached git patch. See below for how to create a git patch.
|
149
|
+
* Patches should not make any changes in your patch to the gemspec task other
|
150
|
+
than adding/removing dependencies (e.g., changing the name, version, email,
|
151
|
+
description, etc.)
|
152
|
+
* Patches should not include any changes to the gemspec itself.
|
153
|
+
* Document any new methods, options, arguments, etc.
|
154
|
+
* Write tests.
|
155
|
+
* As much as possible, follow the coding and testing styles you see in existing
|
156
|
+
code. One could accuse me of being nitpicky about this, but consistent code is
|
157
|
+
easier to read, maintain, and enhance.
|
158
|
+
* Don't make any massive changes to the structure of library or test code. If
|
159
|
+
you think something needs a huge refactor or rearrangement, shoot me a
|
160
|
+
message; trying to apply that kind of patch without warning opens the door to
|
161
|
+
a world of conflict hurt.
|
162
|
+
|
163
|
+
Here's how to create a Git patch - assuming you're pulling from the canonical
|
164
|
+
Sunspot repository at `upstream`:
|
165
|
+
|
166
|
+
git fetch upstream
|
167
|
+
git format-patch upstre
|
168
|
+
|
169
|
+
== Further Reading
|
170
|
+
|
171
|
+
* Sunspot Discussion: http://groups.google.com/group/ruby-sunspot
|
172
|
+
* IRC: #sunspot-ruby @ Freenode
|
173
|
+
* Posts about Sunspot from my tumblog: http://outofti.me/tagged/sunspot
|
174
|
+
* Read about it on Linux Magazine: http://www.linux-mag.com/id/7341
|
175
|
+
|
176
|
+
== Contributors
|
177
|
+
|
178
|
+
* Mat Brown (mat@patch.com)
|
179
|
+
* Peer Allan (peer.allan@gmail.com)
|
180
|
+
* Dmitriy Dzema (dima@dzema.name)
|
181
|
+
* Benjamin Krause (bk@benjaminkrause.com)
|
182
|
+
* Marcel de Graaf (marcel@slashdev.nl)
|
183
|
+
* Brandon Keepers (brandon@opensoul.org)
|
184
|
+
* Peter Berkenbosch (peterberkenbosch@me.com)
|
185
|
+
* Brian Atkinson
|
186
|
+
* Tom Coleman (tom@thesnail.org)
|
187
|
+
* Matt Mitchell (goodieboy@gmail.com)
|
188
|
+
|
189
|
+
== License
|
190
|
+
|
191
|
+
Sunspot is distributed under the MIT License, copyright (c) 2008-2009 Mat Brown
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
=== 0.10.x ===
|
2
|
+
* Can retrieve facets from search via string
|
3
|
+
* Allow #latitude and #longitude as coordinate attributes
|
4
|
+
* Allow use of #text_fields from inside disjunction
|
5
|
+
|
6
|
+
* Assumed inconsistency
|
7
|
+
* Support all operations in batches. Make it smart.
|
8
|
+
* Don't use more than one commits when one is equivalent
|
9
|
+
* Preserve adds/deletes that are done after last commit
|
10
|
+
* Don't do adds and deletes for the same document out of order
|
11
|
+
* Don't do more than one add for the same document
|
12
|
+
* Do use as few requests as possible within those constraints
|
13
|
+
=== Future ===
|
14
|
+
* Support Solr functions (e.g. dismax :bf)
|
data/VERSION.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'optparse'
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'schema')
|
6
|
+
|
7
|
+
solr_directory = FileUtils.pwd
|
8
|
+
|
9
|
+
schema = Sunspot::Schema.new
|
10
|
+
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = 'Usage: sunspot-configure-solr [options]'
|
13
|
+
|
14
|
+
opts.on '--tokenizer=TOKENIZER', 'Tokenizer class to use' do |tokenizer|
|
15
|
+
schema.tokenizer = tokenizer
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on '--extra-filter=EXTRA_FILTER', 'Extra filters for tokenized text (you may specify this multiple times)' do |extra_filter|
|
19
|
+
schema.add_filter(extra_filter)
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on '--dir=CONF_DIR', 'Directory containing Solr configuration and schema' do |dir|
|
23
|
+
solr_directory = File.expand_path(dir)
|
24
|
+
end
|
25
|
+
end.parse!
|
26
|
+
|
27
|
+
conf_directory = File.join(solr_directory, 'conf')
|
28
|
+
schema_file = File.join(conf_directory, 'schema.xml')
|
29
|
+
|
30
|
+
FileUtils.mkdir_p(conf_directory)
|
31
|
+
|
32
|
+
if File.exist?(schema_file)
|
33
|
+
backup_file = File.join(conf_directory, "schema-#{File.mtime(schema_file).strftime('%Y%m%d%H%M%S')}.xml")
|
34
|
+
STDERR.puts("Backing up current schema file to #{File.expand_path(backup_file)}")
|
35
|
+
FileUtils.mv(schema_file, backup_file)
|
36
|
+
end
|
37
|
+
|
38
|
+
File.open(File.join(conf_directory, 'schema.xml'), 'w') do |file|
|
39
|
+
file << schema.to_xml
|
40
|
+
end
|
data/bin/sunspot-solr
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
using_gems = false
|
3
|
+
begin
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tempfile'
|
6
|
+
require 'tmpdir'
|
7
|
+
require 'optparse'
|
8
|
+
require 'daemons'
|
9
|
+
rescue LoadError => e
|
10
|
+
if using_gems
|
11
|
+
raise(e)
|
12
|
+
else
|
13
|
+
using_gems = true
|
14
|
+
require 'rubygems'
|
15
|
+
retry
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
working_directory = FileUtils.pwd
|
20
|
+
solr_install = File.expand_path(File.join(File.dirname(__FILE__), '..', 'solr'))
|
21
|
+
|
22
|
+
port = '8983'
|
23
|
+
data_dir = File.expand_path(File.join(Dir.tmpdir, 'solr_data'))
|
24
|
+
solr_home = File.join(solr_install, 'solr')
|
25
|
+
pid_dir = working_directory
|
26
|
+
log_file = nil
|
27
|
+
log_level = 'OFF'
|
28
|
+
min_memory = '128m'
|
29
|
+
max_memory = '512m'
|
30
|
+
|
31
|
+
OptionParser.new do |opts|
|
32
|
+
opts.banner = "Usage: sunspot-solr start [options]"
|
33
|
+
|
34
|
+
opts.on '-p', '--port=PORT', 'Port on which to run Solr (default 8983)' do |p|
|
35
|
+
port = p
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on '-d', '--data-directory=DIRECTORY', 'Solr data directory' do |d|
|
39
|
+
data_dir = File.expand_path(d)
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on '-s', '--solr-home=HOME', 'Solr home directory (should contain conf/ directory)' do |s|
|
43
|
+
solr_home = File.expand_path(s)
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on '--pid-dir=PID_DIR', 'Directory for pid files' do |pd|
|
47
|
+
pid_dir = File.expand_path(pd)
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on '-l', '--log-level=LOG_LEVEL', 'Solr logging level' do |l|
|
51
|
+
log_level = l
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on '--log-file=LOG_FILE', 'Path to Solr log file' do |lf|
|
55
|
+
log_file = File.expand_path(lf)
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on '--max-memory=MEMORY', 'Specify the maximum size of the memory allocation pool' do |mm|
|
59
|
+
max_memory = mm
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on '--min-memory=MEMORY', 'Specify the initial size of the memory allocation pool' do |mm|
|
63
|
+
min_memory = mm
|
64
|
+
end
|
65
|
+
end.parse!
|
66
|
+
|
67
|
+
options = { :dir_mode => :normal, :dir => pid_dir }
|
68
|
+
|
69
|
+
def logging_properties( log_file, log_level )
|
70
|
+
temp_file = Tempfile.new 'logging.properties'
|
71
|
+
temp_file << <<PROPERTIES
|
72
|
+
.level = #{log_level}
|
73
|
+
handlers = java.util.logging.FileHandler
|
74
|
+
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
75
|
+
java.util.logging.FileHandler.pattern = #{log_file}
|
76
|
+
PROPERTIES
|
77
|
+
temp_file.flush
|
78
|
+
temp_file.close
|
79
|
+
temp_file.path
|
80
|
+
end
|
81
|
+
|
82
|
+
Daemons.run_proc('sunspot-solr', options) do
|
83
|
+
FileUtils.cd(solr_install) do
|
84
|
+
args = ['java']
|
85
|
+
args << "-Xms#{min_memory}"
|
86
|
+
args << "-Xmx#{max_memory}"
|
87
|
+
args << "-Djetty.port=#{port}" if port
|
88
|
+
args << "-Dsolr.data.dir=#{data_dir}" if data_dir
|
89
|
+
args << "-Dsolr.solr.home=#{solr_home}" if solr_home
|
90
|
+
args << "-Djava.util.logging.config.file=#{logging_properties(log_file, log_level)}" if log_file and log_level != 'OFF'
|
91
|
+
args << '-jar' << File.join(solr_install, 'start.jar')
|
92
|
+
STDERR.puts(args * ' ')
|
93
|
+
Kernel.exec(*args)
|
94
|
+
end
|
95
|
+
end
|