This commit is contained in:
parent
91a2854537
commit
8bc7a471cd
|
@ -37,10 +37,21 @@ index_settings = {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"body": {"type": "text", "analyzer": "ru"},
|
"body": {"type": "text", "analyzer": "ru"},
|
||||||
"title": {"type": "text", "analyzer": "ru"},
|
#"cover": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
"subtitle": {"type": "text", "analyzer": "ru"},
|
#"created_at": {"type": "long"},
|
||||||
|
#"created_by": {"type": "long"},
|
||||||
|
#"featured_at": {"type": "long"},
|
||||||
|
#"id": {"type": "long"},
|
||||||
|
#"lang": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
|
#"layout": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
"lead": {"type": "text", "analyzer": "ru"},
|
"lead": {"type": "text", "analyzer": "ru"},
|
||||||
# 'author': {'type': 'text'},
|
"media": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
|
# "oid": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
|
# "published_at": {"type": "long"},
|
||||||
|
# "slug": {"type": "text", "fields": {"keyword": {"type": "keyword", "ignore_above": 256}}},
|
||||||
|
"subtitle": {"type": "text", "analyzer": "ru"},
|
||||||
|
"title": {"type": "text", "analyzer": "ru"},
|
||||||
|
# "updated_at": {"type": "long"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -151,16 +162,23 @@ class SearchService:
|
||||||
def index(self, shout):
|
def index(self, shout):
|
||||||
if self.client:
|
if self.client:
|
||||||
logger.debug(f"Индексируем пост {shout.id}")
|
logger.debug(f"Индексируем пост {shout.id}")
|
||||||
asyncio.create_task(self.perform_index(shout))
|
index_body = {
|
||||||
|
"body": shout.body,
|
||||||
|
"title": shout.title,
|
||||||
|
"subtitle": shout.subtitle,
|
||||||
|
"lead": shout.lead,
|
||||||
|
"media": shout.media,
|
||||||
|
}
|
||||||
|
asyncio.create_task(self.perform_index(shout, index_body))
|
||||||
else:
|
else:
|
||||||
logger.error("клиент не инициализован, невозможно проидексировать")
|
logger.error("клиент не инициализован, невозможно проидексировать")
|
||||||
|
|
||||||
async def perform_index(self, shout):
|
async def perform_index(self, shout, index_body):
|
||||||
if self.client:
|
if self.client:
|
||||||
self.client.index(
|
self.client.index(
|
||||||
index=self.index_name,
|
index=self.index_name,
|
||||||
id=str(shout.id),
|
id=str(shout.id),
|
||||||
body=shout.dict()
|
body=index_body
|
||||||
)
|
)
|
||||||
|
|
||||||
async def search(self, text, limit, offset):
|
async def search(self, text, limit, offset):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user