vintasoftware / django-zombodb

Easy Django integration with Elasticsearch through ZomboDB Postgres Extension
https://django-zombodb.readthedocs.io
MIT License
149 stars 10 forks source link

Add support to Elastic type mapping #21

Closed gtsalles closed 5 years ago

gtsalles commented 5 years ago

This adds a parameter field_mapping to ZomboDBIndex to receive custom type mappings.

The idea is to pass a dict with the field name as key, and another dict as value containing the desired elasticsearch mapping for the indexed field.

# Example

class Meta:
    indexes = [
        ZomboDBIndex(fields=[
            'name',
        ],
        field_mapping={
            'name': {"type": "text", "copy_to": "zdb_all",
                     "analyzer": "fulltext_with_shingles",
                     "search_analyzer": "fulltext_with_shingles_search"},
        })
    ]

Related to #2

codecov-io commented 5 years ago

Codecov Report

Merging #21 into master will increase coverage by 0.04%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   99.13%   99.18%   +0.04%     
==========================================
  Files           8        9       +1     
  Lines         230      244      +14     
  Branches       21       24       +3     
==========================================
+ Hits          228      242      +14     
  Misses          1        1              
  Partials        1        1
Impacted Files Coverage Δ
django_zombodb/indexes.py 100% <100%> (ø) :arrow_up:
django_zombodb/querysets.py 100% <100%> (ø) :arrow_up:
django_zombodb/serializers.py 100% <100%> (ø)
django_zombodb/helpers.py 91.66% <100%> (-0.65%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 138741d...5f42ccf. Read the comment docs.

fjsj commented 5 years ago

Thanks @gtsalles ! Awesome work