Skip to content

Issue with indexing when sanitizing attributes #323

Open
@joshio1

Description

@joshio1

Description
When I use sanitize attributes, search does not return expected results. For eg. I have:

class Book
   meilisearch sanitize: true do
     attribute :title, :description
  end
end

This is only for book with description which has some HTML in this format:

book = create(:book, description: "<div>Hello</div><div>Hi</div>")

Now, when I search like this:

[3] pry(#<RSpec::ExampleGroups::Library>)> Book.raw_search('Hi')
=> {"hits"=>[],
 "query"=>"Hi",
 "processingTimeMs"=>0,
 "limit"=>20,
 "offset"=>0,
 "estimatedTotalHits"=>0,
 "nbHits"=>0}

Expected behavior
I was expecting to get 1 hit for the word Hi.

Current behavior
But I get 0 hits for Hi. I get 1 hit if we search Hello instead and also if book is created using this description: <div>Hello</div><div> Hi</div> (i.e. one space before Hi)

Environment (please complete the following information):

  • OS: Mac
  • Meilisearch server version: 1.4.2
  • meilisearch-rails version: 0.10.1
  • Rails version: 7.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportIssues related to support questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions