<commit_before>require 'test_helper'
require File.dirname(__FILE__) + '/test_helper.rb'

class Mappings < Test::Unit::TestCase
  load_schema

  class User < ActiveRecord::Base
    elastic_index(
      :mapping => {
        :properties => {
          :name => {:type => "string", :index => "not_analyzed"}
        }
      }
    )
  end
  
  def test_not_analyzed_property
    puts 'indexing'
    
    User.delete_all
    User.delete_index
    Escargot::LocalIndexing.create_index_for_model(User)
    
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')

    User.refresh_index
    
    assert_equal User.search_count('name:pedro'), 0
    assert_equal User.search_count('name:"<NAME>"'), 1
  end
end<commit_msg>@bugFix Test Mappings counts, because change functionality in rubberband '0.0.5'<commit_after>require 'test_helper'
require File.dirname(__FILE__) + '/test_helper.rb'

class Mappings < Test::Unit::TestCase
  load_schema

  class User < ActiveRecord::Base
    elastic_index(
      :mapping => {
        :properties => {
          :name => {:type => "string", :index => "not_analyzed"}
        }
      }
    )
  end
  
  def test_not_analyzed_property
    puts 'indexing'
    
    User.delete_all
    User.delete_index
    Escargot::LocalIndexing.create_index_for_model(User)
    
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')
    User.create(:name => '<NAME>')

    User.refresh_index

    assert_equal User.search_count('name=pedro'), 0
    assert_equal User.search_count('name="<NAME>"'), 1
  end
end
{'fraction_non_alphanumeric': 0.14484007242003621, 'fraction_numerical': 0.004224502112251056, 'mean_word_length': 3.1658291457286434, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6053476', 'n_tokens_mistral': 551, 'n_tokens_neox': 540, 'n_words': 98}