Skip to content

v3.2.0

Compare
Choose a tag to compare
@StefanBogdan StefanBogdan released this 02 Sep 09:48
· 1548 commits to main since this release

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 the weaviate.gql.filter.NearText and weaviate.gql.filter.Ask filters.
    The autocorrect is enabled only if Weaviate server has the text-spellcheck module enabled. If autocorrect is True 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.