redcar 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/CHANGES +5 -0
  2. data/Rakefile +1 -2
  3. data/lib/redcar/installer.rb +2 -1
  4. data/lib/redcar.rb +2 -2
  5. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  6. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  7. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  8. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  9. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  10. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  11. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  12. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  13. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  14. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  15. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  16. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  17. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  18. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  19. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  20. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  21. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  22. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  23. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  24. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  25. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  26. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  27. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  28. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  29. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  30. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  31. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  32. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  33. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  34. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  35. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  36. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  37. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  38. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  39. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  40. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  41. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  42. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  43. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  44. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  45. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  46. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  47. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  48. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  49. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  50. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  51. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  52. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  53. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  54. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  55. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  56. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  57. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  58. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  59. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  60. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  61. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  62. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  63. metadata +62 -4
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.9.1 (2 December 2010)
2
+ ===============================
3
+
4
+ * Move rhino mirror (Dan Lucraft)
5
+
1
6
  Version 0.9 (25 November 2010)
2
7
  ==============================
3
8
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- REDCAR_VERSION = "0.9.0" # also change in lib/redcar.rb!
1
+ REDCAR_VERSION = "0.9.1" # also change in lib/redcar.rb!
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
4
  require 'spec/rake/spectask'
@@ -228,7 +228,6 @@ task :release => :gem do
228
228
  }
229
229
 
230
230
  s3_uploads.each do |source, target|
231
- puts [source, target]
232
231
  AWS::S3::S3Object.store(target, open(source), 'redcar', :access => :public_read)
233
232
  end
234
233
  end
@@ -63,7 +63,8 @@ module Redcar
63
63
  "http://redcar.s3.amazonaws.com/org-enclojure-repl-server.jar" => nil,
64
64
  "http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/groovy/groovy-all/1.7.4/groovy-all-1.7.4.jar" => "/groovy-all.jar",
65
65
  "http://mirrors.ibiblio.org/pub/mirrors/maven2/org/tmatesoft/svnkit/svnkit/1.3.4/svnkit-1.3.4.jar" => "/svnkit.jar",
66
- "http://mirrors.ibiblio.org/pub/mirrors/maven2/rhino/js/1.7R2/js-1.7R2.jar" => "/js.jar"
66
+ # "http://mirrors.ibiblio.org/pub/mirrors/maven2/rhino/js/1.7R2/js-1.7R2.jar" => "/js.jar",
67
+ "http://redcar.s3.amazonaws.com/deps/rhino-js-1.7R2.jar" => "/js.jar"
67
68
  },
