v3.2.0
Fixes/updates in weaviate.wcs.WCS
class:
- Fixed progress bar for
weaviate.wcs.WCS.create
, it is being updated in Notebooks too, instead of printing each iteration on new line. - Method
weaviate.wcs.WCS.create
now prints the creation status above the bar.
Updates in weaviate.gql
sub-package:
- New key-value
autocorrect: <bool>
introduced for theweaviate.gql.filter.NearText
andweaviate.gql.filter.Ask
filters.
Theautocorrect
is enabled only if Weaviate server has thetext-spellcheck
module enabled. Ifautocorrect
isTrue
the query is corrected before the query is made. Usage example:
# with 'nearText' filter
client.query\
.get('Article', ['title', 'author'])\
.near_text(
{
'concepts': ['Ecconomy'],
'autocorrect': True
}
)
# the concept should be corrected to 'Economy'
# with 'ask' filter
client.query\
.get('Article', ['title', 'author'])\
.with_ask(
{
'question': 'When was the last financial crysis?',
'autocorrect': True
}
)
# the question should be corrected to 'When was the last financial crisis?'
- New method
weaviate.gql.get.GetBuilder.with_additional
is added to GET the_additional
properties. Usage example:
# single additional property with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
id
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional('id']) # argument as `str`
# multiple additional property with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
id
certainty
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(['id', 'certainty']) # argument as `List[str]`
# additional properties as clause with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
classification {
basedOn
classifiedFields
completed
id
scope
}
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
{
'classification' : ['basedOn', 'classifiedFields', 'completed', 'id']
}
) # argument as `dict[str, List[str]]`
# or with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
classification {
completed
}
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
{
'classification' : 'completed'
}
) # argument as `Dict[str, str]`
Consider the following GraphQL clause:
'''
{
Get {
Article {
title
author
_additional {
token (
properties: ["content"]
limit: 10
certainty: 0.8
) {
certainty
endPosition
entity
property
startPosition
word
}
}
}
}
}
'''
# Then the python translation of this is the following:
clause = {
'token': [ # if only one, can be passes as `str`
'certainty',
'endPosition',
'entity',
'property',
'startPosition',
'word',
]
}
settings = {
'properties': ["content"], # is required
'limit': 10, # optional, int
'certainty': 0.8 # optional, float
}
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
(clause, settings)
) # argument as `Tuple[Dict[str, List[str]], Dict[str, Any]]`
If the desired clause does not match any example above, then the clause can always be
converted to string before passing it to the .with_additional()
method.