BaseQuery

class polyglotdb.query.base.query.BaseQuery(corpus, to_find)[source]

Methods

__init__(corpus, to_find) Initialize self.
aggregate(*args) Aggregate the results of the query by a grouping factor or overall.
all()
cache()
clear_columns() Remove any columns specified.
columns(*args) Add one or more additional columns to the results.
count() Returns the number of rows in the query.
create_subset(label)
cypher() Generates a Cypher statement based on the query.
cypher_params()
delete() Remove the results of a query from the graph.
filter(*args) Apply one or more filters to a query.
generate_return() Generates final statement from query object, calling whichever one of the other generate statements is specified in the query obj
get()
group_by(*args) Specify one or more fields for how aggregates should be grouped.
limit(limit) sets object limit to parameter limit
offset(number)
optional_nodes()
order_by(field[, descending]) Specify how the results of the query should be ordered.
preload(*args)
remove_subset(label)
required_nodes()
set_properties(**kwargs)
to_csv(path) Same as all, but the results of the query are output to the specified path as a CSV file.
to_json()
aggregate(*args)[source]

Aggregate the results of the query by a grouping factor or overall. Not specifying a group_by in the query will result in a single result for the aggregate from the whole query.

clear_columns()[source]

Remove any columns specified. The default columns for any query are the id of the token and the label of the type.

columns(*args)[source]

Add one or more additional columns to the results.

Columns should be Attribute objects.

count()[source]

Returns the number of rows in the query.

cypher()[source]

Generates a Cypher statement based on the query.

delete()[source]

Remove the results of a query from the graph. CAUTION: this is irreversible.

filter(*args)[source]

Apply one or more filters to a query.

generate_return()[source]

Generates final statement from query object, calling whichever one of the other generate statements is specified in the query obj

Parameters:
query : :class: ~polyglotdb.graph.GraphQuery

a query object

Returns:
str

cypher formatted string

group_by(*args)[source]

Specify one or more fields for how aggregates should be grouped.

limit(limit)[source]

sets object limit to parameter limit

order_by(field, descending=False)[source]

Specify how the results of the query should be ordered.

Parameters:
field : Attribute

Determines what the ordering should be based on

descending : bool, defaults to False

Whether the order should be descending

to_csv(path)[source]

Same as all, but the results of the query are output to the specified path as a CSV file.