Skip to content

Instantly share code, notes, and snippets.

@hsm207
Created March 21, 2023 08:46
Show Gist options
  • Save hsm207/e3099a12dce426b0c4ad9ccdf67ec498 to your computer and use it in GitHub Desktop.
Save hsm207/e3099a12dce426b0c4ad9ccdf67ec498 to your computer and use it in GitHub Desktop.
bug with bm25 query
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from weaviate import Client\n",
"import weaviate"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'3.15.2'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"weaviate.__version__"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"client = Client(\"http://weaviate:8080\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"client.schema.create_class({\n",
" \"class\": \"Book\",\n",
" \"description\": \"A book\",\n",
" \"properties\": [\n",
" {\n",
" \"name\": \"title\",\n",
" \"dataType\": [\"string\"],\n",
" \"description\": \"The title of the book\"\n",
" },\n",
" {\n",
" \"name\": \"author\",\n",
" \"dataType\": [\"string\"],\n",
" \"description\": \"The author of the book\"\n",
" },\n",
" {\n",
" \"name\": \"text\",\n",
" \"dataType\": [\"string\"],\n",
" \"description\": \"The text of the book\"\n",
" }\n",
" ]\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{Get{Book(bm25:{query: \"{'query': 'hello world', 'properties': ['text']}\"}){title author}}}\n"
]
}
],
"source": [
"bm25 = {\n",
" \"query\": \"hello world\",\n",
" \"properties\": [\"text\"]\n",
"}\n",
"\n",
"query = client.query.get(\"Book\", [\"title\", \"author\"]).with_bm25(bm25).build()\n",
"print(query)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment