fix: standard

This commit is contained in:
李如威 2025-12-15 18:05:30 +08:00
parent 766624c04c
commit 88ddcaa11f
1 changed files with 2 additions and 4 deletions

View File

@ -1,11 +1,10 @@
import httpx import httpx
from pipeline.config import config from pipeline.config import config
class AsyncES: class AsyncES:
def __init__(self): def __init__(self):
self.base = f"{config['es_host']}:{config['es_port']}" self.base = f"{config['es_host']}:{config['es_port']}"
self.auth = (config["es_user"], config["es_password"]) self.auth = (config["es_user"], config['es_password'])
async def create_index(self, index: str): async def create_index(self, index: str):
""" """
@ -16,7 +15,7 @@ class AsyncES:
f"{self.base}/{index}", f"{self.base}/{index}",
auth=self.auth, auth=self.auth,
json={ json={
"settings": {"analysis": {"analyzer": {"default": {"type": "ik_max_word"}}}}, "settings": {"analysis": {"analyzer": {"default": {"type": "standard"}}}},
"mappings": { "mappings": {
"properties": { "properties": {
"text": {"type": "text"}, "text": {"type": "text"},
@ -43,5 +42,4 @@ class AsyncES:
resp = await client.post(f"{self.base}/{index}/_search", auth=self.auth, json={"size": top_k, "query": {"match": {"text": query}}}) resp = await client.post(f"{self.base}/{index}/_search", auth=self.auth, json={"size": top_k, "query": {"match": {"text": query}}})
return resp.json() return resp.json()
es_client = AsyncES es_client = AsyncES