Skip to main content

Add some more functionality to the wagtail elasticsearch search backend

Project description

Add some more functionality to the wagtail elasticsearch search backend

This plugin adds search capabilities through elasticsearch. Elasticsearch provides scored search results, facetting, suggestions and autocomplete.

Features

  • filter on fields that are not in the database

  • order on fields that are not in the database

  • search suggestions when no results are found

This readme is far from done and complete, take care.

Configuration

  • WAGTAILSEARCHEXTENSION_NUM_SUGGESTIONS: Number of suggestions to offer

  • WAGTAILSEARCHEXTENSION_BOOSTED_FIELDS: Fields to be boosted

  • WAGTAILSEARCHEXTENSION_FACET_BUCKET_SIZE: How many items to allow in a bucket

  • WAGTAILSEARCHEXTENSION_PAGE_SIZE: How many items to retrieve from elasticsearc in one go.

  • WAGTAILSEARCHEXTENSION_MULTIMATCH_TYPE: How should the score be calculated in a multimatch query

  • WAGTAILSEARCHEXTENSION_DEFAULT_OPERATOR: Should all the search terms be present or just one of the search terms? (default=or) change to and if all the search terms should be present.

Facet types

Facets can be configured using the get_facets classmethod. This is a list of dictionaries that must look like this:

[
    {
      "label": "Brand",
      "name": "brand",
      "type": "term",
    }
]

Currently 2 facet types are supported 1. term, facets are treated as keywords and counted and matched as such. 2. range, facets are treated as integer ranges, the ranges parameter must de defined for type range. It can be used to segment the range, eg. [10, 100, 100] will yield 4 filters ranges, 0-9, 10-99, 100-999 and 1000+

Facet ordering

The default ordering for facets is alphnumerically ({"-key", "asc"}). The number of facets returned can be changed with the ocyan parameter facet_bucket_size. By default only 10 facets will be returned. If there are a lot more facets then 10 and you do not want to increase the number of facets it can make a lot of sense to order by the number of occurrences, this will select the most useful facets. The ordering can be changed in the facet definition:

{
  "label": "Brand",
  "name": "brand",
  "type": "term",
  "order": { "_count" : "desc" }
}

Now the most popular brands will be shown. For more info, please read https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order

Boosting fields

Boosting field relevance is done by using the WAGTAILSEARCHEXTENSION_BOOSTED_FIELDS setting:

"boosted_fields": {
  "upc": 888,
  "title": 777
}

Tweaking the mapping

You can override/extend the elasticsearch settings by using the ELASTICSEARCH_EXTRA_SETTINGS setting

For example:

WAGTAILSEARCHEXTENSION_ELASTICSEARCH_EXTRA_SETTINGS = {
    'settings': {
        'analysis': {
            'analyzer': {
                'custom_analyzer': {
                  'type': 'custom',
                  'tokenizer': 'custom_tokenizer',
                  'filter': ['asciifolding', 'ngram']
                }
            },
            'tokenizer': {
                'custom_tokenizer': {
                    'type': 'nGram',
                    'min_gram': 3,
                    'max_gram': 15
                }
            }
        }
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail-extendedsearch-1.0.6.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

wagtail_extendedsearch-1.0.6-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file wagtail-extendedsearch-1.0.6.tar.gz.

File metadata

File hashes

Hashes for wagtail-extendedsearch-1.0.6.tar.gz
Algorithm Hash digest
SHA256 cbeda7f0a256c1c057e1fc8c026e0b5571121f8b37b587fec6135b716118a1a8
MD5 7092964228cbe2a832a7b839714b0af7
BLAKE2b-256 1a0e86eb0fb6c9dddca4c4eb0c755fe9f613fbc5ca4af72c0151996b34e68eba

See more details on using hashes here.

File details

Details for the file wagtail_extendedsearch-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_extendedsearch-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 995cc5c8c02f8f383c1e1fa71bd33e1c5225f8b28743a49435ea3c32e814746a
MD5 a01a4f63d27b4ee2b5e1c77575265305
BLAKE2b-256 03a4f509ed14b6f6cd9c2cedc928c5d4ddfdbaeceda0c6f4a5579c057f72d26c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page