
Forbiden 'it' as field value? Problems with searching
Reported by Jaroslaw Zabiello | October 10th, 2009 @ 03:08 PM | in 0.3.3
Is something special about 'it' as a field value? I cannot find anything for field value equal 'it'. Have a look at the following code:
{{{ ruby
testneo.rb
require 'rubygems'
require 'neo4j'
Neo4j::Config[:storage_path] =
File.dirname(FILE)+'/db/neo4j'
Lucene::Config[:store_on_file] = true
Lucene::Config[:storage_path] =
File.dirname(FILE)+'/db/lucene'
FileUtils.rm_rf Neo4j::Config[:storage_path]
FileUtils.rm_rf Lucene::Config[:storage_path] unless
Lucene::Config[:storage_path].nil?
class NeoLang
include Neo4j::NodeMixin property :code, :name, :available index
:code, :tokenized => true index :name, :tokenized => true
index :available, :tokenized => true def to_s
"#{self.code}(#{self.name})"
end end
Neo4j.start
Neo4j::Transaction.run do
node = NeoLang.new node.code = 'en' node.name = "English"
node.available = 1
node = NeoLang.new node.code = 'it' node.name = "Italian" node.available = 1 end
Neo4j::Transaction.run do
NeoLang.find(:available=>1).each{|o|puts o} # => en(English)
# => it(Italian) p NeoLang.find(:code=>'it').first # =>
nil .............................. WTF? puts
NeoLang.find(:code=>'en').first # => en(English)
puts '--'
# again, with Lucene DSL:
NeoLang.find('available:1').each{|o|puts o} # => en(English)
# => it(Italian) p NeoLang.find('code:it').first # => nil
.............................. WTF? puts
NeoLang.find('code:en').first # => en(English)
end
Neo4j.stop
MacBook Pro, Mac OS-X 2.6.1, used Lucene 2.4.0, but also tested with Lucene 2.9.0
$ uname -a Darwin MacBook-Pro-15-admin.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386
$ java -version java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-90, mixed
mode)
$ jruby -v jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) (2009-10-06 6586) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
$ jruby -S gem list neo4j neo4j (0.3.2)
$ jruby testneo.rb en(English)
it(Italian)
nil
en(English)
en(English)
it(Italian)
nil
en(English)
}}}
Comments and changes to this ticket
-
Jaroslaw Zabiello October 10th, 2009 @ 03:09 PM
Stupid lighthouse does not have preview button. The same code again: http://gist.github.com/206827
-
Jaroslaw Zabiello October 10th, 2009 @ 08:49 PM
This is another try. It does not matter if I use :tokenize => true or false for 'code' field. First API works, Lucene DSL does not.
#!/opt/jruby/bin/jruby require 'rubygems' require 'neo4j' NEO4J_STORAGE = File.dirname(__FILE__)+'/db/neo4j' LUCENE_STORAGE = File.dirname(__FILE__)+'/db/lucene' Neo4j::Config[:storage_path] = NEO4J_STORAGE Lucene::Config[:store_on_file] = true Lucene::Config[:storage_path] = LUCENE_STORAGE FileUtils.rm_rf NEO4J_STORAGE FileUtils.rm_rf LUCENE_STORAGE class NeoLang include Neo4j::NodeMixin property :code index :code def to_s "#{self.code}" end end Neo4j.start @langs = %w(en at ut ti it id) Neo4j::Transaction.run do @langs.each do |lang| node = NeoLang.new node.code = lang end end Neo4j::Transaction.run do puts "Try1:" @langs.each do |lang| puts "#{lang} -> #{NeoLang.find(:code=>lang).first.to_s}" end puts "Try2:" @langs.each do |lang| puts "#{lang} -> #{NeoLang.find('code:'+lang).first.to_s}" end end Neo4j.stop =begin Result: Try1: en -> en at -> at ut -> ut ti -> ti it -> it id -> id Try2: en -> en at -> ut -> ut ti -> ti it -> id -> id =end
-
Andreas Ronge October 10th, 2009 @ 10:01 PM
I don't know, but I would not be surprised if lucene treated "it" like and, or - do not index those words.
Have to check the lucene documentation.
But if you don't use :tokenized => true then this is weired. -
Andreas Ronge October 12th, 2009 @ 02:57 PM
- Milestone set to 0.3.3
-
Andreas Ronge October 12th, 2009 @ 03:19 PM
- State changed from new to invalid
Solved in ticket 87 - http://neo4j.lighthouseapp.com/projects/15548/tickets/87-support-fo...
Need to set correct analyzer - :keyword.
I have added RSpecs for the example above.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Neo4j.rb is a graph database framework for JRuby.
It provides:
* Mapping of ruby objects to nodes in networks rather than in tables.
* Storage of ruby object to a file system.
* Fast traversal of relationships between nodes in a hugh node space.
* Transaction with rollbacks support.
* Indexing and quering of ruby objects.
* Integration with Rails