68
69
  :windows => {
69
70
  "http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/#{xulrunner_version}/runtimes/xulrunner-#{xulrunner_version}.en-US.win32.zip" => "xulrunner-#{xulrunner_version}.en-US.win32.zip",
data/lib/redcar.rb CHANGED
@@ -51,10 +51,10 @@ end
51
51
  #
52
52
  # and so on.
53
53
  module Redcar
54
- VERSION = '0.9.0' # also change in the Rakefile!
54
+ VERSION = '0.9.1' # also change in the Rakefile!
55
55
  VERSION_MAJOR = 0
56
56
  VERSION_MINOR = 9
57
- VERSION_RELEASE = 0
57
+ VERSION_RELEASE = 1
58
58
 
59
59
  ENVIRONMENTS = [:user, :debug, :test]
60
60
 
@@ -0,0 +1,147 @@
1
+ == 0.4.6 / 2010-08-31
2
+ * Bug fix: Using a has_one - should only delete the relationship to the old node, NOT delete the old node (#123)
3
+
4
+ == 0.4.5 / 2010-08-18
5
+ * Bug fix: When setting an indexed property = nil, raises an undefined method "root_class" exception (#122)
6
+
7
+ == 0.4.4 / 2010-08-01
8
+ * Fixed bug on traversing when using the RelationshipMixin (#121)
9
+ * BatchInserter and JRuby 1.6 - Fix iteration error with trying to modify in-place hash
10
+
11
+ == 0.4.3 / 2010-04-10
12
+ * Fixed .gitignore - make sure that we do not include unnecessarily files like neo4j databases. Release 0.4.2 contained test data.
13
+ * Added synchronize around Index.new so that two thread can't modify the same index at the same time.
14
+
15
+ == 0.4.2 / 2010-04-08
16
+ * No index on properties for the initialize method bug (#116)
17
+ * Tidy up Thread Synchronization in Lucene wrapper - lucene indexing performance improvement (#117)
18
+ * Permission bug loading neo4j jar file (#118)
19
+ * Spike: Make NodeMixin ActiveModel complient - experimental (#115)
20
+
21
+ == 0.4.1 / 2010-03-11
22
+ * Migrations (#108)
23
+ * BatchInserter (#111)
24
+ * Neo4j::Relationship.new should take a hash of properties (#110)
25
+ * Upgrade to neo4j-1.0 (#114)
26
+ * Bigfix: has_one should replace old relationship (#106)
27
+ * Bugfix: custom accessors for NodeMixin#update (#113)
28
+ * Bugfix: Indexed properties problem on extented ruby classes critical "properties indexer" (#112)
29
+
30
+ == 0.4.0 / 2010-02-06
31
+ * Performance improvements and Refactoring: Use and Extend Neo4j Java Classes (#97)
32
+ * Support for Index and Declaration of Properties on Relationships (#91)
33
+ * Upgrade to neo4j-1.0 rc (#100)
34
+ * All internal properties should be prefix with a '_',0.4.0 (#105)
35
+ * Generate relationship accessor methods for declared has_n and has_one relationships (#104)
36
+ * New way of creating relationship - Neo4j::Relationship.new (#103)
37
+ * Neo4j#init_node method should take one or more args (#98)
38
+ * Namespaced relationships: has_one...from using the wrong has_n...to(#92)
39
+ * Neo4j::NodeMixin and Neo4j::Node should allow a hash for initialization (#99)
40
+
41
+ == 0.3.3 / 2009-11-25
42
+ * Support for a counter property on has_lists (#75)
43
+ * Support for Cascade delete. On has_n, had_one and has_list (#81)
44
+ * NodeMixin#all should work with inheritance - Child classes should have a relationship of their own. (#64)
45
+ * Support for other lucene analyzer then StandardAnalyzer (#87)
46
+ * NodeMixin initialize should accept block like docs (#82)
47
+ * Add incoming relationship should work as expected: n1.relationships.incoming(:foo) << n2 (#80)
48
+ * Delete node from a has_list relationship should work as expected (#79)
49
+ * Improve stacktraces (#94)
50
+ * Removed sideeffect of rspecs (#90)
51
+ * Add debug method on NodeMixin to print it self (#88)
52
+ * Removed to_a method (#73)
53
+ * Upgrade to neo4j-1.0b10 (#95)
54
+ * Upgrade to lucene 2.9.0 (#83)
55
+ * Refactoring: RSpecs (#74)
56
+ * Refactoring: aggregate each, renamed to property aggregator (#72)
57
+ * BugFix: neo4j gem cannot be built from the source (#86)
58
+ * BugFix: Neo4j::relationship should not raise Exception if there are no relationships (#78)
59
+
60
+ == 0.3.2 / 2009-09-17
61
+ * Added support for aggregating nodes (#65)
62
+ * Wrapped Neo4j GraphAlgo AllSimplePath (#70)
63
+ * Added traversal with traversal position (#71)
64
+ * Removed DynamicAccessors mixin, replaced by [] operator (#67)
65
+ * Impl Neo4j.all_nodes (#69)
66
+ * Upgrated Neo4j jar file to 1.0-b9
67
+ * The Neo4j#relationship method now allows a filter parameter (#66)
68
+ * Neo4j.rb now can read database not created by Neo4j.rb - does not require classname property (#63)
69
+ * REST - added an "all" value for the depth traversal query parameter (#62)
70
+ * REST - Performance improvments using the Rest Mixin (#60)
71
+
72
+ == 0.3.1 / 2009-07-25
73
+ * Feature, extension - find path between given pair of nodes (#58)
74
+ * Fix a messy exception on GET /nodes/UnknownClassName (#57)
75
+ * Bug - exception on GET /nodes/classname/rel if rel is a has_one relationship (#56)
76
+ * Bug: GET /nodes/classname missing out nodes with no properties (#55)
77
+ * Bug: Lucene sorting caused exception if there were no documents (#54)
78
+ * Bug: reindexer fails to connect nodes to the IndexNode (#53)
79
+
80
+ == 0.3.0 / 2009-06-25
81
+ * Neo4j should track node changes
82
+ * RESTful support for lucene queries, sorting and paging
83
+ * RESTful support for Relationships
84
+ * RESTful support for Node and properties
85
+ * Experimental support for Master-Slave Replication via REST
86
+ * RESTful Node representation should contain hyperlinks to relationships
87
+ * Added some handy method like first and empty? on relationships
88
+ * Use new neo4j: neo-1.0-b8
89
+ * Add an event handler for create/delete nodes start/stop neo, update property/relationship
90
+ * The NodeMixin should behave like a hash, added [] and []= methods
91
+ * Support list topology - has_list and belongs_to_list Neo4j::NodeMixin Classmethods
92
+ * Should be possible to add relationships without declaring them (Neo4j#relationships.outgoing(:friends) << node)
93
+ * Neo4j extensions file structure, should be easy to create your own extensions
94
+ * Rename relation to relationship (Neo4j::Relations => Neo4j::Relationships, DynamicRelation => Relationship) [data incompatible change]
95
+ * Auto Transaction is now optional
96
+ * Setting Float properties fails under JRuby1.2.0
97
+ * Bug: Indexing relationships does not work
98
+ * Make the ReferenceNode include Neo4j::NodeMixin
99
+ * Added handy Neo4j class that simply includes the Neo4j::NodeMixin
100
+ * Neo4j::IndexNode now holds references to all nodes (Neo4j.ref_node -> Neo4j::IndexNode -> ...)
101
+
102
+
103
+ == 0.2.1 / 2009-03-15
104
+ * Refactoring of lucene indexing of the node space (28)
105
+ * Fixed bug on Neo4j::Nodemixin#property? (#22)
106
+
107
+
108
+ == 0.2.0 / 2009-01-20
109
+ * Impl. Neo4j::Node#traverse - enables traversal and filtering using TraversalPosition info (#17,#19)
110
+ * Impl. traversal to any depth (#15)
111
+ * Impl. traversal several relationships type at the same time (#16)
112
+ * Fixed a Lucene timezone bug (#20)
113
+ * Lots of refactoring of the neo4j.rb traversal code and RSpecs
114
+
115
+ == 0.1.0 / 2008-12-18
116
+ * Property can now be of any type (and not only String, Fixnum, Float)
117
+ * Indexing and Query with Date and DateTime
118
+ * YARD documentation
119
+ * Properties can be removed
120
+ * A property can be set to nil (it will then be removed).
121
+
122
+ == 0.0.7 / 2008-12-10
123
+ * Added method to_param and methods on the value object needed for Ruby on Rails
124
+ * Impl. update from a value object/hash for a node
125
+ * Impl. generation of value object classes/instances from a node.
126
+ * Refactoring the Transaction handling (reuse PlaceboTransaction instances if possible)
127
+ * Removed the need to start and stop neo. It will be done automatically when needed.
128
+
129
+
130
+ == 0.0.6 / 2008-12-03
131
+ * Removed the configuration from the Neo4j.start method. Now exist in Neo4j::Config and Lucene::Config.
132
+ * Implemented sort_by method.
133
+ * Lazy loading of search result. Execute the query and load the nodes only if needed.
134
+ * Added support to use lucene query language, example: Person.find("name:foo AND age:42")
135
+ * All test now uses RAM based lucene indexes.
136
+
137
+ == 0.0.5 / 2008-11-17
138
+ * Supports keeping lucene index in memory instead of on disk
139
+ * Added support for lucene full text search
140
+ * Fixed so neo4j runs on JRuby 1.1.5
141
+ * Implemented support for reindex all instances of a node class. This is needed if the lucene index is kept in memory or if the index is changed.
142
+ * Added ReferenceNode. All nodes now have a relationship from this reference node.
143
+ * Lots of refactoring
144
+ * Added the IMDB example. It shows how to create a neo database, lucene queries and node traversals.
145
+
146
+ == 0.0.4 / 2008-10-23
147
+ * First release to rubyforge
@@ -0,0 +1,17 @@
1
+ Maintainer:
2
+ Andreas Ronge <andreas dot ronge at gmail dot com>
3
+
4
+ Contributors:
5
+ * Martin Kleppmann
6
+ * Peter Neubauer
7
+ * Jan-Felix Wittmann
8
+ * Marius Mårnes Mathiesen
9
+ * Bert Fitié
10
+ * Jan Berkel
11
+ * David Beckwith
12
+ * Johny Ho
13
+ * Carlo Cabanilla
14
+ * Anders Janmyr
15
+ * Nick Sieger
16
+ * Sean Bowman
17
+ * BrilliantArc
@@ -0,0 +1,9 @@
1
+ source :gemcutter
2
+
3
+ gemspec
4
+
5
+ gem "rake", ">= 0.8.7"
6
+ gem "rdoc", ">= 2.5.10"
7
+ gem "horo", ">= 1.0.2"
8
+ gem "rspec", ">= 2.0.0"
9
+
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lucene (0.5.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.2)
10
+ horo (1.0.2)
11
+ rdoc (~> 2.5)
12
+ rake (0.8.7)
13
+ rdoc (2.5.11)
14
+ rspec (2.0.1)
15
+ rspec-core (~> 2.0.1)
16
+ rspec-expectations (~> 2.0.1)
17
+ rspec-mocks (~> 2.0.1)
18
+ rspec-core (2.0.1)
19
+ rspec-expectations (2.0.1)
20
+ diff-lcs (>= 1.1.2)
21
+ rspec-mocks (2.0.1)
22
+ rspec-core (~> 2.0.1)
23
+ rspec-expectations (~> 2.0.1)
24
+
25
+ PLATFORMS
26
+ java
27
+
28
+ DEPENDENCIES
29
+ horo (>= 1.0.2)
30
+ lucene!
31
+ rake (>= 0.8.7)
32
+ rdoc (>= 2.5.10)
33
+ rspec (>= 2.0.0)
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Andreas Ronge
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,283 @@
1
+ = Lucene.rb
2
+
3
+ Lucene.rb is JRuby wrapper for the Lucene document database.
4
+
5
+ * Lucene (http://lucene.apache.org/java/docs/index.html) for querying and indexing.
6
+
7
+ == Status
8
+
9
+ This library was once included in the neo4j.rb gem (version <= 0.4.6).
10
+ The neo4j wrapper has now replaced this library with the included Java neo4j-lucene component. The main reason for this split was that neo4j now uses two phase commit to keep the databases in sync.
11
+
12
+ === TODO
13
+ * Upgrade to newer lucene 3.x
14
+ * Check the thread synchronization and locking - is this needed ?
15
+
16
+ == Installation
17
+
18
+ ==== Install JRuby
19
+ The easiest way to install JRuby is by using RVM, see http://rvm.beginrescueend.com. Otherwise check: http://kenai.com/projects/jruby/pages/GettingStarted#Installing_JRuby
20
+
21
+ == Lucene.rb
22
+
23
+ Lucene provides:
24
+ * Flexible Queries - Phrases, Wildcards, Compound boolean expressions etc...
25
+ * Field-specific Queries eg. title, artist, album
26
+ * Sorting
27
+ * Ranked Searching
28
+
29
+ The Lucene index will be updated after the transaction commits. It is not possible to
30
+ query for something that has been created inside the same transaction as where the query is performed.
31
+
32
+ === Lucene Document
33
+
34
+ In Lucene everything is a Document. A document can represent anything textual:
35
+ A Word Document, a DVD (the textual metadata only), or a Neo4j.rb node.
36
+ A document is like a record or row in a relationship database.
37
+
38
+ The following example shows how a document can be created by using the ''<<'' operator
39
+ on the Lucene::Index class and found using the Lucene::Index#find method.
40
+
41
+ Example of how to write a document and find it:
42
+
43
+ require 'lucene'
44
+
45
+ include Lucene
46
+
47
+ # the var/myindex parameter is either a path where to store the index or
48
+ # just a key if index is kept in memory (see below)
49
+ index = Index.new('var/myindex')
50
+
51
+ # add one document (a document is like a record or row in a relationship database)
52
+ index << {:id=>'1', :name=>'foo'}
53
+
54
+ # write to the index file
55
+ index.commit
56
+
57
+ # find a document with name foo
58
+ # hits is a ruby Enumeration of documents
59
+ hits = index.find{name == 'foo'}
60
+
61
+ # show the id of the first document (document 0) found
62
+ # (the document contains all stored fields - see below)
63
+ hits[0][:id] # => '1'
64
+
65
+ Notice that you have to call the commit method in order to update the index (both disk and in memory indexes).
66
+ Performing several update and delete operations before a commit will give much
67
+ better performance than committing after each operation.
68
+
69
+ === Keep indexing on disk
70
+
71
+ By default Neo4j::Lucene keeps indexes in memory. That means that when the application restarts
72
+ the index will be gone and you have to reindex everything again.
73
+
74
+ To store indexes on file:
75
+
76
+ Lucene::Config[:store_on_file] = true
77
+ Lucene::Config[:storage_path] => '/home/neo/lucene-db'
78
+
79
+ When creating a new index the location of the index will be the Lucene::Config[:storage_path] + index path
80
+ Example:
81
+
82
+ Lucene::Config[:store_on_file] = true
83
+ Lucene::Config[:storage_path] => '/home/neo/lucene-db'
84
+ index = Index.new('/foo/lucene')
85
+
86
+ The example above will store the index at /home/neo/lucene-db/foo/lucene
87
+
88
+ === Indexing several values with the same key
89
+
90
+ Let say a person can have several phone numbers. How do we index that?
91
+
92
+ index << {:id=>'1', :name=>'adam', :phone => ['987-654', '1234-5678']}
93
+
94
+
95
+ === Id field
96
+
97
+ All Documents must have one id field. If an id is not specified, the default will be: :id of type String.
98
+ A different id can be specified using the field_infos id_field property on the index:
99
+
100
+ index = Index.new('some/path/to/the/index')
101
+ index.field_infos.id_field = :my_id
102
+
103
+ To change the type of the my_id from String to a different type see below.
104
+
105
+ === Conversion of types
106
+
107
+ Lucene.rb can handle type conversion for you. (The Java Lucene library stores all
108
+ the fields as Strings)
109
+ For example if you want the id field to be a Fixnum
110
+
111
+ require 'lucene'
112
+ include Lucene
113
+
114
+ index = Index.new('var/myindex') # store the index at dir: var/myindex
115
+ index.field_infos[:id][:type] = Fixnum
116
+
117
+ index << {:id=>1, :name=>'foo'} # notice 1 is not a string now
118
+
119
+ index.commit
120
+
121
+ # find that document, hits is a ruby Enumeration of documents
122
+ hits = index.find(:name => 'foo')
123
+
124
+ # show the id of the first document (document 0) found
125
+ # (the document contains all stored fields - see below)
126
+ doc[0][:id] # => 1
127
+
128
+ If the field_info type parameter is not set then it has a default value of String.
129
+
130
+ === Storage of fields
131
+
132
+ By default only the id field will be stored.
133
+ That means that in the example above the :name field will not be included in the document.
134
+
135
+ Example
136
+ doc = index.find('name' => 'foo')
137
+ doc[:id] # => 1
138
+ doc[:name] # => nil
139
+
140
+ Use the field info :store=true if you want a field to be stored in the index
141
+ (otherwise it will only be searchable).
142
+
143
+ Example
144
+
145
+ require 'lucene'
146
+ include Lucene
147
+
148
+ index = Index.new('var/myindex') # store the index at dir: var/myindex
149
+ index.field_infos[:id][:type] = Fixnum
150
+ index.field_infos[:name][:store] = true # store this field
151
+
152
+ index << {:id=>1, :name=>'foo'} # notice 1 is not a string now
153
+
154
+ index.commit
155
+
156
+ # find that document, hits is a ruby Enumeration of documents
157
+ hits = index.find('name' => 'foo')
158
+
159
+ # let say hits only contains one document so we can use doc[0] for that one
160
+ # that document contains all stored fields (see below)
161
+ doc[0][:id] # => 1
162
+ doc[0][:name] # => 'foo'
163
+
164
+ === Setting field infos
165
+
166
+ As shown above you can set field infos like this
167
+
168
+ index.field_infos[:id][:type] = Fixnum
169
+
170
+ Or you can set several properties like this:
171
+
172
+ index.field_infos[:id] = {:type => Fixnum, :store => true}
173
+
174
+ ==== Tokenized
175
+
176
+ Field infos can be used to specify if the should be tokenized.
177
+ If this value is not set then the entire content of the field will be considered as a single term.
178
+
179
+ Example
180
+
181
+ index.field_infos[:text][:tokenized] = true
182
+
183
+ If not specified, the default is 'false'
184
+
185
+ ==== Analyzer
186
+
187
+ Field infos can also be used to set which analyzer should be used.
188
+ If none is specified, the default analyzer - org.apache.lucene.analysis.standard.StandardAnalyzer (:standard) will be used.
189
+
190
+
191
+ index.field_infos[:code][:tokenized] = false
192
+ index.field_infos[:code][:analyzer] = :standard
193
+
194
+ The following analyzer is supported
195
+ * :standard (default) - org.apache.lucene.analysis.standard.StandardAnalyzer
196
+ * :keyword - org.apache.lucene.analysis.KeywordAnalyzer
197
+ * :simple - org.apache.lucene.analysis.SimpleAnalyzer
198
+ * :whitespace - org.apache.lucene.analysis.WhitespaceAnalyzer
199
+ * :stop - org.apache.lucene.analysis.StopAnalyzer
200
+
201
+ For more info, check the Lucene documentation, http://lucene.apache.org/java/docs/
202
+
203
+
204
+ === Simple Queries
205
+
206
+ Lucene.rb support search in several fields:
207
+ Example:
208
+
209
+ # finds all document having both name 'foo' and age 42
210
+ hits = index.find('name' => 'foo', :age=>42)
211
+
212
+ Range queries:
213
+
214
+ # finds all document having both name 'foo' and age between 3 and 30
215
+ hits = index.find('name' => 'foo', :age=>3..30)
216
+
217
+ === Lucene Queries
218
+
219
+ If the query is string then the string is a Lucene query.
220
+
221
+ hits = index.find('name:foo')
222
+
223
+ For more information see:
224
+ http://lucene.apache.org/java/2_4_0/queryparsersyntax.html
225
+
226
+ === Advanced Queries (DSL)
227
+
228
+ The queries above can also be written in a lucene.rb DSL:
229
+
230
+ hits = index.find { (name == 'andreas') & (foo == 'bar')}
231
+
232
+ Expression with OR (|) is supported, example
233
+
234
+ # find all documents with name 'andreas' or age between 30 and 40
235
+ hits = index.find { (name == 'andreas') | (age == 30..40)}
236
+
237
+ === Sorting
238
+
239
+ Sorting is specified by the 'sort_by' parameter
240
+ Example:
241
+
242
+ hits = index.find(:name => 'foo', :sort_by=>:category)
243
+
244
+ To sort by several fields:
245
+
246
+ hits = index.find(:name => 'foo', :sort_by=>[:category, :country])
247
+
248
+ Example sort order:
249
+
250
+ hits = index.find(:name => 'foo', :sort_by=>[Desc[:category, :country], Asc[:city]])
251
+
252
+ === Thread-safety
253
+
254
+ The Lucene::Index is thread safe.
255
+ It guarantees that an index is not updated from two threads at the same time.
256
+
257
+
258
+ === Lucene Transactions
259
+
260
+ Use the Lucene::Transaction in order to do atomic commits.
261
+ By using a transaction you do not need to call the Index.commit method.
262
+
263
+ Example:
264
+
265
+ Transaction.run do |t|
266
+ index = Index.new('var/index/foo')
267
+ index << { id=>42, :name=>'andreas'}
268
+ t.failure # rollback
269
+ end
270
+
271
+ result = index.find('name' => 'andreas')
272
+ result.size.should == 0
273
+
274
+ You can find uncommitted documents with the uncommitted index property.
275
+
276
+ Example:
277
+
278
+ index = Index.new('var/index/foo')
279
+ index.uncommited #=> [document1, document2]
280
+
281
+ Notice that even if it looks like a new Index instance object was created the index.uncommitted
282
+ may return a non-empty array. This is because Index.new is a singleton - a new instance object is not created.
283
+
@@ -0,0 +1,35 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+
3
+ require 'rake'
4
+ require 'rdoc/task'
5
+
6
+ require "lucene/version"
7
+
8
+
9
+ def assert_committed
10
+ status = %x{git status}
11
+ fail("Can't release gem unless everything is committed") unless status =~ /nothing to commit \(working directory clean\)|nothing added to commit but untracked files present/
12
+ end
13
+ desc "create the gemspec"
14
+ task :build do
15
+ system "gem build lucene.gemspec"
16
+ end
17
+
18
+ desc "release gem to gemcutter"
19
+ task :release => :build do
20
+ assert_committed
21
+ system "gem push lucene-#{Lucene::VERSION}.gem"
22
+ end
23
+
24
+ desc "Generate documentation for Neo4j.rb"
25
+ RDoc::Task.new do |rdoc|
26
+ rdoc.rdoc_dir = 'doc/rdoc'
27
+ rdoc.title = "Lucene.rb Documentation #{Lucene::VERSION}"
28
+ rdoc.options << '-f' << 'horo'
29
+ rdoc.options << '-c' << 'utf-8'
30
+ rdoc.options << '-m' << 'README.rdoc'
31
+
32
+ rdoc.rdoc_files.include('README.rdoc')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
35
+
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../lib")
2
+
3
+ require 'rubygems'
4
+ require 'neo4j'
5
+ require 'neo4j/extensions/activemodel'
6
+
7
+ class Person
8
+ include Neo4j::NodeMixin
9
+ include ActiveModel::Serializers::JSON
10
+ include ActiveModel::Serializers::Xml
11
+
12
+ property :first_name
13
+ property :last_name
14
+
15
+ end
16
+
17
+
18
+ Neo4j::Transaction.run do
19
+ person = Person.new :first_name => 'jimmy', :last_name => 'smith'
20
+
21
+ puts "HASH: #{person.serializable_hash}"
22
+ puts "JSON: #{person.to_json}"
23
+ puts "XML : #{person.to_xml}"
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../lib")
2
+
3
+ require 'rubygems'
4
+ require 'neo4j'
5
+ require 'neo4j/extensions/activemodel'
6
+
7
+ class Person
8
+ include Neo4j::NodeMixin
9
+ include ActiveModel::Validations
10
+
11
+ property :first_name
12
+ property :last_name
13
+
14
+ validates_presence_of :first_name, :last_name
15
+ end
16
+
17
+
18
+ Neo4j::Transaction.run do
19
+ person = Person.new
20
+
21
+ puts person.valid?
22
+ puts person.errors.inspect
23
+ person.first_name = "Hej"
24
+ person.last_name = "hop"
25
+ puts person.valid?
26
+ end
@@ -0,0 +1,4 @@
1
+ task :default => :spec
2
+ task :spec do
3
+ system("spec --options spec/spec.opts spec/*_spec.rb") || raise
4
+ end
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../lib")
2
+ require 'neo4j'
3
+ require 'rubygems'
4
+ require 'sinatra/base'
5
+ require 'neo4j/extensions/rest'
6
+ #require 'sinatra'
7
+
8
+ Sinatra::Application.set(:public, File.dirname(__FILE__) + "/public")
9
+
10
+ Sinatra::Application.get('/') do
11
+ erb :index
12
+ end
13
+
14
+ Sinatra::Application.post('/echo') do
15
+ puts request.body
16
+ request.body
17
+ end
18
+ Sinatra::Application.post('/jquery.js') do
19
+ puts request.body
20
+ request.body
21
+ end
22
+
23
+ Sinatra::Application.get('/echo') do
24
+ puts request.body
25
+ 'pong get'
26
+ end
27
+ puts "HOST " + Sinatra::Application.host
28
+ Sinatra::Application.run! :port => 9123
29
+ #Neo4j.start_rest