Class: Lutaml::UmlRepository::StaticSite::SearchIndexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/uml_repository/static_site/search_index_builder.rb

Overview

Builds a lunr.js-compatible search index from a UML repository.

The index includes:

  • Document store with searchable content

  • Field configuration for lunr.js

  • Pre-processed tokens for efficient client-side search

Examples:

repository = UmlRepository.from_package("model.lur")
builder = SearchIndexBuilder.new(repository)
index = builder.build

Constant Summary collapse

STOP_WORDS =
%w[
  the a an and or but in on at to for of with from by
  is are was were be been being have has had
  this that these those it its
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, options = {}) ⇒ SearchIndexBuilder

Initialize search index builder

Parameters:

  • repository (UmlRepository)

    The repository to index

  • options (Hash) (defaults to: {})

    Builder options

Options Hash (options):

  • :languages (Array<String>)

    Languages for stemming



33
34
35
36
37
# File 'lib/lutaml/uml_repository/static_site/search_index_builder.rb', line 33

def initialize(repository, options = {})
  @repository = repository
  @options = default_options.merge(options)
  @id_generator = IDGenerator.new
end

Instance Attribute Details

#id_generatorObject (readonly)

Returns the value of attribute id_generator.



20
21
22
# File 'lib/lutaml/uml_repository/static_site/search_index_builder.rb', line 20

def id_generator
  @id_generator
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/lutaml/uml_repository/static_site/search_index_builder.rb', line 20

def options
  @options
end

#repositoryObject (readonly)

Returns the value of attribute repository.



20
21
22
# File 'lib/lutaml/uml_repository/static_site/search_index_builder.rb', line 20

def repository
  @repository
end

Instance Method Details

#buildHash

Build the search index

Returns:

  • (Hash)

    Lunr.js-compatible search index structure



42
43
44
45
46
47
48
49
50
# File 'lib/lutaml/uml_repository/static_site/search_index_builder.rb', line 42

def build
  {
    version: "1.0.0",
    fields: field_definitions,
    ref: "id",
    documentStore: build_document_store,
    pipeline: ["stemmer", "stopWordFilter"],
  }
end