Sha256: 283097b371365329189208384c1ab502f05727c5ba0dfdcb90385d3b3d8227fb

Contents?: true

Size: 1.74 KB

Versions: 103

Compression:

Stored size: 1.74 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe "Regression" do
  
  it 'does not get confused' do
    index = Picky::Index.new :dynamic_weights do
      category :text1
      category :text2
      category :text3
      category :text4
    end
    try = Picky::Search.new index

    try.search('hello hello hello').allocations.size.should == 0

    thing = Struct.new(:id, :text1, :text2, :text3, :text4)
    index.add thing.new(1, 'hello', 'hello', 'hello', 'world')

    try.search('hello hello hello').allocations.size.should == 27

    index.add thing.new(2, 'hello', 'hello', 'hello', 'world')
    index.add thing.new(3, 'hello', 'hello', 'hello', 'world')
    index.add thing.new(4, 'hello', 'hello', 'hello', 'world')
    index.add thing.new(5, 'hello', 'hello', 'hello', 'world')

    try.search('hello hello hello').allocations.size.should == 27

    index.add thing.new(6, 'world', 'world', 'world', 'hello')

    try.search('hello hello world').allocations.size.should == 64
  end

  # # This was described by Niko
  # # and references a case where
  # # an attribute and the id referenced
  # # to the same String.
  # #
  # context 'fun cases' do
  #   it 'stopwords destroy ids (final: id reference on attribute)' do
  #     index = Picky::Index.new :stopwords do
  #       key_format :to_sym
  #       indexing splits_text_on: /[\\\/\s\"\'\&_,;:]+/i,
  #                stopwords: /\b(and|the|or|on|of|in|der|die|das|und|oder)\b/i
  #       category :text
  #     end
  #
  #     referenced = "this and that"
  #
  #     require 'ostruct'
  #
  #     thing = OpenStruct.new id: referenced, text: referenced
  #
  #     index.add thing
  #
  #     try = Picky::Search.new index
  #
  #     try.search("this").ids.should == ["this  that"]
  #   end
  # end

end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
picky-4.31.3 spec/functional/regression_spec.rb
picky-4.31.2 spec/functional/regression_spec.rb
picky-4.31.1 spec/functional/regression_spec.rb
picky-4.31.0 spec/functional/regression_spec.rb
picky-4.30.0 spec/functional/regression_spec.rb
picky-4.29.0 spec/functional/regression_spec.rb
picky-4.28.1 spec/functional/regression_spec.rb
picky-4.27.1 spec/functional/regression_spec.rb
picky-4.27.0 spec/functional/regression_spec.rb
picky-4.26.2 spec/functional/regression_spec.rb
picky-4.26.1 spec/functional/regression_spec.rb
picky-4.26.0 spec/functional/regression_spec.rb
picky-4.25.3 spec/functional/regression_spec.rb
picky-4.25.2 spec/functional/regression_spec.rb
picky-4.25.1 spec/functional/regression_spec.rb
picky-4.25.0 spec/functional/regression_spec.rb
picky-4.24.0 spec/functional/regression_spec.rb
picky-4.23.2 spec/functional/regression_spec.rb
picky-4.23.1 spec/functional/regression_spec.rb
picky-4.23.0 spec/functional/regression_spec.rb