The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dancer::SearchApp::IndexSchema - schema definition for the Elasticsearch index

Consider maybe extending this so different items (like Tweets, RSS) have different fields instead of mushing all metadata into the same schema

Boost direct matches, still allow synonyms

PUT /<index_name>/<type_name>/_mapping { "<type>": { "properties": { "title": { "type": "string", "fields": { "exact": { "type": "string", "index": "not_analyzed" }, "synonym": { "type": "string", "index": "analyzed", "analyzer": "synonym_analyzer" }, "stemmed": { "type": "string", "index": "analyzed", "analyzer": "stemming_analyzer" } } } } } }

And the following query should match as you wish :

POST /<index_name>/<type_name>/_search { "query": { "multi_match": { "query": "injury", "fields": [ "title.exact^3", "title.synonym^2", "title.stemmed" ] } } }

create_mapping

Defines a Dancer::SearchApp index. This is currently the following specification:

        "properties" => {
            "url"        => { type => "text" }, # file://-URL
            "title"      => multilang_text('title',$analyzer),
            "author"     => multilang_text('author', $analyzer),
            "content"    => multilang_text('content',$analyzer),
            'mime_type'  => { type => "string" }, # text/html etc.
            "creation_date"    => {
              "type"  =>  "date",
              "format" => "yyyy-MM-dd HH:mm:ss",
            },
        },

find_or_create_index

  my $found = find_or_create_index( $es, $index_name, $lang, $type );
  $found->then( sub {
      my( $name ) = @_;
      print "Using index '$name'\n";
  });

Returns the full name for the index $index_name, concatenated with the language. The language is important to chose the correct stemmer. Existing indices will be cached in the package global variable %indices.

REPOSITORY

The public repository of this module is https://github.com/Corion/dancer-searchapp.

SUPPORT

The public support forum of this module is https://perlmonks.org/.

TALKS

I've given a talk about this module at Perl conferences:

German Perl Workshop 2016, German

BUG TRACKER

Please report bugs in this module via the RT CPAN bug queue at https://rt.cpan.org/Public/Dist/Display.html?Name=Dancer-SearchApp or via mail to dancer-searchapp-Bugs@rt.cpan.org.

AUTHOR

Max Maischein corion@cpan.org

COPYRIGHT (c)

Copyright 2014-2016 by Max Maischein corion@cpan.org.

LICENSE

This module is released under the same terms as Perl itself.