Issues with search certain phrases

12 views
Skip to first unread message

Mat Gren

unread,
Nov 18, 2014, 5:13:04 PM11/18/14
to picky...@googlegroups.com
Hi there!

I have an issue with searching words like "front-end" or "1Z0-803" in my source file. The search doesn't find them although they are indexed.

Let me show you my case. Code:

require 'picky'

data = Picky::Index.new :content do
  category :text, partial: Picky::Partial::None.new
end

Document = Struct.new :id, :text

File.open 'story.txt' do |story|
  data.add Document.new(1, story.read)
end

text = Picky::Search.new data

text.search('front-end')

The story.txt file is simple:
back-end developer
front-end developer
1Z0-803
---end of file---

When I debug it I see that my file was properly indexed:
@inverted={"back-end"=>[1], "developer"=>[1], "front-end"=>[1], "1z0-803"=>[1]

but when I launch above search, there is no result. The same goes for when I search '1z0-803'. 

Thank you in advance for your help!

Cheers, Mat



Picky / Florian Hanke

unread,
Nov 18, 2014, 5:57:11 PM11/18/14
to picky...@googlegroups.com
Hi Mat,

You've sadly hit an open issue! :(

Currently, Picky interprets - to be a "range" character (to do ranged queries, e.g. "amount:1-5").

Use Picky::Query::Token.range_character = '…' to set it to another character. I'm planning to use a less problematic character, or set it to nil by default.

I've added a code example you can run below.

Cheers,
   Florian

---
require 'picky'

Picky::Query::Token.range_character = '…'

data = Picky::Index.new :content do
  category :text, partial: Picky::Partial::None.new
end

Document = Struct.new :id, :text

data.add Document.new(1, 'back-end developer')
data.add Document.new(2, 'front-end developer')
data.add Document.new(3, '1Z0-803')

text = Picky::Search.new data

p text.search('developer', 20).ids
---
Reply all
Reply to author
Forward
0 new messages