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.7.tar.gz (11.0 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for wagtail-extendedsearch-1.0.7.tar.gz
Algorithm Hash digest
SHA256 d248de0e6186f0f22e8f6f3d97a67ec0437d826610488be57132f6c38e43b478
MD5 2a8a2939258908120c53e5d8f9f89318
BLAKE2b-256 5d2fdd31cdbf8f6f6b95bc03162c191840f06b4c455de53c2d3ccd58cb5cefd0

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