loader = TextLoader('../../../state_of_the_union.txt')
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
for d in docs:
    d.metadata = {'some': 'metadata'}
docsearch = MyScale.from_documents(docs, embeddings)
query = "What did the president say about Ketanji Brown Jackson"
docs = docsearch.similarity_search(query)
Inserting data...: 100%|██████████| 42/42 [00:18<00:00,  2.21it/s]
print(docs[0].page_content)
As Frances Haugen, who is here with us tonight, has shown, we must hold social media platforms accountable for the national experiment they’re conducting on our children for profit. 
It’s time to strengthen privacy protections, ban targeted advertising to children, demand tech companies stop collecting personal data on our children. 
And let’s get all Americans the mental health services they need. More people they can turn to for help, and full parity between physical and mental health care. 
Third, support our veterans. 
Veterans are the best of us. 
I’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home. 
My administration is providing assistance with job training and housing, and now helping lower-income veterans get VA care debt-free.  
Our troops in Iraq and Afghanistan faced many dangers.
Get connection info and data schema#
print(str(docsearch))
Filtering#
You can have direct access to myscale SQL where statement. You can write WHERE clause following standard SQL.
rtdocs_stable/api.python.langchain.com/en/stable/modules/indexes/vectorstores/examples/myscale.html