<commit_before>class SearchService
  class FuzzySearch < BaseSearch
    class ReferenceQuery < FuzzyQuery
      def query(*)
        {
          index: "#{TradeTariffBackend.search_namespace}-search_references",
          type: 'search_reference',
          search: {
            query: {
              bool: {
                must: {
                  multi_match: {
                    query: query_string,
                    fields: ['title'],
                    operator: 'and' # all terms must be present
                  }
                },
                filter: {
                  bool: {
                    must: [
                      { term: { reference_class: index.type } },
                      {
                        nested: {
                          path: "reference",
                          query: {
                            bool: {
                              must: { match_all: {} },
                              filter: {
                                bool: {
                                  should: [
                                    # actual date is either between item's (validity_start_date..validity_end_date)
                                    {
                                      bool: {
                                        must: [
                                          { range: { "reference.validity_start_date" => { lte: date } } },
                                          { range: { "reference.validity_end_date" => { gte: date } } }<commit_msg>fixed `reference_class` matching.<commit_after>class SearchService
  class FuzzySearch < BaseSearch
    class ReferenceQuery < FuzzyQuery
      def query(*)
        {
          index: "#{TradeTariffBackend.search_namespace}-search_references",
          type: 'search_reference',
          search: {
            query: {
              bool: {
                must: {
                  multi_match: {
                    query: query_string,
                    fields: ['title'],
                    operator: 'and' # all terms must be present
                  }
                },
                filter: {
                  bool: {
                    must: [
                      { term: { reference_class: index.type.capitalize } },
                      {
                        nested: {
                          path: "reference",
                          query: {
                            bool: {
                              must: { match_all: {} },
                              filter: {
                                bool: {
                                  should: [
                                    # actual date is either between item's (validity_start_date..validity_end_date)
                                    {
                                      bool: {
                                        must: [
                                          { range: { "reference.validity_start_date" => { lte: date } } },
                                          { range: { "reference.validity_end_date" => { gte: date } } }
{'fraction_non_alphanumeric': 0.08145975887911372, 'fraction_numerical': 0.0, 'mean_word_length': 0.7374080362195812, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5031112', 'n_tokens_mistral': 665, 'n_tokens_neox': 623, 'n_words': 128}