getdkan/lunr.php

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (1.0.1) of this package.

Maintainers

Package info

github.com/GetDKAN/lunr.php

pkg:composer/getdkan/lunr.php

Statistics

Installs: 8 545

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 5

1.0.1 2019-10-02 02:18 UTC

This package is auto-updated.

Last update: 2026-05-27 17:54:21 UTC


README

CircleCI Maintainability Test Coverage

This project creates an index for Lunr.js in PHP. This will allow you to generate a Lunr.js endpoint in a PHP application.

Installation

composer install

Tests

Run:

./vendor/bin/phpunit

Usage

Generating an index is similar to Lunr.js.

  // Instantiate the builder.
  $build = new BuildLunrIndex();
  // Add a unique id.
  $build->ref('identifier');
  // Add fields.
  $build->field("title");
  $build->field("description");
  // Add transforms to the pipeline.
  $pipeline->add('LunrPHP\LunrDefaultPipelines::trimmer');
  $pipeline->add('LunrPHP\LunrDefaultPipelines::stop_word_filter');
  $pipeline->add('LunrPHP\LunrDefaultPipelines::stemmer');
 // Load docs.
  $string = file_get_contents("./fixtures/fixture.json");
  $datasets = json_decode($string, true);
  // Add documents to the index.
  foreach ($datasets as $dataset) {
    $build->add($dataset);
  }

  // Output the index.
  $output = $build->output();

  // Place wherever.
  echo json_encode($output, JSON_PRETTY_PRINT);

Pipelines

There is a simple Pipelines class to run transforms on the terms during indexing. See src/pipelines.php for included pipelines.

Missing Features

This index is missing boosts and several other indexing features.