Skip to content

Commit

Permalink
修改mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
liangliangyy committed Sep 23, 2019
1 parent 7db717c commit 36edc1a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions blog/documents.py
Expand Up @@ -55,18 +55,18 @@ def create(url, time_taken, log_datetime, type, useragent):


class ArticleDocument(Document):
body = Text(analyzer='ik_max_word')
title = Text(analyzer='ik_max_word')
body = Text(analyzer='ik_max_word', search_analyzer='ik_smart')
title = Text(analyzer='ik_max_word', search_analyzer='ik_smart')
author = Object(properties={
'nickname': Text(analyzer='ik_max_word'),
'nickname': Text(analyzer='ik_max_word', search_analyzer='ik_smart'),
'id': Integer()
})
category = Object(properties={
'name': Text(analyzer='ik_max_word'),
'name': Text(analyzer='ik_max_word', search_analyzer='ik_smart'),
'id': Integer()
})
tags = Object(properties={
'name': Text(analyzer='ik_max_word'),
'name': Text(analyzer='ik_max_word', search_analyzer='ik_smart'),
'id': Integer()
})

Expand Down Expand Up @@ -99,12 +99,12 @@ def create_index(self):

def delete_index(self):
from elasticsearch import Elasticsearch
es = Elasticsearch()
es = Elasticsearch(settings.ELASTICSEARCH_DSL['default']['hosts'])
es.indices.delete(index='blog', ignore=[400, 404])

def convert_to_doc(self, articles):
return [ArticleDocument(meta={'id': article.id}, body=article.body, title=article.title,
auth={
author={
'nikename': article.author.username,
'id': article.author.id
},
Expand Down

0 comments on commit 36edc1a

Please sign in to comment.