import { esClient } from "../elasticsearch";

const USER_INDEX = 'users';
export async function createUser(user: any): Promise<ReturnType<typeof esClient.index>> {
    return esClient.index({
        index: USER_INDEX,
        document: user,
    });
}

export async function searchUser(query: string): Promise<ReturnType<typeof esClient.search>> {
    return esClient.search({
        index: USER_INDEX,
        query: {
            multi_match: {
                query,
                fields: ['name', 'email'],
            },
        },
    });
}
